我正在为坐在内容div上的有角度的选项卡设计高级样式。如何在使用伪元素时隐藏溢出文本(:before&:after)?
我刚刚解决它,下面的建议遵循:之前和之后:塑造div。但是,我坚持试图让DIV本身使用的最大宽度,而不是宽度:
HTML
<br>
<div class="tab">Really really really really really really long content title</div>
<div class="tab-content">Content text</div>
CSS
。
tab-content, .tab, .tab:before, .tab:after {
background-color: #f5f5f5;
}
body {
background-color: #666;
}
.tab-content {
border-left: 1px solid blue;
border-right: 1px solid blue;
border-bottom: 1px solid blue;
border-top: 1px solid blue;
margin-top: -1px;
padding-top:10px;
padding-bottom:20px;
padding-left:10px;
padding-right:10px;
}
.tab:before {
}
.tab {
max-width: 150px;
display:block;
border-left: 1px solid blue;
border-top: 1px solid blue;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
height: 50px;
border-radius: 15px 100px 0px 0px;
position: relative;
z-index: 100000000;
line-height:50px;
padding-left:20px;
}
.tab:after {
border-right: 1px solid blue;
border-top: 1px solid blue;
border-top-left-radius: 0px;
border-top-right-radius: 10px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 00px;
display: block;
content:" ";
width: 150px;
height: 50px;
top: -1px;
position: absolute;
right: -28px;
transform:skewX(45deg);
-ms-transform:skewX(45deg);
-webkit-transform:skewX(45deg);
z-index: -1;
}
任何想法?
的jsfiddle这里:http://jsfiddle.net/robmc/ZvEyx/9/
感谢,可惜后来我失去了我的标签创建的造型:后。你知道其他方式可以调整它的大小吗?我是否有位置:标签错误?虽然我从这里看不到一个简单的方法。 – alias51
啊我看到了,甚至没有检查,我会更新答案。 –
虽然这很聪明,但我唯一犹豫的是,搜索引擎可能会将'font-size:0px'放平以尝试在内容中注入垃圾邮件。但是,如果此选项卡是密码保护区域的一部分,则无关紧要。 –