用:after伪元素标签写分割线
来源:互联网 发布:java订单管理系统 编辑:程序博客网 时间:2024/05/24 06:48
最近在手机商城和微信页面很多都用到了分割线,下面总结用到的分割线。
第一种:
效果:
html:
<div class="hot">
<span>产品热卖</span>
</div>
________________________________
style:
.hot{
width:100%;
height:20px;
background-color:#f2f2f2;
text-align:center;
color:#000;
font-size:12px;
line-height:20px;
position:relative;
}
.hot:after{
content:"";
width:100%;
height:1px;
background-color:red;
position:absolute;
bottom:50%;
z-index:1;
left:0;
}
.hot span{
z-index:2;
position: relative;
background-color:#f2f2f2;
padding:0 10px;
}
看着效果还可,就是线有点粗不好看,这个就要用到渐变了。
.hot:after{
content:"";
width:100%;
height:1px;
/*这个就是设置渐变的啦!*/
background-image: -webkit-linear-gradient(top, hsla(0,0%,100%,.1), hsla(0,0%,0%,.1));
background-image: -moz-linear-gradient(top, hsla(0,0%,100%,.1), hsla(0,0%,0%,.1));
background-image: -ms-linear-gradient(top, hsla(0,0%,100%,.1), hsla(0,0%,0%,.1));
background-image: -o-linear-gradient(top, hsla(0,0%,100%,.1), hsla(0,0%,0%,.1));
background-image: linear-gradient(top, hsla(0,0%,100%,.1), hsla(0,0%,0%,.1));
position:absolute;
bottom:50%;
z-index:1;
left:0;
}
加上渐变后的效果,是不是美美滴!
第二种:
效果如下:
html:
<div class="list">
<ul>
<li>产品</li>
<li>法律</li>
<li>体检</li>
<li>案例</li>
<li>新增</li>
</ul>
</div>
style:
.list{
width:100%;
background-color:#f2f2f2;
margin-top:10px;
}
.list ul{
list-style:none;
}
.list li{
height:40px;
padding-left:30px;
position:relative;
}
.list li:after{
content:'';
width:calc(100% - 40px);/*如果两边都要留空位的话就需要计算宽度*/
height:1px;
background-color:red;
bottom:0;
left:40px;
position:absolute;
}
第三种:
效果如下:
html:
<div class="range">
<a href="javascript:;">优惠幅度6.8折</a>
<a href="javascript:;">已有999人购买</a>
</div>
style:
.range {
width: 100%;
background: rgba(0, 0, 0, 0.6);
top: 0;
overflow: hidden;
position: absolute;
}
.range a {
text-decoration: none;
float: left;
text-align: center;
width: 50%;
display: inline-block;
padding: 10px 0;
color: #fff;
font-size: 13px;
}
.range:after {
content: "";
width: 1px;
height: 70%;
background-color: #fff;
position: absolute;
left: 50%;
top: 5px;
}
注意:这里的定位都是固定定位
- :after伪元素标签写分割线
- 用:after伪元素标签写分割线
- 使用css after伪元素构造分割线
- css:after 伪元素
- :after 伪元素
- CSS :after 伪元素
- 伪元素:after和:before
- 伪元素::after和::before
- 伪元素::after和::before
- 伪元素::before和::after
- 伪元素::after和::before
- 伪元素::after和::before
- Before和:After伪元素
- CSS伪元素 :before :after
- befor-after两个伪元素
- 伪元素 之:after,:before
- after伪元素清楚浮动
- 伪元素:before和:after
- 调换两个数
- 数据结构实验2(设计哈弗曼编码和译码系统)
- 乘积最大的拆分
- Java多线程(二)之Atomic:原子变量与原子类
- AList of SCI Journals related to Geomatics
- 用:after伪元素标签写分割线
- 编程心路
- 基于Kafka如何部署一个稳定可靠的zookeeper集群服务
- Kendall tau距离:求两个排列之间的逆序数
- 如何解压assets目录下的压缩包文件
- 顺序容器--容器库.迭代器
- cocoapod error diff
- 日期时间选择插件 - laydate.js
- Java和Jsp中获取类所在路径(绝对路径、相对路径)的几种方法