您现在的位置:首页 >> 前端 >> 内容

用伪类写一个带箭头的步骤条样式的教程

时间:2017/10/28 10:43:30 点击:

  核心提示:今天需求要写一个带指向性箭头的步骤条,网上查找了一些示例,觉得用伪类这种方式还是挺好的,优点显而易见,不需引用控件,不需复杂的代码,不需设计特定的背景图片,步骤条颜色可以在自己的样式代码里面自由控制,...

今天需求要写一个带指向性箭头的步骤条,网上查找了一些示例,觉得用伪类这种方式还是挺好的,

优点显而易见,不需引用控件,不需复杂的代码,不需设计特定的背景图片,步骤条颜色可以在自己的样式代码里面自由控制,个人觉得还是很优秀的。

附一个样例代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.cssNav li{  
    padding: 0px 20px 0 40px;   
    line-height: 40px;  
    background: #50abe4;  
    display: inline-block;   
    color: #fff;  
    position: relative;  
}  
.cssNav li:after{  
    content: '';  
    display: block;  
    border-top: 20px solid transparent;  
    border-bottom: 20px solid transparent;  
    border-left: 20px solid #50abe4;  
    position: absolute;   
    right: -20px;   
    top: 0;  
    z-index: 10;  
}  
.cssNav li:before{  
    content: '';  
    display: block;  
    border-top: 20px solid transparent;  
    border-bottom: 20px solid transparent;  
    border-left: 20px solid #fff;  
    position: absolute;   
    left: 0px;   
    top: 0;  
} 
.cssNav li:first-child{    
    border-radius: 4px 0 0 4px;    
    padding-left: 25px;  
}    
.cssNav li:last-child,.cssNavEnd{    
    border-radius: 0px 4px 4px 0px;    
    padding-right: 25px;  
}    
.cssNav li:first-child:before{    
    display: none;    
}    
.cssNav li:last-child:after,.cssNavEnd:after{    
    display: none;    
} 
.cssNav li.gone {  
    background-color: #DDDDDD; 
    color:#000000;
}  
.cssNav li.gone:after {  
    border-left-color: #DDDDDD;  
} 
.cssNav li.active {  
    background-color: #ef72b6;  
    
}  
.cssNav li.active:after {  
    border-left-color: #ef72b6;  
} 
</style>
</head>
<body>
<ul class="cssNav">
<li class="gone">首页</li>
<li class="active">第一页</li>
<li>第二页</li>
<li>第三页</li>
</ul>
</body>
</html>

作者:网络 来源:kkhk04的博客