#icons{
border: 1px solid bisque;
height: 250px;
}
#icons .column{//每一列
width:25%;
display: inline-block;float: left;
text-align: center;
}
#icons .column .txt{//每列文字
width:100%;
height: 52px;
margin-top: 134px;
border-right: 2px solid #787b83;//在此处加隔条
}
#icons .column.txt:last-child{
border-right: none;
}
#icons .column .txt p{
width: 160px;
height: 52px;
font-size: 14px;
line-height: 18px;
color: #767777;
margin-left: 25%;
}
html:
打造全新世界观,让你更爱你的生活
丰富多彩的公益活动,发挥新世界的主人公意识
时尚的新理念,超前体验未知的生活
完善的培养机制,培养你全新的世界观
效果如下:
本以为在 `#icons .column .txt` 处加隔条后,想把最后一个竖隔条设为 `border:none;` 没想到如上如所示,全部都不见了。
原来,伪类选择器`:first-child`和`:last-child`是根据父级进行筛选的,`#icons .column .txt:last-child` 的父级是‘.txt`,在该处上的子级只有一个,最后的子级当然也是自己本身,所以要想达到效果,就应该在‘.txt`的父级添加伪类。
#icons .column:last-child .txt{
border-right: none;
}
效果如下: