Created
July 24, 2013 09:14
-
-
Save zmmbreeze/6069120 to your computer and use it in GitHub Desktop.
A CodePen by mzhou.
This file contains hidden or 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
<div class="fluid-wrap"> | |
<img src="http://placehold.it/800x600" alt="" /> | |
</div> |
This file contains hidden or 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
// | |
// 自适应布局:长宽比固定的视频、flash、图片、iframe或class为`est-fixed-ratio`的元素 | |
// | |
// 固定尺寸比例,固定额外高度(默认为0,可以用作视频播放器的控制栏高度) | |
// .fluid-video > embed | |
// .fluid-video > object | |
// .fluid-video > iframe | |
// .fluid-video > div | |
// | |
// http://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php | |
.est-layout-fluid-fixed-ratio(@width, @height, @extraHeight: 0) { | |
position: relative; | |
padding-bottom: ((unit(@height) / unit(@width)) * 100%); /* 16:9 */ | |
padding-top: @extraHeight; | |
height: 0; | |
object, embed, iframe, img, .est-fixed-ratio { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
} | |
} | |
.fluid-wrap { | |
.est-layout-fluid-fixed-ratio(800, 600); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment