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