css 之 hover 大用途

來源:互聯網
上載者:User

標籤::hover   relative   cte   lock   blog   實現   ict   不顯示   決定   

1.當滑鼠移動至表徵圖或者文字時,滑鼠右下角出現圖片索引?

                               

代碼實現如下:

<a href="#">點擊關注    <div class="pic">        <img src="../../img/picter/images/card1.gif" alt=""/>    </div></a>

CSS插入樣式:

       a{            position: relative;        }        .pic{            width: 100px;            height: 150px;            position: absolute;            top: 30px;            display: none;        }        a:hover .pic{            display: block;        }

注釋:

首先,給父級確定相對定位 position:relative

其次 ,子級確定決定定位,即圖片需要展示的位置 position:absolute,由於子級本身是一個div區塊層級元素,為了使移動滑鼠可以達到上訴效果,故將子級div轉變為none;

當滑鼠不移動時,圖片不顯示。

最後,最關鍵!!!

當滑鼠移動至 a 標籤,需要顯示的是 div裡面的 picter ,故書寫時需注意: a:hover .pic ,將空元素轉變為 block 區塊層級元素顯示即可。

 

css 之 hover 大用途

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.