Created
September 17, 2018 10:27
-
-
Save ssdemajia/e76bb17522eea7048a782c711523c78b to your computer and use it in GitHub Desktop.
使用flex、align-items、justify-content居中元素
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="inner"> | |
sssss | |
</div> | |
</div> | |
</body> | |
<style> | |
#drag { | |
background-color: aquamarine; | |
position: absolute; | |
width: 100px; | |
height: 100px; | |
} | |
.container { | |
width: 300px; | |
height: 200px; | |
border: 3px solid #548612; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
.inner { | |
border: 3px solid #458761; | |
padding: 20px; | |
} | |
</style> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment