欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用div+css3實(shí)現(xiàn)一個(gè)背景漸變的button按鈕的示例代碼

  發(fā)布時(shí)間:2020-07-07 15:41:33   作者:酷酷的橙007   我要評(píng)論
這篇文章主要介紹了利用div+css3實(shí)現(xiàn)一個(gè)背景漸變的button按鈕的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

隨著目前前端頁(yè)面的需求不斷提升,有些場(chǎng)景需要漸變背景的元素。本文利用div和css3新屬性,實(shí)現(xiàn)了一個(gè)背景漸變的按鈕,具體如下:

1.background: linear-gradient 背景為漸變色屬性
2.利用css3中動(dòng)畫特性animation,實(shí)現(xiàn)背景從左至右變化(color_move)
3.為了實(shí)現(xiàn)漸變效果,將background的寬度拉長(zhǎng)至400%

上代碼:

html:

<div class="btn_demo">
	<div class="text">體 驗(yàn)</div>
	<div class="arrow">»</div>
</div>

css:

@keyframes arrow_move {
   /* 開始狀態(tài) */
    0% {
        left: 130px;
    }
	/* 結(jié)束狀態(tài) */
    100% {
        left: 140px;
    }
}
@keyframes color_move {
    /* 開始狀態(tài) */
    0% {
        background-position: 0% 0%; /* 水平位置 垂直位置 */
    }
    50% {
        background-position: 50% 0%;
    }
	/* 結(jié)束狀態(tài) */
    100% {
        background-position: 100% 0%;
    }
}
.btn_demo {
    width:180px;
    height:60px;
    border-radius: 10px;
    position: relative;
    background: linear-gradient( 90deg, #373d42 0%, #2679dd 50%, #373d42 100%);
    background-size: 400% 100%;
    animation: color_move 5s infinite ease-in-out alternate;
    cursor: pointer;
}
.btn_demo:hover {
    background: #2679dd;
}
.btn_demo:active {
    background: #373d42;
}
.btn_demo > .text {
    /* background: yellow; */
    width: 50px;
    text-align: center;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    font-size: 20px;
    color: #fff;
    font-weight: bold;
}
.btn_demo > .arrow {
    /* background: green; */
    width: 20px;
    text-align: center;
    position: absolute;
    font-size: 30px;
    color: #fff;
    top: 46%;
    transform: translateY(-50%);
    left: 130px; /* 移動(dòng)130~150px */
    /* 調(diào)用動(dòng)畫 */
    animation-name: arrow_move;
    /* 持續(xù)時(shí)間 */
    animation-duration: 1s;
    /* 無(wú)限播放 */
    animation-iteration-count: infinite;
}

效果如下:


到此這篇關(guān)于利用div+css3實(shí)現(xiàn)一個(gè)背景漸變的button按鈕的示例代碼的文章就介紹到這了,更多相關(guān)div+css3背景漸變按鈕內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論