溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

div+css樣式如何實(shí)現(xiàn)帶小三角的tooltips效果

發(fā)布時(shí)間:2021-06-29 09:16:19 來(lái)源:億速云 閱讀:389 作者:小新 欄目:web開(kāi)發(fā)

這篇文章將為大家詳細(xì)講解有關(guān) div+css樣式如何實(shí)現(xiàn)帶小三角的tooltips效果,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

 代碼和效果圖如下:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
            .tooltips {
                position: relative;
                width: 300px;
                height: 80px;
                line-height: 60px;
                background: #D7E7FC;
                border-radius: 4px;
            }
            .arrow {
                position: absolute;
                color: #D7E7FC;
                width: 0px;
                height: 0px;
                line-height: 0px;
                border-width: 20px 15px 0;
                border-style: solid dashed dashed dashed;
                border-left-color: transparent;
                border-right-color: transparent;
                bottom: -20px;
                right: 50%;
            }
            .tooltips {
                position: relative;
                width: 300px;
                height: 80px;
                line-height: 60px;
                background: #D7E7FC;
                border: 1px solid #A5C4EC;
                border-radius: 4px;
            }
            .arrow {
                position: absolute;
                width: 0px;
                height: 0px;
                line-height: 0px;
                border-width: 20px 15px 0;
                border-style: solid dashed dashed dashed;
                border-left-color: transparent;
                border-right-color: transparent;
            }
            .arrow-border {
                color: #A5C4EC;
                bottom: -20px;
                right: 50%;
            }
            .arrow-bg {
                color: #D7E7FC;
                bottom: -19px;
                right: 50%;
            }
        </style>
    </head>
    <body>
        <!--先定義一個(gè)相對(duì)定位的盒子div:-->
        <div class="tooltips">
            <!--給div盒子添加一個(gè)三角型圖標(biāo)-->
            <div class="arrow "></div>
            <!--給“小三角穿上松緊帶”需要使用兩個(gè)三角形疊加的方式-->
            <!--首先我們定義兩個(gè)三角形的div,一個(gè)背景色和盒子的邊框顏色相同,一個(gè)背景色和盒子的背景色一致:-->
            <div class="arrow arrow-border"></div>
            <div class="arrow arrow-bg"></div>
            <!--注意:.arrow-bg和.arrow-border的bottom位置相差為1px(可根據(jù)邊框?qū)挾日{(diào)整)兩個(gè)div的順序不可顛倒。-->
        </div>
    </body>
</html>

效果展示圖

div+css樣式如何實(shí)現(xiàn)帶小三角的tooltips效果

關(guān)于“ div+css樣式如何實(shí)現(xiàn)帶小三角的tooltips效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI