Last active
March 9, 2017 06:28
-
-
Save Allenice/1fc5a2f54a2f514d6f17 to your computer and use it in GitHub Desktop.
div 宽高等比
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"> | |
<title>Document</title> | |
<style> | |
.h-equal-w { | |
width: 100px; | |
overflow: hidden; | |
background: #ccc; | |
position: relative; | |
} | |
.h-equal-w:before { | |
content: ''; | |
display: block; | |
padding-top: 100%; | |
} | |
.content { | |
width: 100%; | |
height: 100%; | |
position: absolute; | |
left: 0; | |
top: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="h-equal-w"> | |
<div class="content">height equal width</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment