现在越来越时尚化,tab标签页已经不像原来的那么传统格式化了,现在给大家实现一个简约美观的tab标签页
比较简约的梯形tab

.nav{
display: flex;
width: 300px;
align-items: flex-end;
}
.nav .item{
flex: 1;
height: 40px;
background: #eee;
border-radius: 5px 5px 0 0;
position: relative;
list-style: none;
}
.nav .item.active{
height: 45px;
background: orange;
}
.nav .item:first-child:before{
content: '';
display: none;
width: 10px;
height: 100%;
background: orange;
position: absolute;
right: -5px;
top: 0;
z-index: 10;
border-radius: 0 5px 0 0;
transform: skew(10deg);
}
.nav .item:first-child.active:before{
display: block;
}
.nav .item:last-child:before{
content: '';
display: none;
width: 10px;
height: 100%;
background: orange;
position: absolute;
left: -5px;
top: 0;
z-index: 10;
border-radius: 5px 0 0 0;
transform: skew(-10deg);
}
.nav .item:last-child.active:before{
display: block;
}
document.querySelector('.nav').addEventListener('click',function(e){
if(e.target.nodeName=='LI'){
var item = document.querySelectorAll('.item');
for(var i = 0; i < item.length; i++){
item[i].className = 'item';
}
e.target.className = 'item active';
}
})
以上就可以实现漂亮tab标签页,不像传统的梯形tab那样,有更好的意见或者建议欢迎留言~
本文章为原创文章,转发请注明出处,谢谢!
标签:tab,梯形,item,nav,5px,display,css,before
来源: https://blog.csdn.net/p_pppxxxxmmm/article/details/106764545
本文介绍了一种实现简约美观梯形Tab标签页的方法,通过CSS样式实现梯形效果,使得标签页不再传统而更具时尚感。示例代码展示了如何利用Flex布局和变形技巧来创建这种效果。当点击Tab时,会切换选中状态,改变高度和背景颜色,同时利用伪元素添加斜边,营造出梯形视觉。这是一个原创的前端设计教程,欢迎大家留言交流。

545

被折叠的 条评论
为什么被折叠?



