最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

css 11種方法實(shí)現(xiàn)一個(gè)tips帶有描邊的小箭頭

  發(fā)布時(shí)間:2019-02-21 16:49:58   作者:w3cbest   我要評(píng)論
這篇文章主要介紹了css 11種方法實(shí)現(xiàn)一個(gè)tips帶有描邊的小箭頭,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

我們?cè)诰W(wǎng)頁開發(fā)中實(shí)現(xiàn)一個(gè)tips時(shí)會(huì)有一個(gè)小箭頭,實(shí)現(xiàn)這種方法的文章網(wǎng)上已經(jīng)泛濫了,但有時(shí)實(shí)現(xiàn)這個(gè)小箭頭不止只有單純的三角它還有描邊,今天我們就借那些現(xiàn)有的文章在深入一點(diǎn)來說說如何給tips小箭頭描邊,本章不涉及svg/canvas,沒必要因?yàn)槲抑v的是css。

主體樣式:

<div class="dui-tips"><a href="http://www.w3cbest.com">w3cbest我是一個(gè)tips</a></div>
 .dui-tips{
        position: relative;
        padding: 10px;
        text-align: center;
        border: 1px solid #f60;
        border-radius: 5px;
        background-color: #fff;
    }

第一種border描邊雙層覆蓋:

就是大家常用的border,實(shí)現(xiàn)原理就是給其中一條邊設(shè)置顏色寬度及樣式,我這里使用了兩個(gè)偽類進(jìn)行折疊,將一個(gè)白色的覆蓋在有顏色的偽類上面,再偏移1px來模擬實(shí)現(xiàn)1px的描邊效果,代碼如下:

.dui-tips {
    &:before, &:after {
        position: absolute;
        left: 50%;
        display: table;
        width: 0;
        height: 0;
        content: '';
        transform: translate(-50%, 0);
        border-width: 10px 10px 0 10px;
        border-style: solid;
    }
    &:before {
        z-index: 0;
        bottom: -10px;
        border-color: #f60 transparent transparent transparent;
    }
    &:after {
        z-index: 1;
        bottom: -8px;
        border-color: #fff transparent transparent transparent;
    }
}

第二種border描邊結(jié)合濾鏡drop-shadow屬性:

第二種是第一種的延伸,使用濾鏡filter的drop-shadow描邊來實(shí)現(xiàn),box-shadow和drop-shadow實(shí)現(xiàn)不規(guī)則投影

.dui-tips {
    &:after {
        position: absolute;
        left: 50%;
        display: table;
        width: 0;
        height: 0;
        content: '';
        transform: translate(-50%, 0);
        border-width: 10px 10px 0 10px;
        border-style: solid;

        bottom: -9px;
        border-color: #fff transparent transparent transparent;
        filter: drop-shadow(0px 2px 0px #f60);
    }
}

第三種通過特殊符號(hào)或字體雙層覆蓋

第三種方法和第一種類似,通過兩層顏色疊加在有層級(jí)的偏移來實(shí)現(xiàn)

.dui-tips {
    &:before, &:after {
        font-size: 24px;
        line-height: 18px;
        position: absolute;
        left: 50%;
        display: table;
        content: '◆';
        transform: translate(-50%, 0);
        text-align: center;
    }
    &:before {
        z-index: 0;
        bottom: -10px;
        color: #f60;
    }
    &:after {
        z-index: 1;
        bottom: -8px;
        color: #fff;
    }
}

第四種通過text-shadow實(shí)現(xiàn)

這種放發(fā)通過給文子設(shè)置1px的陰影來顯描邊效果

.dui-tips {
    &:after {
        font-size: 24px;
        line-height: 18px;
        position: absolute;
        left: 50%;
        display: table;
        content: '◆';
        transform: translate(-50%, 0);
        text-align: center;

        z-index: 1;
        bottom: -8px;
        color: #fff;
        text-shadow: 0 2px 0 #f60;
    }
}

第五種 background雙層覆蓋

這種方式設(shè)置兩個(gè)寬度和高度分別為10px的方塊背景,再給兩層背景分別設(shè)置不同的顏色,再通過兩層背景顏色疊加,經(jīng)過層級(jí)偏移再有transform的rotate屬性旋轉(zhuǎn)角度,來實(shí)現(xiàn)箭頭的朝向。

.dui-tips {
    &:before, &:after {
        position: absolute;
        left: 50%;
        display: table;
        width: 10px;
        height: 10px;
        content: '';
        margin-left: -5px;
        transform: rotate(-45deg);
    }
    &:before {
        z-index: 0;
        bottom: -6px;
        background-color: #f60;
    }
    &:after {
        z-index: 1;
        bottom: -5px;
        background-color: #fff;
    }
}

第六種background和border背景描邊旋轉(zhuǎn)

此方法就是設(shè)置一個(gè)寬度和高度分別為10px的方塊背景,然后背景相鄰的兩條邊描邊再有transform的rotate屬性旋轉(zhuǎn)角度,來實(shí)現(xiàn)箭頭的朝向。

.dui-tips {
    &:after {
        position: absolute;
        left: 50%;
        display: table;
        width: 10px;
        height: 10px;
        margin-left: -5px;
        content: '';
        transform: rotate(-45deg);

        z-index: 1;
        bottom: -6px;
        border-bottom: 1px solid #f60;
        border-left: 1px solid #f60;
        background-color: #fff;
    }
}

第七種background和box-shadow

.dui-tips {
    &:after {
        position: absolute;
        left: 50%;
        display: table;
        width: 10px;
        height: 10px;
        content: '';
        margin-left: -5px;
        transform: rotate(-45deg);

        z-index: 1;
        bottom: -5px;
        background-color: #fff;
        box-shadow: -1px 1px 0 #f60;
    }
}

第八種linear-gradient

.dui-tips{
    &:before, &:after{
        position: absolute;
        left: 50%;
        display: table;
        width: 10px;
        height: 10px;
        content: '';
        margin-left: -5px;
        transform: rotate(-135deg);
    }
    &:before {
        z-index: 0;
        bottom: -6px;
        background: linear-gradient(-45deg, transparent 7px, #f60 0);
    }
    &:after {
        z-index: 1;
        bottom: -5px;
        background: linear-gradient(-45deg, transparent 7px, #fff 0);
    }
}

第九種linear-gradient和box-shadow

.dui-tips{
    &:after{
        position: absolute;
        left: 50%;
        display: table;
        width: 10px;
        height: 10px;
        content: '';
        margin-left: -5px;
        transform: rotate(-135deg);

        z-index: 1;
        bottom: -5px;
        background: linear-gradient(-45deg, transparent 7px, #fff 0);
        box-shadow: -1px -1px 0 #f60
    }
}

第十種linear-gradient和border

.dui-tips{
    &:after{
        position: absolute;
        left: 50%;
        display: table;
        width: 10px;
        height: 10px;
        content: '';
        margin-left: -5px;
        transform: rotate(-135deg);

        z-index: 1;
        bottom: -6px;
        background: linear-gradient(-45deg, transparent 7px, #fff 0);
        border-top: 1px solid #f60;
        border-left: 1px solid #f60;
    }
}

第十一種ouline

.dui-tips {
    &:before, &:after {
        position: absolute;
        left: 50%;
        display: table;
        width: 0;
        height: 0;
        content: '';
        transform: rotate(45deg);
        outline-style: solid;
        outline-width: 5px;
    }
    &:before {
        z-index: 0;
        bottom: -1px;
        outline-color: #f60;
    }
    &:after {
        z-index: 1;
        bottom: 0;
        outline-color: #fff;
    }
}

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • CSS實(shí)現(xiàn)鼠標(biāo)懸停svg圖標(biāo)描邊效果

    這篇文章主要介紹了CSS實(shí)現(xiàn)鼠標(biāo)懸停svg圖標(biāo)描邊效果,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-03-30

最新評(píng)論

乳源| 乐东| 东丽区| 墨竹工卡县| 吴江市| 汝阳县| 株洲县| 郓城县| 明溪县| 北宁市| 郧西县| 宿迁市| 呼图壁县| 陇西县| 马尔康县| 眉山市| 清丰县| 临江市| 勐海县| 金华市| 延安市| 巢湖市| 托里县| 当涂县| 天峻县| 南昌市| 英山县| 八宿县| 芜湖县| 五指山市| 宿迁市| 许昌县| 雷山县| 富锦市| 巴塘县| 土默特右旗| 宽城| 济宁市| 永平县| 辛集市| 山阴县|