css圖片的一些方法

css3過(guò)度動(dòng)畫

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS3過(guò)渡動(dòng)畫</title>
    <style type="text/css">
        .box{
            width: 100px;
            height: 100px;
            background-color: gold;
            /*在哪產(chǎn)生動(dòng)畫、動(dòng)畫的時(shí)間、運(yùn)動(dòng)曲線、延遲*/
            /*transition: border-radius 500ms ease,width 500ms ease 500ms,height 500ms ease 1s,background-color 500ms ease 1.5s;*/
            transition: all 500ms ease;
        }
        .box:hover{
            width: 500px;
            height: 300px;
            background-color: red;
            border-radius: 50px;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>

css3圓角、陰影、透明度

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>css3圓角 陰影 透明度</title>
    <style type="text/css">
        .box{
            width: 200px;
            height: 200px;
            border: 2px solid #000;
            background-color: gold;
            margin: 50px auto 0;
            /*border-top-left-radius: 100px 50px;左上角為橢圓圓角*/
            /*border-top-left-radius: 100px;
            border-top-right-radius: 100px;左、右上角為正圓圓角*/
            /*border-radius: 40px;曲率半徑為40的圓角矩形*/
            /*border-radius: 20%;最大200px,20%即40px*/
            border-radius: 50%;/*正圓*/
        }
        .box1{
            width: 200px;
            height: 40px;
            background-color: gold;
            margin: 100px auto 0;
            /*水平偏移 垂直偏移 羽化大小 擴(kuò)展大小 顏色*/
            box-shadow: 10px 10px 10px 0px #bfa;
        }
        .box2{
            width: 200px;
            height: 40px;
            background-color: gold;
            margin: 100px auto 0;
            /*水平偏移 垂直偏移 羽化大小 擴(kuò)展大小 顏色 是否內(nèi)陰影*/
            box-shadow: 0px 0px 20px 2px red inset;
        }

        body{
            background-color: cyan;
        }
        .box3{
            width: 200px;
            height: 200px;
            /*background: url(images/location_bg.jpg);*/
            background-color: gold;
            margin: 50px auto 0;
            border: 2px solid #000;
            border-radius: 50%;
            /*透明度30%,文字也透明了*/
            opacity: 0.3;
            filter: alpha(opacity=30);/*兼容IE*/
            text-align: center;
            line-height: 200px;
        }
        .box4{
            width: 200px;
            height: 200px;
            /*背景色變透明,但文字不會(huì)透明*/
            background-color: rgba(255,215,0,0.3);
            margin: 50px auto 0;
            /*邊框透明*/
            border: 2px solid rgba(0,0,0,0.3);
            border-radius: 50%;
            text-align: center;
            line-height: 200px;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3">床前明月光</div>
    <div class="box4">床前明月光</div>
</body>
</html>

運(yùn)動(dòng)曲線

!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>運(yùn)動(dòng)曲線</title>
    <style type="text/css">
        div{
            width: 50px;
            height: 50px;
            background-color: gold;
            margin-bottom: 20px;
        }
        div:nth-child(1){
            /*勻速*/
            transition: all 1s linear;
        }
        div:nth-child(2){
            /*開始和結(jié)束慢速,中間加速*/
            transition: all 1s ease;
        }
        div:nth-child(3){
            /*開始慢速,結(jié)尾突然停止*/
            transition: all 1s ease-in;
        }
        div:nth-child(4){
            /*突然開始,結(jié)束時(shí)慢速*/
            transition: all 1s ease-out;
        }
        div:nth-child(5){
            /*開始和結(jié)束時(shí)慢速*/
            transition: all 1s ease-in-out;
        }
        div:nth-child(6){
            /*貝塞爾(貝茲)曲線*/
            /*transition: all 1s cubic-bezier(0.250,0.250,0.750,0.750);勻速*/
            /*超出再縮回的彈性效果*/
            transition: all 1s cubic-bezier(0.470, -0.485, 0.460, 1.435);
        }
        div:hover{
            width: 1000px;
        }
    </style>
</head>

圖片文字遮罩

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>圖片文字遮罩</title>
    <style type="text/css">
        .box{
            width: 200px;
            height: 300px;
            margin: 50px auto 0;
            border: 1px solid #000;
            position: relative;
            /*默認(rèn)文字不可見*/
            overflow: hidden;
        }
        .box img{
            width: 200px;
            height: 300px;
        }
        .box .pic_info{
            width: 200px;
            height: 200px;
            background-color: rgba(0,0,0,0.5);
            color: #fff;

            /*定位使色塊在圖片正下方*/
            position: absolute;
            left: 0;
            top: 300px;

            transition: all 500ms cubic-bezier(0.470, -0.485, 0.460, 1.435);
        }
        .box:hover .pic_info{
            /*色塊上移*/
            top:150px;
        }
        /*間距用p標(biāo)簽的margin,而不直接給.pic_info用padding,因?yàn)閜adding會(huì)改變盒子大小*/
        .box .pic_info p{
            margin: 20px;
            line-height: 30px;
        }
    </style>
</head>

變形

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>變形</title>
    <style type="text/css">
        .box,.box2,.box3,.box4{
            width: 200px;
            height: 200px;
            background-color: gold;
            margin: 50px auto 0;
            transition: all 1s ease;
        }
        .box:hover{
            /*box的動(dòng)畫不會(huì)影響到box2*/
            /*位移*/
            transform: translate(50px,50px);
        }
        .box2:hover{
            /*沿Z軸旋轉(zhuǎn)360度*/
            transform: rotate(360deg);
        }
        .box3:hover{
            /*縮放*/
            transform: scale(0.5,0.2);
        }
        .box4:hover{
            /*斜切*/
            /*transform: skew(45deg,0);*/
            transform: skew(0,45deg);
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <div class="box2"></div>
    <div class="box3"></div>
    <div class="box4"></div>
</body>
</html>

元素旋轉(zhuǎn)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素旋轉(zhuǎn)</title>
    <style type="text/css">
        /*旋轉(zhuǎn)方向判斷
        1、X軸向右、Y軸向下、Z軸向屏幕外
        2、讓軸向?qū)χ约?,順時(shí)針方向就是該軸向的旋轉(zhuǎn)方向*/
        .box{
            width: 300px;
            height: 300px;
            background-color: gold;
            margin: 50px auto 0;
            transition: all 500ms ease;
            /*設(shè)置盒子按3D空間顯示*/
            transform-style: preserve-3d;
            transform: perspective(800px) rotateY(0deg);
        }
        .box:hover{
            /*默認(rèn)沿Z軸旋轉(zhuǎn)*/
            /*transform: rotate(45deg);*/
            /*perspective設(shè)置透視距離,經(jīng)驗(yàn)數(shù)值800比較符合人眼的透視效果*/
            /*transform: perspective(800px) rotateX(45deg);*/
            transform: perspective(800px) rotateY(-45deg);
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
?著作權(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)容

  • 1 CALayer IOS SDK詳解之CALayer(一) http://doc.okbase.net/Hell...
    Kevin_Junbaozi閱讀 5,351評(píng)論 3 23
  • 官網(wǎng)中文版 1 簡(jiǎn)易天空替換## 技能:線性擦除,追蹤運(yùn)動(dòng),用顏色鍵K出人物,用色彩曲線調(diào)色。(1)天空?qǐng)D片素材放...
    朱細(xì)細(xì)閱讀 11,688評(píng)論 4 81
  • 1、通過(guò)CocoaPods安裝項(xiàng)目名稱項(xiàng)目信息 AFNetworking網(wǎng)絡(luò)請(qǐng)求組件 FMDB本地?cái)?shù)據(jù)庫(kù)組件 SD...
    陽(yáng)明AI閱讀 16,240評(píng)論 3 119
  • 上周六BM舉行周年慶,我報(bào)名參加了。地點(diǎn)是在深圳的南山區(qū)。聽說(shuō)有很多外地和國(guó)外的小伙伴也趕過(guò)來(lái)了?!臼斋@】: 一本...
    羽辰在精進(jìn)閱讀 162評(píng)論 0 0
  • 這是我加入007以來(lái)的第0篇文章。希望能開一個(gè)好頭,輸出一些有意思的內(nèi)容。 我就分享一下今天抓住的一次小的賺錢機(jī)會(huì)...
    yinyuanlin閱讀 2,456評(píng)論 8 7

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