css3新增模块

  • 边框圆角
  • 阴影
  • 形变:旋转,缩放,位移
  • 过度效果
  • 动画效果
  • 媒体查询
  • Flex布局
  • Grid布局
  • 等等(选择器还可以自定义字体)

新增加圆角功能:border-radius:左上  右上  右下  左下

<style>
  .box{
    width: 100px;
    height: 100px;
    border: 1px solid red;
    border-radius: 30px;
  }
</style>
</head>
<body>
  <div class="box"></div>
</body>
</html>

阴影:  box-shadow: 10px 20px 30px blue

参考x轴,y轴,模糊半径,建议阴影颜色不要设置黑色

<style>
  .box{
    width: 100px;
    height: 100px;
    border: 1px solid red;
    border-radius: 30px;
    background-color: red;
    /* 10px表示向右移动距离,20px是向下移动的距离,30px是羽化的效果值越大羽化越大 */
    box-shadow: 10px 20px 30px blue;
  }
</style>
</head>
<body>
  <div class="box"></div>
</body>
</html>

形变:

transform:

rotate();旋转 deg单位表示角度

scale();缩放

translate();位移

<style>
      .box{
        width: 100px;
        height: 100px;
        background-color: red ;
        /* 圆角 */
        border:1px solid red;
        border-radius: 4opx;
        /* 阴影 */
        background-color: red;;
        box-shadow: 10px 20px 30px 50px blue;
        /* 形变 */
        /* transform: rotate(45deg);
        transform:scale(0.5);
        transform:translate(50px,100px); */
        /* 旋转后位移 */
        /* transform:rotate(45deg) translate(50px,100px); */
          }
          /* 鼠标移入旋转后位移 */
      .box:hover{
        transform: rotate(45deg) scale(0.5);
      }
  </style>
</head>
<body>
    <div class="box"><h1>hello</h1></div>
    
</div>
</body>
</html>

 案例:水平居中

 <style>
      .box{
            width:500px;
            height: 200px;
            background-color: red ;
            /* margin: 0 auto; */
            position: absolute;
            top:50%;
            left: 50%;
            transform: translate(-50%,-50%);
          }
   
      /* 让一个元素在网页中水平居中 */
  </style>
</head>
<body>
    <div class="box"><h1>hello</h1></div>
    
</div>
</body>
</html>

案例:让一个蓝色的正圆垂直水平居中显示,正圆直径是100px,阴影是红色是10px.

  <style>
      .box{
            width:100px;
            height: 100px;
            background-color: blue ;
            /* margin: 0 auto; */
            position: absolute;
            border-radius: 50%;
            top:50%;
            left: 50%;
            box-shadow: 10px 10px 10px red;
            transform: translate(-50%,-50%);
          }
  </style>
</head>
<body>
    <div class="box"></div>
    </div>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值