css[属性补充]

1,overflow(溢出裁剪 边框 盒子阴影)

  • overflow:hidden;
  • border:1px solid red;
  • box-shandow:5px 5px 5px red;
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>溢出裁剪</title>
  <style>
    body,html{
      min-width: 700px;
      max-width: 1600px;
    }
    div{
      width: 300px;
      height: 300px;
      /* border: 1px solid red; */
      border-width:5px ;
      border-style: dashed;
      border-color: black;
      /* 边框圆角 */
      border-radius: 5px;
      /* 超出容器范围的部分隐藏 */
      overflow: hidden;
      /* 盒子阴影 水平偏移 垂直偏移 阴影的模糊程度*/
      box-shadow: 5px 5px 10px  gray;
    }
  </style>
</head>
<body>
  <div>
    <img src="images/daf4d1caa2266b3e.png" alt="">
  </div>
  <H3>OVERFLOW</H3>
</body>
</html>

2,背景

  • 背景颜色:background-color
  • 背景图片:background-img
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>背景</title>
  <style>
    body{
      /* background-color: aqua; */
      background-image: url("images/daf4d1caa2266b3e.png");
      /* 取消图片平铺 */
     /*  background-repeat: no-repeat; */
     /*  严x轴平铺 */
      background-repeat: repeat-x;
       /* 背景固定 */
       background-attachment: fixed;
    }
    div{
      margin: 0 auto;
      width: 600px;
      height: 1200px;
      background: lightcoral;
     
    }
  </style>
</head>
<body>
  <div></div>
</body>
</html>

2.1,精灵图的使用

  • backgroud-position
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
       div{
           width: 120px;
           height: 120px;
           margin: 0 auto;
           background: url("../images/inde_icon.png");
           background-position: -547px -120px;
           border: 1px solid red;
       }
    </style>
</head>
<body>
    <div>
    </div>
</body>
</html>

在这里插入图片描述
使用精灵图之后

在这里插入图片描述

  • 背景固定:background-attachment:fixed;
  • 背景图片的大小:
    • auto 自己适应
    • contain 一个方向的值去填充
    • cover 完全填充
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div{
      background: url("images/daf4d1caa2266b3e.png");
      width: 600px;
      height: 600px;
      /* contain 包含 他是自己根据某个放向的值去适应 
        cover 完全填充
      */
      background-size:cover;
    }
  </style>
</head>
<body>
  <div>

  </div>
</body>
</html>

3,颜色

  • 颜色名称
  • 十六进制色值
  • rgb
  • rgba
<style>
    p{
      /* color是文字的颜色: 
      1. 颜色的名称red green
      2.RGB三原色 red green blue
      3. 16进制的颜色值
      4. rgba()
      */
     /*  color: rgb(0, 110, 255); */
     /* 十六进制的颜色值 */
     /* color:rgb(109, 46, 46); */
     /* 透明度的值在0-1之间 */
     color:rgb(109, 46, 46,0.5);
    }
    div{
      width: 200px;
      height: 200px;
     /*  background: rgba(200, 100, 20, 1); */
     background-color: red;
     /* 透明度 */
     opacity: 0.4;
    }
  </style>

4,文本

  • text-align 水平位置
  • text-sahndow 文字阴影
  • text-ident 文字缩进
  • line-hight 行高
  • text-decoration 文本装饰
<style>
    div{
      width: 500px;
      height: 200px;
      border: 1px solid red;
      /* 文本的水平位置 center 居中 */
      text-align:center ;
      /*文字阴影  */
      text-shadow: 5px 5px 5px red;
      /* 文字的缩进 */
      text-indent: 10px;
    }
    div a{
      /* 文本装饰 下划线*/
      text-decoration: underline;
    }
    #p1{
      width: 500px;
      height: 50px;
      border: 1px solid red;
      text-align: center;
      /* 行高 */
      line-height: 50px;
    }
  </style>

5,其他属性

  • list-style :取消列表样式
  • outline 轮廓线
  • cursor 鼠标显示样式
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* ul 默认是自带样式的 里面的元素和Ul自身有间距 */
    ul{
      width: 400px;
      height: 50px;
      border: 1px solid red;
      /* 取消列表的样式 */
      list-style: none;
      margin: 0;
      padding: 0;
    }
    ul > li {
      width: 96px;
      height: 50px;
      border: 1px solid green;
      float: left;
    }

    input{
      width: 150px;
      height: 35px;
      background: lawngreen;
      /* 外部的轮廓线 */
      outline:none ;
      /* border: 1px solid lawngreen; */
      border: none;
    }
    input:hover{
      /* 鼠标的样式 pointer*/
      cursor: wait;
    }
  </style>
</head>
<body>
  <ul>
    <li>hello</li>
    <li>hello</li>
    <li>hello</li>
    <li>hello</li>
  </ul>

<br>
  <input type="button" value="">
</body>
</html>

6,过渡

  • transition:
    • ease 平滑过渡
    • ease-in由慢到快
    • ease-out又快到慢
    • ease-in-out

7,转换(transform)

  • translate
  • rotate
  • 3D
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>转换</title>
  <style>
    div{
      width: 300px;
      height: 300px;
      background: lightblue;
      margin: 100px auto;
    }
    div:hover{
      /* 水平移动5px */
      transform: translateX(-5px) translateY(-5px);
      box-shadow: 0px 0px 15px black;
      transition: 1s ease;

    }
    div:nth-child(2){
      width: 300px;
      height: 300px;
      margin: 50px auto;
      background: lightcoral;
    }
    div:nth-child(2):hover{
      /* 旋转 deg 角度单位 */
      transform: rotate(45deg) scale(1.5);
      transition: 2s ease-in-out;
      /* scale 缩放 */
    /*   transform: scale(1.5); */
    }
  </style>
</head>
<body>
  <div></div>
  <div></div>
</body>
</html>
  • 转换前

在这里插入图片描述

  • 转换后

在这里插入图片描述

  • 3D效果
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D效果</title>
    <style>
        .box {
            position: relative;
            width: 200px;
            height: 200px;
            /* background: lawngreen; */
            border: 1px solid red;
            margin: 200px auto;
            /* 转换为3d效果 x y z */
            transform-style: preserve-3d;
            transform: rotateX(-60deg) rotateY(60deg);
        }

        .front,
        .top,
        .left,
        .right,
        .back,
        .bottom {
            position: absolute;
            width: 200px;
            height: 200px;
        }

        .front {
            background-image: url("../images/3.png");
            transform: translateZ(100px);
        }

        .back {
            background-image: url("../images/3.png");
            transform: translateZ(-100px) rotateY(180deg);
        }

        .left {
            background-image: url("../images/3.png");
            transform: translateX(-100px) rotateY(-90deg);
        }

        .right {
            background-image: url("../images/3.png");
            transform: translateX(100px) rotateY(90deg);
        }

        .top {
            background-image: url("../images/3.png");
            transform: translateY(-100px) rotateX(90deg);
        }

        .bottom {
            background-image: url("../images/3.png");
            transform: translateY(100px) rotateX(-90deg);
        }

        .box:hover {
            transform: rotateX(-360deg) rotateY(360deg);
            transition: 10s ease;
        }

        /* 爆炸效果 */
        .box:hover .front {
            background-image: url("../images/3.png");
            transform: translateZ(200px);
        }

        .box:hover .back {
            background-image: url("../images/3.png");
            transform: translateZ(-200px) rotateY(180deg);
        }

        .box:hover .left {
            background-image: url("../images/3.png");
            transform: translateX(-200px) rotateY(-90deg);
        }

        .box:hover .right {
            background-image: url("../images/3.png");
            transform: translateX(200px) rotateY(90deg);
        }

        .box:hover .top {
            background-image: url("../images/3.png");
            transform: translateY(-200px) rotateX(90deg);
        }

        .box:hover .bottom {
            background-image: url("../images/3.png");
            transform: translateY(200px) rotateX(-90deg);
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="front">前面</div>
        <div class="back">后面</div>
        <div class="left">左面</div>
        <div class="right">右面</div>
        <div class="top">上面</div>
        <div class="bottom">下面</div>
    </div>


</body>

</html>

在这里插入图片描述

8,动画

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动画</title>
    <style>
        div {
            width: 300px;
            height: 300px;
            background: lightcoral;
            /* 动画名称,时间,速度,死循环![在这里插入图片描述](https://img-blog.csdnimg.cn/20200425235910977.gif#pic_center)
 */
            animation: temp 3s ease infinite;
        }

        @keyframes temp {
            0% {
                transform: translate(0, 0);
            }

            25% {
                transform: translate(200px, 0) rotate(60deg);
                background: red;
            }

            50% {
                transform: translate(200px, 200px) rotate(60deg);
                background: green;
            }

            75% {
                transform: translate(0, 200px) rotate(60deg);
                background:blue;
            }

            100% {
                transform: translate(0, 0) rotate(0);
                background: lightseagreen;
            }
        }
    </style>
</head>

<body>
    <div></div>
</body>

</html>

在这里插入图片描述

9,响应式和自适应页面布局(了解)

  • 媒体查询
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 媒体查询: 查询当前设备浏览器的大小 -->
  <style>
    /* 我们根据浏览器的不同决定他的大小 */
    @media screen and  (min-width: 1200px){
      .nav{
        width: 1516px;
        height: 400px;
        background: lawngreen;
      }
    }



    @media screen and  (max-width: 1200px) and (min-width: 768px){
      .nav{
        width: 1516px;
        height: 200px;
        background: lightseagreen;
      }
    }
    @media screen and  (max-width: 768px){
      .nav{
        width: 1516px;
        height: 300px;
        background: lightcoral;
      }
    }
  </style>
</head>
<body>
  <div class="nav">hello</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值