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

淺談CSS3鼠標(biāo)移入圖片動(dòng)態(tài)提示效果(transform)

  發(fā)布時(shí)間:2017-11-06 15:25:38   作者:fanfan_12511   我要評(píng)論
本篇文章主要介紹了淺談CSS3鼠標(biāo)移入圖片動(dòng)態(tài)提示效果(transform),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

第一次嘗試著寫博客,不好或者有誤的地方希望大家多多指正吶,今天主要寫的是關(guān)于CSS3的一個(gè)重要屬性transform的一些用法,這些例子是之前在慕課網(wǎng)上學(xué)習(xí)某位老師的課程后自己敲的。

一、前言

1. transform是什么?

transform的含義是:改變,使....變形;轉(zhuǎn)換

2. transform的常見屬性有哪些?

transform的屬性包括: translate()/rotate() / skew() / scale() /,分別還有x、y之分,比如:rotatex() 和 rotatey() ,以此類推。

transform:translate()

含義:變動(dòng),位移;例如向右位移20像素,向上位移50像素(向左向下為負(fù)值) 實(shí)例如下

.test01{-webkit-transform:translate(20px,50px);-moz-transform:translate(20px,50px)}

transform:rotate()

含義:旋轉(zhuǎn);“deg”是表示旋轉(zhuǎn)的度數(shù) 例如“180deg”表示旋轉(zhuǎn)“180度”  實(shí)例如下

.test02{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg)}

transform:skew()

含義:傾斜  實(shí)例如下

.test03{-webkit-transform:skew(20deg);-moz-transform:skew(20deg)} 

transform:scale()

含義:比例  1.8表示以1.8的比例放大 如果是放大整數(shù)倍如放大3倍 必須寫成3.0  實(shí)例如下

.test03{-webkit-transform:scale(2.5);-moz-transform:scale(2.5)}

3. transform的實(shí)例

demo01 說明:鼠標(biāo)移入后 圖片左移 內(nèi)容依次進(jìn)入

步驟:

1.寫好html代碼并通過css設(shè)置好內(nèi)容和圖片的初始樣式(文字內(nèi)容都在圖片上);

2.將描述內(nèi)容通過transform屬性位移到左側(cè) 看不到為止(transform:translate(-600px,0););

3.接下來設(shè)置鼠標(biāo)移入時(shí)(:hover)的樣式  同樣是利用transform   使內(nèi)容左移的距離為0(transform:translate(0,0))這里用到transition-delay屬性主要是為了讓三個(gè)內(nèi)容分別延遲不同的時(shí)間 形成依次進(jìn)入的效果?! ?/p>

/*圖片左移 文字依次進(jìn)入*/
.test1{background: #fff;}
.test1 figcaption p{background: #fff;color:#333;margin:5px 0;transform: translate(-600px,0px);}
.test1 figcaption{padding:20px}
.test1:hover figcaption p{transform: translate(0,0);}

.test1 figcaption p:nth-of-type(1){transition-delay: 0.2s;}
.test1 figcaption p:nth-of-type(2){transition-delay: 0.3s;}
.test1 figcaption p:nth-of-type(3){transition-delay: 0.4s;}
.test1:hover img{transform: translate(-5px,0);}

        <!--移動(dòng)-->
        <figure class="test1">
            <img src="img/altimg05.jpg">
            <figcaption>
                <h2>圖片標(biāo)題</h2>
                <p>這里是圖片的相關(guān)描述內(nèi)容</p>
                <p>這里是圖片的相關(guān)描述內(nèi)容</p>
                <p>這里是圖片的相關(guān)描述內(nèi)容</p>
            </figcaption>
        </figure>

demo02 說明:鼠標(biāo)移入后 圖片變模糊 矩形從圖片外旋轉(zhuǎn)進(jìn)入圖片中指定位置 文字從右側(cè)飛過來 并逐漸顯示

    

步驟:

1.寫好html代碼并通過css設(shè)置好內(nèi)容和圖片的初始樣式(矩形文字都在圖片上);

2.將矩形通過transform屬性位移到上方 看不到為止 并設(shè)置旋轉(zhuǎn)的角度為0  transform: translate(0,-400px) rotate(0deg);

3.接下來設(shè)置鼠標(biāo)移入時(shí)(:hover)的樣式 位移設(shè)置為0并旋轉(zhuǎn)360度  transform: translate(0,0) rotate(360deg);

/*旋轉(zhuǎn)*/
.test2{background: #ccc;}
.test2 figcaption{width: 100%;height: 100%;}
.test2 figcaption h2{margin:15% 0 0 15%}
.test2 figcaption p{margin-left:15%;transform: translate(50px,0);opacity: 0;}
.test2 figcaption div{border:2px solid #ccc;width: 80%;height: 80%;position:absolute;top:10%;left:10%;transform: translate(0,-400px) rotate(0deg);}
.test2:hover figcaption div{transform: translate(0,0) rotate(360deg);}
.test2:hover img{opacity: 0.6;}
.test2:hover figcaption p{transform: translate(0,0);opacity: 1;}

 
        <!--旋轉(zhuǎn)-->
        <figure class="test2">
            <img src="img/altimg05.jpg">
            <figcaption>
                <h2>圖片標(biāo)題</h2>
                <p>飛來飛去</p>


                <div></div>
            </figcaption>
        </figure>

demo03 說明:鼠標(biāo)移入后 扭曲的字正常顯示(因?yàn)槔又信で?0度 所以視覺上看不到文字)

      

步驟:

1.寫好html代碼并通過css設(shè)置好內(nèi)容和圖片的初始樣式;

2.將文字內(nèi)容扭曲90度 transform: skew(90deg);

3.接下來設(shè)置鼠標(biāo)移入時(shí)(:hover)的樣式 將文字內(nèi)容扭曲0度 transform: skew(0);

/*扭曲*/
.test3{background:#CCCCCC;}
.test3 figcaption{position: absolute;left:15%;top:15%}
.test3 figcaption h2{transform: skew(90deg);}
.test3 figcaption p{transform: skew(90deg);}
.test3:hover img{opacity: 0.6;}
.test3:hover figcaption h2{transform: skew(0);}
.test3:hover figcaption p{transform: skew(0);}
        <!--扭曲-->
        <figure class="test3">
            <img src="img/altimg05.jpg">
            <figcaption>
                <h2>圖片標(biāo)題</h2>
                <p>這里是圖片的相關(guān)描述內(nèi)容</p>
            </figcaption>
        </figure>

demo04 說明:鼠標(biāo)移入后 矩形和文字顯示并縮小  圖片也縮小

 

步驟:

1.寫好html代碼并通過css設(shè)置好內(nèi)容和圖片的初始樣式

2.將內(nèi)容放大1.2倍 這是為了鼠標(biāo)移入后放大倍數(shù)變成1時(shí)形成縮小的效果 內(nèi)容的透明度設(shè)置為0;

3.接下來設(shè)置鼠標(biāo)移入時(shí)(:hover)的樣式 內(nèi)容放大倍數(shù)變成1也就是原始大小 圖片縮小  透明度都變成1;

/*縮放*/
.test4{background: #000;}
.test4 figcaption{width: 100%;height: 100%;}
.test4 figcaption h2{margin:15% 0 0 15%;opacity:0;transform: scale(1.2);}
.test4 figcaption p{margin-left:15%;opacity:0;transform: scale(1.2);}
.test4 figcaption div{border:2px solid #ccc;width: 80%;height: 80%;position:absolute;top:10%;left:10%;transform: scale(1.2,1.2);opacity: 0;}
.test4:hover figcaption div{transform: scale(1,1);opacity: 1;}
.test4:hover img{opacity: 0.6;transform: scale(0.9,0.9);}
.test4:hover figcaption h2{opacity: 1;transform: scale(1);}
.test4:hover figcaption p{opacity: 1;transform: scale(1);}

 

        <!--縮放-->
        <figure class="test4">
            <img src="img/altimg05.jpg">
            <figcaption>
                <h2>圖片標(biāo)題</h2>
                <p>這里是圖片的相關(guān)描述內(nèi)容</p>
                <div></div>
            </figcaption>
        </figure>

demo05 說明:鼠標(biāo)移入后 內(nèi)容顯示 并出現(xiàn)井字格

  

步驟:

1.寫好html代碼并通過css設(shè)置好內(nèi)容和圖片的初始樣式(井字就是兩個(gè)矩形的重疊)

2.將兩個(gè)矩形縮小0.8 并設(shè)置透明度為0 內(nèi)容也設(shè)置透明度為0;

3.接下來設(shè)置鼠標(biāo)移入時(shí)(:hover)的樣式 內(nèi)容透明度設(shè)置為1 設(shè)置矩形縮放為1  這里利用到transition屬性 主要是為了縮小放大過程逐漸變化;

/*井字格*/
.test5{background: #000;}
.test5 figcaption{width: 100%;height: 100%;}
.test5 figcaption h2{margin: 15% 0 0 18%;opacity: 0;}
.test5 figcaption p{margin-left: 18%;opacity: 0;}
.test5 figcaption div{position: absolute;}
.test5 figcaption div.div01{width: 80%;height:70%;border-top: 2px solid #ccc;border-bottom: 2px solid #ccc;left:10%;top:15%;opacity: 0;transform: scale(0.8);}
.test5 figcaption div.div02{width: 70%;height:80%;border-left: 2px solid #ccc;border-right: 2px solid #ccc;left: 15%;top:10%;opacity: 0;transform: scale(0.8);}
.test5:hover div.div01{opacity: 1;transform: scale(1);transition: transform 0.3s ease-in}
.test5:hover div.div02{opacity: 1;transform: scale(1);transition: transform 0.3s ease-in}
.test5:hover figcaption p{opacity: 1;}
.test5:hover figcaption h2{opacity: 1;}
.test5:hover img{opacity: 0.6;}

        <!--井字格-->
        <figure class="test5">
            <img src="img/altimg05.jpg">
            <figcaption>
                <h2>圖片標(biāo)題</h2>
                <p>這里是圖片的相關(guān)描述內(nèi)容</p>
                <div class="div01"></div>
                <div class="div02"></div>
            </figcaption>
        </figure>

以上是幾個(gè)簡單的小例子,之所以用figure和figcaption標(biāo)簽,主要是標(biāo)簽的語義化,截取動(dòng)態(tài)圖用到的是GifCam第一次用 挺好用的 很可愛 哈哈。

figure標(biāo)簽主要是用于規(guī)定獨(dú)立的流內(nèi)容(圖片,圖表,照片,代碼等)而figcaption與figure標(biāo)簽配套使用,主要用于定義figure元素的標(biāo)題

哦,對(duì)了,由于這幾個(gè)例子寫在一個(gè)html里面 所以提取出了部分公用的樣式

body,figure,figcaption,h2,p{margin:0;padding:0;font-family: "微軟雅黑";}
figure{position: relative;overflow: hidden;float: left;width:33.33%;height: 350px;}
figcaption{position: absolute;top: 0;left: 0;color:#fff;}
figure img{width:101%;height: 360px;opacity: 0.8;transition: all 0.35s}
figure figcaption p,h2,span,div{transition: all 0.35s}
@media screen and (max-width: 600px) {
    figure{width: 100%;}
}
@media screen and (min-width:601px) and (max-width: 1000px) {
    figure{width: 50%;}
}
@media screen and (min-width: 1001px) {
    figure{width: 33.33%;}
}

 

總結(jié):

之所以選擇寫博客主要是為了鍛煉自己的表達(dá)能力,培養(yǎng)一個(gè)總結(jié)知識(shí)點(diǎn)的好習(xí)慣,以前看別人寫的一些好的文章時(shí)都很羨慕,自己卻總是不知道從何下手,直到最近投簡歷的時(shí)候發(fā)現(xiàn)很多公司都要求注明自己的博客地址,所以有必要逼著自己寫一下東西啦!

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論