css 伪类:last-child等不起作用
来源:互联网 发布:淘宝手办黑店 编辑:程序博客网 时间:2024/06/05 18:48
#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%;
}
<div id="icons">
<div class="column column1">
<div class="txt">
<p>打造全新世界观,让你更爱你的生活</p>
</div>
</div>
<div class="column column2">
<div class="txt">
<p>丰富多彩的公益活动,发挥新世界的主人公意识</p>
</div>
</div>
<div class="column column3">
<div class="txt">
<p>时尚的新理念,超前体验未知的生活</p>
</div>
</div>
<div class="column column4">
<div class="txt">
<p>完善的培养机制,培养你全新的世界观</p>
</div>
</div>
</div>
本以为在 `#icons .column .txt` 处加隔条后,想把最后一个竖隔条设为 `border:none;` 没想到如上如所示,全部都不见了。
原来,伪类选择器`:first-child`和`:last-child`是根据父级进行筛选的,`#icons .column .txt:last-child` 的父级是‘.txt`,在该处上的子级只有一个,最后的子级当然也是自己本身,所以要想达到效果,就应该在‘.txt`的父级添加伪类。
#icons .column:last-child .txt{ border-right: none;}
- css 伪类:last-child等不起作用
- 结构性伪类选择器—last-child
- 【CSS3】---结构性伪类选择器-first-child+last-child
- CSS :first-child 伪类
- css--伪类:first-child
- css:first-child、last-child、nth-child、 nth-last-child
- first-child first-of-type last-child last-of-type 伪类选择器总结
- 【CSS3】结构性伪类选择器—last-child
- 【CSS3】结构性伪类选择器—nth-last-child(n)
- 结构性伪类选择器—nth-last-child(n)
- css中的伪类 之 first-child
- :last-child | CSS属性参考
- IE下的伪类:first-child和:last-child版本支持问题
- :first-child 的坑(first-child的伪类选择器不起作用)
- 链接 <a> 的CSS伪类不起作用
- :nth-last-child() | CSS属性参考
- 在IE678下解决伪类last-child的css2方法
- ie8 不支持伪类 :last-child 怎么办 如何实现相同效果
- 安卓自定义View基础04-自定义view的分类以及常用方法讲解
- iOS Delegate通俗理解,使用详解,你还在仅仅拿来传值使吗?
- img标签读取本地图片
- J.U.C之并发工具类:CyclicBarrier
- 最短路径问题
- css 伪类:last-child等不起作用
- linux基本命令及操作15(ftp)
- Struts2官方教程:消息资源文件(Message Resource Files)
- netty学习六:第一个protobuf小demo
- LaTex常见编译问题
- 二分图最大匹配
- AL
- 位操作符-数字如何转化为二进制并进行操作
- IO流--概述