欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

css3 iphone玻璃透明氣泡完美實(shí)現(xiàn)

  發(fā)布時(shí)間:2024-04-23 15:18:16   作者:mob604756f04b77   我要評(píng)論
玻璃透明氣泡而且還是類似iphone風(fēng)格的,聽起來還不錯(cuò)吧,貌似css3的出現(xiàn)讓一切看似不可能的事情變成了可能,接下來為大家介紹下css3實(shí)現(xiàn)玻璃透明氣泡的寫法,感興趣的朋友可以參考下哈

最近在一個(gè)私活做手機(jī)項(xiàng)目時(shí)候,需要實(shí)現(xiàn)一個(gè)類似ios 6中短信那樣的氣泡效果。

這里分享下實(shí)現(xiàn)心得,希望能給大家一點(diǎn)啟發(fā)。

首先分析下iphone的氣泡效果有一下特點(diǎn)

1. 四面圓角

2. 界面上向下的外陰影

3. 上邊和下邊的內(nèi)陰影

4. 上邊內(nèi)的一個(gè)內(nèi)嵌的玻璃氣泡的反光效果

因?yàn)槲淖值拈L(zhǎng)度、高度,內(nèi)容多少都未知,所以如果用圖片,會(huì)涉及到了多張拼貼,而且效果不好,所以就選擇了CSS3。

首先定義一個(gè)容器,盒模型為display: inline-block,方便自適應(yīng)文字大小

.bubble {
position: relative;
display: inline-block;
min-width: 30px;
max-width: 200px;
word-break: break-all;
word-wrap: break-word;
min-height: 22px;
background: #d2d2d2;
border-radius: 15px;
margin-bottom: 20px;
padding: 6px 8px;
-webkit-box-shadow: 0px 1px 2px #000, inset 0px 4px 4px rgba(0,0,0,.3), inset 0px -4px 4px rgba(255,255,255,.5);
-moz-shadow: 0px 1px 2px #000, inset 0px 4px 4px rgba(0,0,0,.3), inset 0px -4px 4px rgba(255,255,255,.5);
box-shadow: 0px 1px 2px #000, inset 0px 4px 4px rgba(0,0,0,.3), inset 0px -4px 4px rgba(255,255,255,.5);
}

設(shè)置斷詞,避免文字過長(zhǎng),撐開容器,同時(shí)設(shè)置最小寬度,最大寬度

設(shè)置圓角,使用border-radius

設(shè)置box-shadow: 0px 1px 2px #000實(shí)現(xiàn)氣泡的外陰影

inset 0px 4px 4px rgba(0,0,0,.3)為上邊框內(nèi)陰影

inset 0px -4px 4px rgba(255,255,255,.5)為下邊框的內(nèi)陰影

接下來,我們需要實(shí)現(xiàn)最后一個(gè)效果內(nèi)嵌玻璃氣泡的反光效果

.bubble .content {
position: relative;
padding: 0 4px;
}
.bubble .content:before {
content: '';
position: absolute;
margin: auto;
top: -5px;
left: 0;
width: 100%;
height: 12px;
background-image: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(255,255,255,0.2) 90%, rgba(255,255,255,0) 90% );
background-image: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(255,255,255,0.2) 90%, rgba(255,255,255,0) 90% );
border-radius: 10px
}

在氣泡內(nèi)嵌一個(gè)顯示內(nèi)容的block,使用block的before偽元素,實(shí)現(xiàn)一個(gè)圓角的漸變氣泡

background-image: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(255,255,255,0.2) 90%, rgba(255,255,255,0) 90% );

最后,通過氣泡的before和after偽元素,實(shí)現(xiàn)三角

.bubble:before {
content: '';
display: block;
font-size: 0;
width: 0;
height: 0;
border-width: 6px;
position: absolute;
bottom: -12px;
left: 12px; 
border-color: #4a4c50 transparent transparent #4a4c50;
border-style: solid dashed dashed solid;
}
.bubble:after {
content: '';
display: block;
font-size: 0;
position: absolute;
bottom: -9px;
left: 13px;
width: 0;
height: 0;
border-width: 5px;
border-color: #e8e8e8 transparent transparent #e8e8e8;
border-style: solid dashed dashed solid;
}

相關(guān)文章

最新評(píng)論