css3--background-attachment background-origin background-clip box-shadow border-radius

background-attachment

fixed相对于视口定位 不会随着滚动条一起滚动

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 0 0;
        background-attachment: fixed;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
      <p>这是测试 这是测试 这是测试</p>
    </div>
  </body>
</html>

在这里插入图片描述
local 相对于内容区定位 会跟随滚动条一起滚动

      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 0 0;
        background-attachment: local;
      }

在这里插入图片描述
scroll 相对于文本定位 不会跟随滚动条一起滚动 与fixed差不多 只定位方式不同

      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 0 0;
        background-attachment: scroll;
      }

在这里插入图片描述

background-origin

当 background-attachment 设置为fixed 时 background-origin 与 background-position不生效
更改定位点
border-box 相对于border定位

      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 0 0;
        background-attachment: fixed;
        background-origin: border-box;
      }
      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 0 0;
        background-attachment: fixed;
        background-origin: border-box;
      }

在这里插入图片描述
padding-box 相对于内边距定位

      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 20px 20px;
        background-attachment: scroll;
        background-origin: padding-box;
      }

在这里插入图片描述

      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 20px 20px;
        background-attachment: scroll;
        background-origin: content-box;
      }

在这里插入图片描述

background-clip

裁剪图片
border-box
以边框裁剪

      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 0px 0px;
        background-attachment: fixed;
        background-origin: border-box;
        background-clip: border-box;
      }

在这里插入图片描述
padding-box 以内边距裁剪

在这里插入图片描述content-box 以内容裁剪

      .box {
        padding: 50px;
        width: 1000px;
        height: 1000px;
        border: 50px solid rgba(123, 123, 123, 0.5);
        overflow: scroll;
        background-image: url(img/1.jpg);
        background-repeat: no-repeat;
        background-position: 0px 0px;
        background-attachment: fixed;
        background-origin: border-box;
        background-clip: content-box;
      }

在这里插入图片描述

边框圆角

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
        border: 20px solid #000;
        box-sizing: border-box;
        border-top: 20px solid red;
        border-right: 20px solid yellow;
        border-bottom-color: blue;
        border-top-left-radius: 50%;
        border-top-right-radius: 50%;
        border-bottom-right-radius: 50%;
        border-bottom-left-radius: 50%;
      }
    </style>
  </head>
  <body>
    <div class="box"></div>
  </body>
</html>

在这里插入图片描述
椭圆

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 400px;
        height: 200px;
        border: 20px solid #000;
        box-sizing: border-box;
        border-top: 20px solid red;
        border-right: 20px solid yellow;
        border-bottom-color: blue;
        border-top-left-radius: 200px 100px;
        border-top-right-radius: 200px 100px;
        border-bottom-right-radius: 50%;
        border-bottom-left-radius: 50%;
      }
    </style>
  </head>
  <body>
    <div class="box"></div>
  </body>
</html>

在这里插入图片描述

border-radius

一个值 对应四个角
两个值 对应 左上右下 左下右上
三个值 对应 左上 右上左下 右下
四个值 对应 左上 右上 右下 左下
100px / 50px
相当于 从左上开始顺时针到左下
100 50 border-top-left-radius
100 50 border-top-right-radius
100 50 border-bottom-left-radius
100 50 border-bottom-right-radius

100px 50px / 50px 30px
100 50 border-top-left-radius
50 30 border-top-right-radius
100 50 border-bottom-left-radius
50 30 border-bottom-right-radius

100px 50px 80px /50px 30px
100 50 border-top-left-radius
50 30 border-top-right-radius
80 50 border-bottom-left-radius
50 30 border-bottom-right-radius

当然也可以设置百分比

box-shadow

x-offset x方向偏移距离
y-offset y方向偏移距离
blur-radius 模糊半径 越大越模糊
spead-radius 阴影扩展半径 越大阴影越大
inset 向内投影 默认向外投影
color 阴影颜色

      .box {
        width: 200px;
        height: 200px;
        background-color: orange;
        box-shadow: 10px 10px 10px 10px inset #bfa;
      }

在这里插入图片描述
可以使用,设置多重阴影

      .box {
        width: 200px;
        height: 200px;
        background-color: orange;
        box-shadow: 4px 2px 1px 10px #bfa, 0px 0px 1px 10px #000, -4px -2px 10px inset blue;
      }

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_聪明勇敢有力气

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值