HTML+CSS进阶学习摘录(Display属性)(三)

一、display:none 与 visbility:hidden

    display:none  元素隐藏,不占据原来位置

   visibility:hidden 元素隐藏,占据原来位置

二、display:table-cell

 (1)图片垂直居中于元素

父元素
{
display:table:cell;
vertical-align:center;
}
子元素
{
  vertical-align:center;
}

(2)等高布局

#wrapper
{
	display:table-row;
	width:auto;
	height:auto;
}
#img-box
{
	display:table-cell;
	vertical-align:middle;
	text-align:center;
	width:150px;
	height:auto;
	border:1px solid red;
}
#text-box
{
	display:table-cell;
	width:200px;
	border:1px solid red;
	border-left:none;
	padding:10px;
}

<div id="wrapper">
  <div id="img-box">
  <img src="m1.jpg" alt="" />
  </div>
  <div id="text-box">
  <span>Dark light, just light each other. The responsibility that 
you and my shoulders take together, such as 
one dust covers up. Only afraid the light suddenly put
 out in theendless dark night and countless
 loneliness.</span>
  
  </div>
</div>
                                                           

(3)自动平均划分元素

*{
	padding:0;
	margin:0;
}
ul
{
	list-style-type:none;
	display:table;
	width:300px;
}
li{
	 display:table-cell;
	 height:60px;
	 line-height:60px;
	 text-align:center;
	 color:white;
}
ul li:nth-child(1){ background-color:Red;}
ul li:nth-child(2){ background-color:Orange;}
ul li:nth-child(3){ background-color:Blue;}
ul li:nth-child(4){ background-color:silver;}
ul li:nth-child(5){ background-color:Purple;}

<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
</ul>
                                                       

三、去除inline-block 元素间距

在父元素中添加
父元素
{
font-size:0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值