過(guò)渡背景圖background-position屬性動(dòng)態(tài)切換菜單的狀態(tài)

實(shí)現(xiàn)效果如下:

效果展示.gif

CSS樣式

<style>
  .container { width: 476px; margin: 0 auto; }
  ul { padding: 20px 0 0 0 ; margin-top: 50px; width: 100%; border-top: 1px dashed #e0e0e0; border-bottom: 1px solid #aaa; }
  li { display: inline-block; margin-left: 40px; cursor: pointer; }
  li a { display: block; width: 60px; height: 60px; padding: 20px; border-radius: 15px; border: 1px dotted #ce0500; }
  li:hover a { border: 1px dotted #696969; }

  li a span { display: block; width: 100%; height: 100%; background:url(img/test/icon1.png) no-repeat bottom center; -webkit-transition: background 0.3s; -moz-transition: background 0.3s; -ms-transition: background 0.3; transition: background 0.3; }
  li:hover a span{ background-position:top center; }

  li p { font-size: 18px; color: #ce0500; text-align: center; margin-top: 15px; }
  li:hover p{ color:#333; }
  li strong { display: block; position: relative; width: 100%; margin-top: 15px; border-bottom: none; }
  li:hover strong {border-bottom: 1px solid #ce0500; }

  li:hover strong i{ display: block; }
  li i { display: none; position: absolute; width: 0; height: 0; left: 50%; margin-left: -9px; border: 10px solid transparent; border-top-color: #ce0500; }
</style>

html

<div class="container">
            <ul class="li_list">
                
                <li>
                    <a>
                        <span></span>
                    </a>
                    <p>我的素材</p>
                    <strong>
                        <i></i>
                    </strong>
                </li>
                <li>
                    <a>
                        <span style="background-image:url(img/test/icon2.png);"></span>
                    </a>
                    <p>我的相冊(cè)</p>
                    <strong>
                        <i></i>
                    </strong>
                </li>
                <li>
                    <a>
                        <span style="background-image:url(img/test/icon3.png);"></span>
                    </a>
                    <p>我的焦點(diǎn)</p>
                    <strong>
                        <i></i>
                    </strong>
                </li>
            </ul>
        </div>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容