第八十四節,css布局小技巧

來源:互聯網
上載者:User

標籤:css布局   images   選擇   osi   轉換   splay   地方   absolute   png   

css布局小技巧

圖片滑鼠放上去遮罩效果,顯示文字

當滑鼠放上去時

/*最外層div*/.a{    width: 384px;    height: 240px;    background-color: #ff4e37;    position: relative;}/*插入圖片的div*/.b{    width: 384px;    height: 240px;    background-color: #ff4e37;    overflow: hidden;}/*遮罩層div*/.c{    width: 384px;    height: 240px;    background-color: #010008;    opacity: 0;    overflow: hidden;    position: absolute;    left: 0px;    top: 0px;    right: 0px;    bottom: 0px;}/*滑鼠放上去效果*/div .c:hover{    background-color: #010008;    opacity: 0.5;    color: #FFFFFF;    font-size: 40px;    font-weight: bold;    text-align: center;    line-height: 240px;}<div class="a">    <div class="b">        <img src="53d.jpg">    </div>    <div class="c">        <samp>美女圖片</samp>    </div></div>

 

css繪製尖角效果

在網頁中,有很多地方會用到尖角,尖角可以是圖片的,也可以用css來繪製

用一個div來繪製尖角

.a{    /*設定邊框*/    border-top: 30px solid red;    border-right: 30px solid black;    border-bottom: 30px solid green;    border-left: 30px solid blue;    /*將區塊轉換成內聯塊*/    display: inline-block;}<div class="a"></div>

效果:顏色可以根據自己的需要調整

 

將其他不需要的3個尖角顏色改成透明的,一個尖角就形成了

.a{    /*設定邊框*/    border-top: 30px solid transparent;    border-right: 30px solid transparent;    border-bottom: 30px solid transparent;    border-left: 30px solid blue;    /*將區塊轉換成內聯塊*/    display: inline-block;}<div class="a"></div>

效果:

 

另一種效果

.a{    /*設定邊框*/    border-top: 30px solid transparent;    border-right: 30px solid transparent;    border-bottom: 0px solid transparent;    border-left: 30px solid blue;    /*將區塊轉換成內聯塊*/    display: inline-block;}<div class="a"></div>

  效果:

 

 

還可以結合偽類別選取器:hover來設定滑鼠動作尖角

.af{    width: 100px;    height: 50px;    background-color: #ff563a;}.a{    /*設定邊框*/    border-top: 10px solid green;    border-right: 10px solid transparent;    border-bottom: 10px solid transparent;    border-left: 10px solid transparent;    /*將區塊轉換成內聯塊*/    display: inline-block;    margin-top: 20px;    margin-left: 10px;}.a:hover{    /*設定邊框*/    border-top: 10px solid transparent;    border-right: 10px solid transparent;    border-bottom: 10px solid green;    border-left: 10px solid transparent;    /*將區塊轉換成內聯塊*/    display: inline-block;    margin-top: 10px;    margin-left: 10px;}<div class="af">    <div class="a"></div></div>

效果:滑鼠沒放上去時尖角向下,滑鼠放上去尖角向上

第八十四節,css布局小技巧

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.