我被困在一個聊天窗口中,我們在元素之前,之後使用CSS創建了一個聊天窗口。我的代碼添加到下面。 我的問題是:與css聊天窗口
- 爲什麼我們設置
content
如果是空白的? - 爲什麼
position
更改爲absolute
:after
和:before
? - 主要問題是:我們如何繪製左側的箭頭?
.bubble {
position: relative;
width: 580px;
min-height: 65px;
padding: 15px;
background: #fff;
border-radius: 10px;
border: 1px solid #ccc;
margin-left: 50px;
margin-top: 59px;
}
.bubble:after {
content: '';
position: absolute;
border-style: solid;
border-width: 15px 15px 15px 0;
display: block;
width: 0;
z-index: 1;
margin-top: -15px;
left: -15px;
top: 50%;
border-color: transparent #fff;
}
.bubble:before {
content: '';
position: absolute;
border-style: solid;
border-width: 15px 15px 15px 0;
display: block;
width: 0;
z-index: 0;
margin-top: -15px;
left: -16px;
top: 50%;
border-color: transparent red;
}
<html>
<body>
<div class="bubble">
<div class="Pointer">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</p>
</div>
</div>
</body>
</html>
僞元素的設置是爲了**樣式的其它內容**。這個*內容*就是你放在'content'屬性中的內容。如果你沒有爲'content'屬性指定一個值,那麼它的默認值就是'none'。如果內容爲「無」,則沒有任何風格,並且無論您應用什麼樣式都不會有任何要應用的內容。 –
使用邊框屬性製作的兩個三角形創建箭頭。一個紅色的三角形使用:之前和一個白色的使用:之後。白色的一個用z-index放在最上面,紅色的三角形放在左邊一個像素。現在它看起來像一條線,但它只是顯示了紅色三角形的一小部分。 – Gerard