站長資訊網
        最全最豐富的資訊網站

        h5實現QQ聊天氣泡的實例介紹

        這篇文章主要介紹了HTML5實現QQ聊天氣泡效果,用 HTML/CSS 做了個類似QQ的聊天氣泡,具有一定的參考價值,感興趣的小伙伴們可以參考一下

        今天自己用 HTML/CSS 做了個類似QQ的聊天氣泡,以下是效果圖:

        h5實現QQ聊天氣泡的實例介紹

        以下說下關鍵地方的樣式設置。然后貼出html和css代碼(不多)。

        步驟1:布局

        消息採用p+float布局,每條消息用一個p標簽包裹,里面再放兩個p分別用來包裹用戶圖標和用戶消息內容。左側消息,先清除浮動,然后設置 float:left。這樣用戶圖標和消息內容就能夠顯示在同一行了,當中用戶圖標在左邊,消息內容緊鄰著用戶圖標。

        右側消息,相同先清除浮動。然后設置 float:right,這樣用戶圖標和消息顯示在同一行了。當中圖標在最右邊。圖標左側是消息。

        h5實現QQ聊天氣泡的實例介紹

        步驟2:設置圓角矩形

        border-radius:7px;

        h5實現QQ聊天氣泡的實例介紹

        步驟3:三角形箭頭
        &n

        將p的寬度和高度設置為0,設置邊框寬度,能夠使其表現出一個由四個三角形組成的矩形,每一個三角形的顏色和大小能夠通過設置border寬度和顏色設置。

        這里將當中三個三角形顏色設置為透明。僅僅留下一個三角形可見。

        h5實現QQ聊天氣泡的實例介紹

            .triangle{          width: 0px;          height: 0px;          border-width: 15px;          border-style: solid;          border-color: red blue green gold;      }

        h5實現QQ聊天氣泡的實例介紹

          .triangle{          width: 0px;          height: 0px;          border-width: 15px;          border-style: solid;          border-color: transparent transparent transparent red;      }

        關鍵點4:三角形尾隨矩形框

        使用相對定位。能夠使三角形始終固定在矩形框的邊上。

        position:relative;

        h5實現QQ聊天氣泡的實例介紹

        所有代碼:

        <html>  <head>  <style>    /* bubble style */          .sender{              clear:both;          }          .sender p:nth-of-type(1){              float: left;          }          .sender p:nth-of-type(2){              background-color: aquamarine;              float: left;              margin: 0 20px 10px 15px;              padding: 10px 10px 10px 0px;              border-radius:7px;          }            .receiver p:first-child img,          .sender p:first-child img{              width:50px;              height: 50px;          }            .receiver{              clear:both;          }          .receiver p:nth-child(1){              float: right;          }          .receiver p:nth-of-type(2){              float:right;              background-color: gold;              margin: 0 10px 10px 20px;              padding: 10px 0px 10px 10px;              border-radius:7px;          }            .left_triangle{              height:0px;                width:0px;                border-width:8px;                border-style:solid;                border-color:transparent aquamarine transparent transparent;                position: relative;              left:-16px;              top:3px;          }            .right_triangle{              height:0px;                width:0px;                border-width:8px;                border-style:solid;                border-color:transparent transparent transparent gold;                position: relative;              right:-16px;              top:3px;          }      </style>  </head>  <body>  <!-- Left -->  <p class="sender">        <p>            <img src="chatTemplateExample2_files/cat.jpg">        </p>    <p>        <p class="left_triangle"></p>        <span> hello, man! </span>     </p>    </p>  <!-- Right -->    <p class="receiver">        <p>            <img src="chatTemplateExample2_files/cat.jpg">        </p>     <p>          <p class="right_triangle"></p>          <span> hello world </span>     </p>    </p>    </body>  </html>

        贊(0)
        分享到: 更多 (0)
        網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號
        主站蜘蛛池模板: 久久线看观看精品香蕉国产| 久久精品国产99国产精品| www亚洲欲色成人久久精品| 亚洲精品国产首次亮相| 国产精品无码一区二区在线 | 国产精品无码无卡无需播放器| 国产精品福利一区二区久久| 在线亚洲精品自拍| 狠狠色伊人久久精品综合网| 四虎永久在线精品884aa下载| 精品无码人妻一区二区免费蜜桃| 亚洲精品国产综合久久一线| 99久久99久久精品国产片果冻| 国产精品视频分类一区| 2021久久国自产拍精品| 国内少妇偷人精品视频免费| 无码aⅴ精品一区二区三区浪潮| 亚洲精品高清在线| 亚洲国产主播精品极品网红| 午夜精品久久影院蜜桃| 欧美精品色婷婷五月综合| 欧美精品福利在线视频 | 国产精品视频第一页| 国产成人精品日本亚洲专一区| 国产成人精品无码免费看| 国产精品无码无在线观看| 久久婷婷国产综合精品| 日本内射精品一区二区视频| 人妻熟妇乱又伦精品视频| 中文精品久久久久人妻| 中文精品99久久国产| 麻豆aⅴ精品无码一区二区| 热re99久久6国产精品免费| 亚洲av永久无码精品网站| 亚洲AV无码成人精品区天堂| 精品无码一区在线观看| 国产剧情国产精品一区| 成人精品综合免费视频| 久久精品一区二区国产| 91精品国产91热久久久久福利| 国产精品1024视频|