美文网首页
十九、圆角边框&盒子阴影

十九、圆角边框&盒子阴影

作者: honest涛 | 来源:发表于2021-02-22 08:22 被阅读0次

一、 圆角边框(重点)

在CSS3中,新增了\color{red}{圆角边框}样式,这样我们的盒子就可以变圆角了。

image.png
\color{red}{border-radius}属性用于设置元素的外边框圆角。

语法:
border-radius:length;

\color{red}{radius半径(圆的半径)原理:}(椭)圆与边框的交集形成圆角效果。

圆角边框.png
  • 参数值可以为\color{red}{数值}\color{red}{百分比}的形式;
  • 如果是\color{red}{正方形},想要设置为一个圆,把数值修改为\color{red}{高度或宽度的一半}即可,或者直接写为50%;
  • \color{red}{如果是个矩形,设置为高度的一半就可以了。}
  • 该书属性是一个\color{red}{简写属性},可以跟四个值,分别代表\color{red}{左上角、右上角、右下角、左下角}
  • 分开写:\color{red}{border-top-left-radius、border-top-right-radius、border-bottom-right-radius、border-bottom-left-radius}

二、盒子阴影(重点)

CSS3中新增了盒子阴影,我们可以使用\color{red}{box-shadow}属性为盒子添加阴影。

语法:
box-shadow: h-shadow v-shadow blur spread color inset;

描述
h-shadow 必需。水平阴影的位置。允许负值。
v-shadow 必需。垂直阴影的位置。允许负值。
blur 可选。模糊距离。
spread 可选。阴影的尺寸。
color 可选。阴影的颜色。
inset 可选。将外部阴影(outset)改为内部阴影。

\color{red}{注意:}
\color{red}{1.默认的是外阴影(outset),但是不可以写这个单词,否则导致阴影无效。}
\color{red}{2.盒子阴影不占用空间,不会影响其他盒子排列。}

三、文字阴影

在CSS3中,我们可以使用\color{red}{text-shadow}属性将阴影应用于文本。

语法:
text-shadow: h-shadow v-shadow blur color;

描述
h-shadow 必需。水平阴影的位置。允许负值。
v-shadow 必需。垂直阴影的位置。允许负值。
blur 可选。模糊距离。
color 可选。阴影的颜色。

四、案例

image.png
<!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>
        .one {
            width: 300px;
            height: 100px;
            background-color: pink;
            border-radius: 10px;
        }
        .two {
            width: 200px;
            height: 200px;
            background-color: pink;
            border-radius: 50%;
        }
        .three {
            width: 200px;
            height: 100px;
            background-color: pink;
            border-radius: 50px;
        }
        .four {
            width: 200px;
            height: 100px;
            background-color: pink;
            border-radius: 10px 15px 20px 25px;
        }
    </style>
</head>
<body>
    <div class="one"></div>
    <h4>1.圆形的做法</h4>
    <div class="two"></div>
    <h4>2.圆角矩形的做法</h4>
    <div class="three"></div>
    <h4>3.可以设置不同的圆角</h4>
    <div class="four"></div>
</body>
</html>

相关文章

  • 十九、圆角边框&盒子阴影

    一、 圆角边框(重点) 在CSS3中,新增了样式,这样我们的盒子就可以变圆角了。 属性用于设置元素的外边框圆角。 ...

  • CSS3基础

    CSS3基础 -- 边框 圆角效果 向元素添加圆角边框 阴影 box-shadow 向盒子添加阴影。支持一个或者...

  • CSS3

    概述 CSS2新特性文本阴影鼠标悬停的动态效果边框圆角盒子阴影盒子倾斜。。。等等浏览器 圆角边框 水平偏移与垂直偏...

  • Flutter-Border

    边框(Border) 单侧边框 全部边框 圆角(borderRadius) 全部圆角 单侧圆角 阴影(BoxSha...

  • Image

    直接圆角图片 设置圆角图片度数 设置圆角图片带灰色圆角边框 设置圆角图片带灰色圆角边框带阴影

  • 常用CSS3 一目了然

    1.css3边框 圆角边框 border-radius: 5px;(圆角半径) 边框阴影 box-shadow: ...

  • flutter 控件添加阴影圆角边框

    快速添加阴影圆角边框代码

  • CSS3

    边框 border-radius - 圆角边框 box-shadow - 边框阴影 border-image - ...

  • CSS3边框,背景,渐变,过渡,2d变换

    01-边框圆角.html 02-圆角应用.html 03-边框阴影.html 04-边框图片.html 01-背景...

  • CSS3新增样式

    边框圆角border-radius边框阴影box-shadow(x水平向右的阴影度,y垂直向下的阴影度,color...

网友评论

      本文标题:十九、圆角边框&盒子阴影

      本文链接:https://www.haomeiwen.com/subject/vqwqfltx.html