成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

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

oneasp / 1198人閱讀

摘要:查看效果第六種和背景描邊旋轉(zhuǎn)此方法就是設(shè)置一個(gè)寬度和高度分別為的方塊背景,然后背景相鄰的兩條邊描邊再有的屬性旋轉(zhuǎn)角度,來(lái)實(shí)現(xiàn)箭頭的朝向。

我們?cè)诰W(wǎng)頁(yè)開(kāi)發(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)來(lái)說(shuō)說(shuō)如何給tips小箭頭描邊,本章不涉及svg/canvas,沒(méi)必要因?yàn)槲抑v的是css。

主體樣式:




 .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來(lái)模擬實(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描邊來(lái)實(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);
    }
}

查看效果

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

第三種方法和第一種類似,通過(guò)兩層顏色疊加在有層級(jí)的偏移來(lái)實(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;
    }
}

查看效果

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

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

.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è)置不同的顏色,再通過(guò)兩層背景顏色疊加,經(jīng)過(guò)層級(jí)偏移再有transform的rotate屬性旋轉(zhuǎn)角度,來(lái)實(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)角度,來(lái)實(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;
    }
}

查看效果

作者: w3cbest前端開(kāi)發(fā)
互動(dòng): 如有疑問(wèn)可進(jìn)群討論
本文原創(chuàng),著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系@w3cbest前端開(kāi)發(fā)獲得授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明原鏈接及出處。

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/117135.html

相關(guān)文章

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

    摘要:查看效果第六種和背景描邊旋轉(zhuǎn)此方法就是設(shè)置一個(gè)寬度和高度分別為的方塊背景,然后背景相鄰的兩條邊描邊再有的屬性旋轉(zhuǎn)角度,來(lái)實(shí)現(xiàn)箭頭的朝向。 showImg(https://segmentfault.com/img/bVbmX2F?w=400&h=277); 我們?cè)诰W(wǎng)頁(yè)開(kāi)發(fā)中實(shí)現(xiàn)一個(gè)tips時(shí)會(huì)有一個(gè)小箭頭,實(shí)現(xiàn)這種方法的文章網(wǎng)上已經(jīng)泛濫了,但有時(shí)實(shí)現(xiàn)這個(gè)小箭頭不止只有單純的三角它還有描邊...

    李濤 評(píng)論0 收藏0
  • 使用SVG + CSS實(shí)現(xiàn)動(dòng)態(tài)霓虹燈文字效果

    摘要:早上無(wú)意間進(jìn)入一個(gè)網(wǎng)站,看到他們的效果略屌,如圖剛開(kāi)始以為是動(dòng)畫之類的,審查元素發(fā)現(xiàn)居然是用動(dòng)畫實(shí)現(xiàn)的,頓時(shí)激起了我的欲望,決定要一探究竟,查看代碼之后,發(fā)現(xiàn)原理居然是如此簡(jiǎn)單多個(gè)描邊動(dòng)畫使用不同的即可對(duì)于一個(gè)形狀元素或文本元素,可以使用 早上無(wú)意間進(jìn)入一個(gè)網(wǎng)站,看到他們的LOGO效果略屌,如圖:showImg(https://segmentfault.com/img/bVT9At?w...

    IntMain 評(píng)論0 收藏0
  • canvas基礎(chǔ)知識(shí)點(diǎn)(一)

    摘要:給設(shè)置寬高標(biāo)簽的寬高默認(rèn)是是一個(gè)行內(nèi)塊元素可以在標(biāo)簽上通過(guò),來(lái)設(shè)置可以在中給對(duì)象設(shè)置注意不要通過(guò)來(lái)調(diào)整的寬高導(dǎo)致內(nèi)部的畫布被拉伸,圖形變形獲取畫筆工具繪圖都是通過(guò)標(biāo)簽的畫筆來(lái)進(jìn)行的注意,不要寫成,里面?zhèn)魅氲膮?shù)目前也只有這一種情況描邊和填充 給canvas設(shè)置寬高: canvas標(biāo)簽的寬高默認(rèn)是300*150,是一個(gè)行內(nèi)塊元素 可以在canvas標(biāo)簽上通過(guò)width,height...

    ephererid 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<