css图片的一些方法

css3过度动画

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS3过渡动画</title>
    <style type="text/css">
        .box{
            width: 100px;
            height: 100px;
            background-color: gold;
            /*在哪产生动画、动画的时间、运动曲线、延迟*/
            /*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;
            /*水平偏移 垂直偏移 羽化大小 扩展大小 颜色*/
            box-shadow: 10px 10px 10px 0px #bfa;
        }
        .box2{
            width: 200px;
            height: 40px;
            background-color: gold;
            margin: 100px auto 0;
            /*水平偏移 垂直偏移 羽化大小 扩展大小 颜色 是否内阴影*/
            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;
            /*背景色变透明,但文字不会透明*/
            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>

运动曲线

!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>运动曲线</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){
            /*开始和结束慢速,中间加速*/
            transition: all 1s ease;
        }
        div:nth-child(3){
            /*开始慢速,结尾突然停止*/
            transition: all 1s ease-in;
        }
        div:nth-child(4){
            /*突然开始,结束时慢速*/
            transition: all 1s ease-out;
        }
        div:nth-child(5){
            /*开始和结束时慢速*/
            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;
            /*默认文字不可见*/
            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标签的margin,而不直接给.pic_info用padding,因为padding会改变盒子大小*/
        .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的动画不会影响到box2*/
            /*位移*/
            transform: translate(50px,50px);
        }
        .box2:hover{
            /*沿Z轴旋转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>

元素旋转

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素旋转</title>
    <style type="text/css">
        /*旋转方向判断
        1、X轴向右、Y轴向下、Z轴向屏幕外
        2、让轴向对着自己,顺时针方向就是该轴向的旋转方向*/
        .box{
            width: 300px;
            height: 300px;
            background-color: gold;
            margin: 50px auto 0;
            transition: all 500ms ease;
            /*设置盒子按3D空间显示*/
            transform-style: preserve-3d;
            transform: perspective(800px) rotateY(0deg);
        }
        .box:hover{
            /*默认沿Z轴旋转*/
            /*transform: rotate(45deg);*/
            /*perspective设置透视距离,经验数值800比较符合人眼的透视效果*/
            /*transform: perspective(800px) rotateX(45deg);*/
            transform: perspective(800px) rotateY(-45deg);
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1 CALayer IOS SDK详解之CALayer(一) http://doc.okbase.net/Hell...
    Kevin_Junbaozi阅读 10,579评论 3 23
  • 官网中文版 1 简易天空替换## 技能:线性擦除,追踪运动,用颜色键K出人物,用色彩曲线调色。(1)天空图片素材放...
    朱细细阅读 13,847评论 4 82
  • 1、通过CocoaPods安装项目名称项目信息 AFNetworking网络请求组件 FMDB本地数据库组件 SD...
    阳明AI阅读 16,041评论 3 119
  • 上周六BM举行周年庆,我报名参加了。地点是在深圳的南山区。听说有很多外地和国外的小伙伴也赶过来了。【收获】: 一本...
    羽辰在精进阅读 793评论 0 0
  • 这是我加入007以来的第0篇文章。希望能开一个好头,输出一些有意思的内容。 我就分享一下今天抓住的一次小的赚钱机会...
    yinyuanlin阅读 6,927评论 8 7