css 保持比例的盒子。来自http://www.mademyday.de/css-height-equals-width-with-pure-css.html

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css 保持比例的盒子。来自http://www.mademyday.de/css-height-equals-width-with-pure-css.html相关的知识,希望对你有一定的参考价值。

/* <div class="ratio-box"><div class="ratio-content">content</div></div> */

.ratio-box {
	position:relative;
	width:100%; /*set the width here*/
}
.ratio-box::before {
	content:"";
	display:block;
	padding-top:75%;	/*4:3 ratio*/
	padding-top:56.25%;	/*16:9 ratio*/
	/*(padding percentages refer to the width of the containing block)*/
}
.ratio-content {
	position:absolute;
	top:0; right:0; bottom:0; left:0;
}

以上是关于css 保持比例的盒子。来自http://www.mademyday.de/css-height-equals-width-with-pure-css.html的主要内容,如果未能解决你的问题,请参考以下文章

CSS DIV绝对定位 后 页面的大小改变 div层位置如何保持不变

css 使用rems的黄金比例印刷比例。 http://www.modularscale.com/?1.6,.8&rem&1.618&web&text

使用 jQuery 或 CSS 保持图像比例

css - 如何在调整窗口大小时连续制作弹性项目3并保持1:1的比例[重复]

以统一大小调整多个图像的大小并保持比例

CSS3如何固定图片宽度使图片高度按图片比例自适应?