Una

接下来的日子,陆续把未总结的问题补充起来......

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

一、元素等比缩放解决方案

<style>
			 /*等比缩放*/
			        .box{
					position: relative;
					width: 50%;		/* desired width */
					background: #000;
					color: #fff;
				}
				.box:before{
					content: "";
					display: block;
					padding-top: 100%; 	
					background: #f00;
				}
				.content{
					position:  absolute;
					top: 0;
					left: 0;
					bottom: 0;
					right: 0;
				}
		</style>
	
	
		<div class='box'> 
		      <div class='content'>1:1</div> 
	        </div>

  

 包含内容的元素使用绝对定位布局,利用元素的padding的百分比属性去设置元素的高度。

  padding可以设置的值:

    1、长度,非负的固定宽度

    2、百分比,相对于父元素的宽度。

   

posted on 2018-09-18 15:03  youyi2016  阅读(346)  评论(0编辑  收藏  举报