搜尋
首頁web前端css教學css3的聊天氣泡樣式

這次帶給大家css3的聊天氣泡樣式,做出css3的聊天氣泡樣式的注意事項有哪些,下面就是實戰案例,一起來看一下。

在聊天的場景中,聊天內容需要用到氣泡修飾,如下圖。下面一一講解。

圖片式:

第一個樣式是京東客服,氣泡的圓角和鉤子都是用圖片了。使用了一個table組合成了一個圓角的框框。 lm樣式拼出了鉤子。

 <p>
                </p><p></p>
                
                                                                                                    

很抱歉,现在人工客服忙,让小JIMI为您解答吧。

                         

                

                    

                                 
你好,我是stoneniqiu
            

樣式:

 .jimi_lists {
    margin: 0 -10px 20px 10px;
    position: relative;
}
 .jimi_lists .header_img.jimi3 {
    background: url(../img/jimi_50_3.png) no-repeat 0 0;
}
 .jimi_lists .header_img {
    width: 50px;
    height: 50px;
    position: absolute;
    top: 0;
    left: 0;
}.fl {
    float: left;
}
 .jimi_lists .msg {
    margin-left: 59px;
    margin-right: 40px;
    margin-top: 2px;
    float: left;
    display: inline;
}
 .jimi_lists .lt {
    background: url(../img/msg_bg_lr.png) no-repeat 0 0;
    width: 26px;
    height: 10px;
}
 .jimi_lists .tt {
    background: url(../img/msg_bg_tb.png) repeat-x 0 -23px;
    height: 10px;
}.jimi_lists .rt {
    background: url(../img/msg_bg_lr.png) no-repeat -35px 0;
    width: 10px;
    height: 10px;
}.jimi_lists .lm {
    background: url(../img/msg_bg_lr.png) repeat-y -94px 0;
    width: 26px;
    vertical-align: top;
    position: relative;
}.jimi_lists .mm {
    padding: 0 5px;
    background-color: #FFF;
    word-break: break-all;
    word-wrap: break-word;
    color: #333;
    line-height: 20px;
}.jimi_lists .lm span {
    background: url(../img/msg_bg_lr.png) no-repeat 0 -14px;
    display: inline-block;
    width: 26px;
    height: 16px;
    position: absolute;
    top: 5px;
}.jimi_lists .rm {
    background: url(../img/msg_bg_lr.png) repeat-y -113px 0;
    width: 10px;
}.jimi_lists .lb {
    background: url(../img/msg_bg_lr.png) no-repeat 0 -43px;
    width: 10px;
    height: 10px;
}.jimi_lists .bm {
    background: url(../img/msg_bg_tb.png) repeat-x 0 -25px;
    height: 10px;
}.jimi_lists .rb {
    background: url(../img/msg_bg_lr.png) no-repeat -35px -43px;
    width: 10px;
    height: 10px;
}.customer_lists {
    position: relative;
    margin: 0 12px 20px 20px;
}.customer_lists .msg {
    float: right;
    margin-right: 73px;
    _margin-right: 38px;
    margin-top: 2px;
}.customer_lists .lt {
    background: url(../img/msg_bg_lr.png) no-repeat -47px -0;
    width: 10px;
    height: 10px;
}.customer_lists .tt {
    background: url(../img/msg_bg_tb.png) repeat-x 0 0;
    height: 10px;
}.customer_lists .rt {
    background: url(../img/msg_bg_lr.png) no-repeat -63px 0;
    width: 26px;
    height: 10px;
}.customer_lists .lm {
    background: url(../img/msg_bg_lr.png) repeat-y -126px 0;
    width: 10px;
}.customer_lists .mm {
    padding: 1px 8px;
    background-color: #3897E7;
    word-break: break-all;
    word-wrap: break-word;
    color: #FFF;
}.customer_lists .rm {
    background: url(../img/msg_bg_lr.png) repeat-y -129px 0;
    width: 26px;
    vertical-align: top;
    position: relative;
}.customer_lists .lb {
    background: url(../img/msg_bg_lr.png) no-repeat -47px -36px;
    width: 10px;
    height: 10px;
}.customer_lists .bm {
    background: url(../img/msg_bg_tb.png) repeat-x -106px -4px;
    height: 10px;
}.customer_lists .rb {
    background: url(../img/msg_bg_lr.png) no-repeat -63px -36px;
    width: 26px;
    height: 10px;
}.customer_lists .rm span {
    background: url(../img/msg_bg_lr.png) no-repeat -63px -14px;
    display: inline-block;
    width: 26px;
    height: 16px;
    position: absolute;
    top: 5px;
}.customer_lists .header_img_hover {
    position: absolute;
    background: url(../img/avatar_mask_01.png);
    top: 0;
    width: 50px;
    height: 50px;
}.customer_lists .header_img {
    position: absolute;
    top: 0;
    right: 14px;
    width: 50px;
    height: 50px;
}
 .clearfix:after {
    content: " .";
    display: block;
    clear: both;
    visibility: hidden;
    height: 0;
}

View Code

背景式:

第二種主要是使用了:before偽類別畫出了三角形,然後用定位拼在了一起。

  <p>
                </p><p></p>
                

                     

换个气泡如何

                                          

                

                    

                                 

                    

这个不错

                             

樣式:

  .bkbubble.right p:before, .bkbubble.left p:before {
      width: 0;
    position: absolute;
    top: 12px;
    border-style: solid;
    content: "";
  }
  .bkbubble.left {
      text-align: right;
  }
 .bkbubble.right p:before {
     left: -12px;
    border-color: transparent #00bfff;
    border-width: 0 12px 12px 0; }
 .bkbubble.left p:before {
     right: -12px;
    border-color: transparent #00bfff;
    border-width: 0 0 12px 12px ; }

更多三角形:http://www.cnblogs.com/lhb25/p/css-and-css3-triangle.html

#邊框式:

如果要求邊框顏色和背景顏色不一樣呢?上面的方法就不行了,因為用:before畫三角形是利用border的原理,也就是說,在上面這種方式下,氣泡邊上的小三形是無法呈現兩種顏色的,因為他只有一個border的顏色。那就要想辦法湊出一個有邊框的三角形了。

  <p>
                </p><p></p>
                

您好,请问有什么可以帮到您?

                

            

1.先畫一個小矩形。

.lim_operator .lim_tale {
    left: -1px;
    background-color: #c8f064;
    border-color: #a5d01b;
    margin-left: 70px;
}.lim_tale {
    position: absolute;
    width: 12px;
    height: 8px;
    overflow: hidden !important;
    top: 10px;
    z-index: 2;
    border-top-style: solid;
    border-top-width: 1px;
}

2.畫出斜線。

css裡面是沒有斜線的,這裡是用了一個園的弧形拼出來的。在一個大圓上,截取一段弧,就是一條斜線了。

.lim_operator .radiusborder {
    position: absolute;
    background-color: #EFF0F2;
    top: -29px;
    left: -94px;
    height: 160px;
    width: 160px;
    border-top-style: solid;
    border-top-width: 1px;
    border-right-style: solid;
    border-right-width: 1px;
    border-top-right-radius: 154px;
    border-color: #a5d01b;
}

疊加式:

原理就是相當於用before先畫出一個有色背景,再用after畫出一個白色背景,然後疊加錯開頂部1-2px,這樣就出現了一個有邊框有背景的三角形。 web 微信就是這種做法

.expression:before {
    content: '';
    position: absolute;
    left: 16px;
    top: 100%;
    margin-left: -7px;
    border: 7px solid transparent;
    border-top-color: #CFCFCF}.expression:after {
    content: '';
    position: absolute;
    left: 16px;
    top: 100%;
    margin-left: -7px;
    margin-top: -1px;
    border: 7px solid transparent;
    border-top-color: #FFF}

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

JavaScript的var與this,{}與function

ss3的漸變如何使用

以上是css3的聊天氣泡樣式的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
這麼多顏色鏈接這麼多顏色鏈接Apr 13, 2025 am 11:36 AM

最近有一系列有關顏色的工具,文章和資源。請允許我通過將它們四捨五之後關閉幾個標籤,以供您享受。

自動利潤在Flexbox中的工作方式自動利潤在Flexbox中的工作方式Apr 13, 2025 am 11:35 AM

羅賓以前已經介紹過這一點,但是我在過去的幾周里聽到了一些關於它的困惑,看到另一個人在解釋它,我想

移動彩虹移動彩虹Apr 13, 2025 am 11:27 AM

我絕對喜歡三明治網站的設計。在許多美麗的功能中,這些標題是滾動時帶有彩虹的下線。它不是

新年,新工作?讓我們做一個網格驅動的簡歷!新年,新工作?讓我們做一個網格驅動的簡歷!Apr 13, 2025 am 11:26 AM

許多流行的簡歷設計通過以網格形狀鋪設部分來充分利用可用的頁面空間。讓我們使用CSS網格創建一個佈局

將用戶擺脫過多習慣的一種方法將用戶擺脫過多習慣的一種方法Apr 13, 2025 am 11:25 AM

頁面重新加載是一回事。有時,當我們認為它沒有響應或認為新內容可用時,我們會刷新頁面。有時我們只是生氣

域驅動的設計與React域驅動的設計與ReactApr 13, 2025 am 11:22 AM

關於如何在React世界中組織前端應用的指導很少。 (只需移動文件,直到“感覺正確”,大聲笑)。真相

檢測非活動用戶檢測非活動用戶Apr 13, 2025 am 11:08 AM

大多數情況下,您並不真正在乎用戶是否積極參與或暫時非活動。不活躍,意思,也許他們

Wufoo ZapierWufoo ZapierApr 13, 2025 am 11:02 AM

Wufoo一直在集成方面非常出色。他們與特定應用程序(例如廣告系列顯示器,MailChimp和Typekit)進行集成,但他們也

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),