亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

CSS 圖片動(dòng)畫特效的示例代碼(相框)

  發(fā)布時(shí)間:2018-06-14 16:28:48   作者:滑滑兔   我要評(píng)論
這篇文章主要介紹了CSS 圖片動(dòng)畫特效的示例代碼(相框)的相關(guān)資料,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

本文介紹了CSS 圖片動(dòng)畫特效的示例代碼(相框),分享給大家,具體如下:

下面是效果圖

HTML代碼

<!-- 主容器 -->
<div class="box">

    <!-- 圖片 -->
    <img src="images/pic.png" alt=""/>

    <!-- 內(nèi)容 -->
    <div class="box-inner-content">
        <h3 class="title">Rabbit</h3>
    <span class="post">Web Developer</span>
    </div>

</div>

CSS代碼

/* 初始化 */
body,
html {
    font-size: 100%;
}
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
body {
    background: #494A5F;
    font-weight: 500;
    font-size: 1.05em;
    font-family: "Microsoft YaHei","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif;
}

/* 外層容器 */
.box {
    margin: 100px auto;
    width: 400px;
    height: 400px;
    overflow: hidden;
    position: relative;
}
.box:before {
    content: "";
    display: block;
    border: 30px solid rgba(255, 255, 255, 0.3);
    position: absolute;
    top: 5px;
    left: 5px;
    bottom: 5px;
    right: 5px;
    opacity: 1;
    z-index: 2;
    transition: all 0.3s ease 0s;
}
.box:hover:before {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 10px solid rgba(255, 255, 255, 0.18);
}
.box:after {
    content: "";
    display: block;
    border: 8px solid #fff;
    position: absolute;
    top: 35px;
    left: 35px;
    bottom: 35px;
    right: 35px;
    opacity: 1;
    z-index: 1;
    transition: all 0.5s ease 0s;
}
.box:hover:after {
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    opacity: 0;
}

/* 圖片 */
.box img {
    width: 100%;
    height: auto;
    transform: scale(1.2);
    transition: all 0.5s ease 0s;
}
.box:hover img {
    transform: scale(1);
}

/* 文字內(nèi)容 */
.box .box-inner-content {
    position: absolute;
    left: 45px;
    bottom: 125px;
    right: 45px;
    text-align: center;
    color: #fff;
    opacity: 0;
    transition: all 0.3s ease 0s;
}
.box:hover .box-inner-content {
    opacity: 1;
    bottom: 20px;
    text-shadow: 0 0 10px #000;
}

/* 標(biāo)題 */
.box .title {
    font-size: 26px;
    font-weight: bold;
    margin: 0;
}

/* 文本 */
.box .post{
    display: block;
    font-size: 16px;
    font-style: italic;
    margin-bottom: 10px;
}

這里用了像素設(shè)定容器的大小,如果用bootstrap等框架的話,可以設(shè)置成響應(yīng)式。

因?yàn)閳D片設(shè)置成100%,所以會(huì)自適應(yīng)外層容器的大小。

需要注意的是外層容器的position一定要設(shè)置成relative。

主要用到CSS3的transition屬性,我這里沒(méi)設(shè)瀏覽器前綴,現(xiàn)在大多數(shù)瀏覽器都已經(jīng)兼容這個(gè)屬性了。如果不放心又不嫌麻煩的話,最好還是把各瀏覽器前綴加上。

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

相關(guān)文章

最新評(píng)論