0
我用下面的HTML/CSS代码,以使聊天泡泡:CSS问题与背景色::后
body {background-color: red}
.message-sent {
position:relative;
padding:10px 20px;
color:white;
background:#0B93F6;
border-radius:25px;
float: right;
margin-bottom: 5px;
margin-right: 30px;
}
.message-sent-last::before {
content:"";
position:absolute;
z-index:-1;
bottom:-2px;
right:-7px;
height:20px;
border-right:20px solid #0B93F6;
border-bottom-left-radius: 16px 14px;
-webkit-transform:translate(0, -2px);
}
.message-sent-last::after {
content:"";
position:absolute;
z-index:1;
bottom:-2px;
right:-56px;
width:26px;
height:20px;
border-bottom-left-radius: 10px;
-webkit-transform:translate(-30px, -2px);
background: red;
}
<div class="message-sent message-sent-last">
Hey there! What's up?
</div>
但问题是在CSS的最后一行我不得不重复背景颜色,否则泡泡就会破裂。请检查了这一点:
body {background-color: red}
.message-sent {
position:relative;
padding:10px 20px;
color:white;
background:#0B93F6;
border-radius:25px;
float: right;
margin-bottom: 5px;
margin-right: 30px;
}
.message-sent-last::before {
content:"";
position:absolute;
z-index:-1;
bottom:-2px;
right:-7px;
height:20px;
border-right:20px solid #0B93F6;
border-bottom-left-radius: 16px 14px;
-webkit-transform:translate(0, -2px);
}
.message-sent-last::after {
content:"";
position:absolute;
z-index:1;
bottom:-2px;
right:-56px;
width:26px;
height:20px;
border-bottom-left-radius: 10px;
-webkit-transform:translate(-30px, -2px);
background: transparent;
}
<div class="message-sent message-sent-last">
Hey there! What's up?
</div>
我想不重复网页的背景颜色,因为片段将在几个地方有不同的背景颜色一起使用。我已经尝试了透明和继承,但没有解决。
这是第二个文档片断的样子:
我在Ubuntu下Chrome和FF测试。
您认为如何?
没有花时间阅读你的问题,但在我的FF,两个片段看起来完全一样 – Kaiido
@Kaiido我在FF和Chrome测试在Ubuntu下。在原始问题中添加了一张图片,显示了第二次剪辑的样子。 – Luciano
这是怎么看起来都像我的FF48在Mac上:http://i.stack.imgur.com/cuyIY.png – Kaiido