用純css3和html制作泡沫對(duì)話框?qū)崿F(xiàn)代碼
發(fā)布時(shí)間:2013-03-21 15:29:27 作者:佚名
我要評(píng)論

泡沫對(duì)話框是一種比較流行的趨勢(shì)因?yàn)樗淖兞藗鹘y(tǒng),通常情況下都是使用html和javascript或者是圖片來(lái)實(shí)現(xiàn),接下來(lái)為大家介紹下使用css3配合html來(lái)實(shí)現(xiàn)一些簡(jiǎn)單的泡沫對(duì)話框
現(xiàn)在,泡沫對(duì)話框是一種比較流行的趨勢(shì),一般都是用html和javascript,和或者圖片來(lái)實(shí)現(xiàn),今天用純css3和html來(lái)實(shí)現(xiàn)一些基本的簡(jiǎn)單的泡沫對(duì)話框
html代碼如下:
復(fù)制代碼
代碼如下:<div class="content">
<h2>The basic bubble variants</h2>
<p class="triangle-isosceles">This only needs one HTML element.</p>
<p class="triangle-isosceles top">For example, <code><p>[text]</p></code>.</p>
<p class="triangle-isosceles left">But it could be any element you want.</p>
<p class="triangle-isosceles right">The entire appearance is created only with CSS.</p>
<p class="triangle-right">This only needs one HTML element.</p>
<p class="triangle-right top">For example, <code><p>[text]</p></code>.</p>
<p class="triangle-right left">But it could be any element you want.</p>
<p class="triangle-right right">The entire appearance is created only with CSS.</p>
</div>
css代碼如下:
復(fù)制代碼
代碼如下:body {
padding:0;
margin:0;
font:1em/1.4 Cambria, Georgia, sans-serif;
color:#333;
background:#fff;
}
a:link, a:visited {
border-bottom:1px solid #c55500;
text-decoration:none;
color:#c55500;
}
a:visited {
border-bottom:1px solid #730800;
color:#730800;
}
a:hover, a:focus, a:active {
border:0;
color:#fff;
background:#c55500;
}
a:visited:hover, a:visited:focus, a:visited:active {
color:#fff;
background:#730800;
}
h2 {
margin:0.5em 0 1.5em;
font-size:1.25em;
font-weight:normal;
font-style:italic;
text-align:center;
}
p {
margin:1em 0;
}
.content h2 {
margin:2em 0 0.75em;
font-size:2em;
font-weight:bold;
font-style:normal;
text-align:left;
}
.content {
width:500px;
padding:0 0 50px;
margin:0 auto;
position:relative;
z-index:1;
}
.triangle-isosceles {
position:relative;
padding:15px;
margin:1em 0 3em;
color:#000;
background:#f3961c;
background:-webkit-gradient(linear, 0 0, 0 100%, from(#f9d835), to(#f3961c));
background:-moz-linear-gradient(#f9d835, #f3961c);
background:-o-linear-gradient(#f9d835, #f3961c);
background:linear-gradient(#f9d835, #f3961c);
filter:progid:DXImageTransform.Microsoft.gradient(GradinetType=0, startColorstr="#f9d835", endColorstr="#f3961c");
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
}
.triangle-isosceles.top {
background:-webkit-gradient(linear, 0 0, 0 100%, from(#f3961c), to(#f9d835));
background:-moz-linear-gradient(#f3961c, #f9d835);
background:-o-linear-gradient(#f3961c, #f9d835);
background:linear-gradient(#f3961c, #f9d835);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr="#f3961c", endColorstr="#f9d835");
}
.triangle-isosceles.left {
margin-left:50px;
background:#f3961c;
}
.triangle-isosceles.right {
margin-right:50px;
background:#f3961c;
}
.triangle-isosceles:after {
content:"";
position:absolute;
left:50px;
bottom:-15px;
border-width:15px 15px 0;
border-style:solid;
border-color:#f3961c transparent;
display:block;
width:0;
}
.triangle-isosceles.top:after {
top:-15px;
bottom:auto;
left:auto;
right:50px;
border-width:0 15px 15px;
border-color:#f3961c transparent;
}
.triangle-isosceles.left:after {
top:16px;
left:-50px;
bottom:auto;
border-width:10px 50px 10px 0;
border-color:transparent #f3961c;
}
.triangle-isosceles.right:after {
top:16px;
right:-50px;
bottom:auto;
border-width:10px 0 10px 50px;
border-color:transparent #f39a1c;
left:auto;
}
.triangle-right {
position:relative;
padding:15px;
margin:1em 0 3em;
color:#fff;
background:#075698;
background:-webkit-gradient(linear, 0 0, 0 100%, from(#2e88c4), to(#075698));
background:-moz-linear-gradient(#2e88c4, #075698);
background:-o-linear-gradient(#2e88c4, #075698);
background:-ms-linear-gradient(#2e88c4, #075698);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr="#2e88c4", endColorstr="#075698");
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
}
.triangle-right.top {
background:-webkit-gradient(linear, 0 0, 0 100%, from(#075698), to(#2e88c4));
background:-moz-linear-gradient(#075698, #2e88c4);
background:-o-linear-gradient(#075698, #2e88c4);
background:linear-gradient(#075698, #2e88c4);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr="#075698", endColorstr="#2e88c4");
}
.triangle-right.left {
margin-left:40px;
background:#075698;
}
.triangle-right.right {
margin-right:40px;
background:#075698;
}
.triangle-right:after {
content:"";
position:absolute;
bottom:-20px;
left:50px;
border-width:20px 0 0 20px;
border-style:solid;
border-color:#075698 transparent;
display:block;
width:0;
height:0;
}
.triangle-right.left:after {
top:16px;
left:-40px;
bottom:auto;
border-width:15px 40px 0 0;
border-color:transparent #075698;
}
.triangle-right.top:after {
top:-20px;
right:50px;
bottom:auto;
left:auto;
right:50px;
border-width:20px 20px 0 0;
border-color:transparent #075698;
}
.triangle-right.right:after {
top:16px;
right:-40px;
bottom:auto;
left:auto;
border-width:15px 0 0px 40px;
border-color:transparent #075698;
}
支持的瀏覽器有:Firefox 3.5+, Safari 4+, Chrome 4+, Opera 10+, IE8+.
預(yù)覽效果如下:
在firefox14.0中預(yù)覽的效果:
在chrome10.0中預(yù)覽效果
在ie9中預(yù)覽效果:
在ie8中預(yù)覽的效果:
相關(guān)文章
CSS3軟件卸載對(duì)話框代碼 根據(jù)是否卸載出現(xiàn)不同表情
這是一個(gè)對(duì)話框插件,它主要用來(lái)卸載軟件時(shí)的提示,特點(diǎn)在于,當(dāng)用戶選擇保留和卸載后,對(duì)話框中間的表情會(huì)根據(jù)用戶選擇發(fā)生動(dòng)態(tài)變化,非??蓯?。需要的朋友前來(lái)下載2019-07-29- 對(duì)話框小尾巴,估計(jì)大家在實(shí)際開發(fā)中應(yīng)該經(jīng)常遇到過(guò),省事點(diǎn)的就是叫設(shè)計(jì)小姐姐給切個(gè)帶小尾巴的背景圖,那不省事的呢?這篇文章主要介紹了CSS對(duì)話框小尾巴,需要的朋友可以2019-05-16
純CSS實(shí)現(xiàn)氣泡對(duì)話框尖角處理方案
這篇文章主要介紹了純CSS實(shí)現(xiàn)氣泡對(duì)話框尖角處理的實(shí)現(xiàn)代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的的朋友參考下吧2017-06-26純CSS代碼實(shí)現(xiàn)各類氣球泡泡對(duì)話框效果
利用CSS的border屬性可以生成一些圖形,例如三角或是圓角。純粹的CSS2的內(nèi)容,沒(méi)有兼容性的問(wèn)題,我之前在純CSS實(shí)現(xiàn)各類氣球泡泡對(duì)話框效果一文中算是比較詳細(xì)的講述了CSS2010-12-27css 實(shí)現(xiàn)小尖角聊天對(duì)話框帶尖角的說(shuō)話泡泡效果
這篇文章主要介紹了css 實(shí)現(xiàn)小尖角聊天對(duì)話框帶尖角的說(shuō)話泡泡效果,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下2020-04-10