CSS border outline

作者: 微语博客 | 来源:发表于2021-06-19 22:52 被阅读0次

边框和轮廓

边框和轮廓是位于外边距内外的线框,有时候,设置边框和轮廓属性对于网页布局很有用,尤其是边框。

边框border

元素默认没有边框,当我们设置元素边框时显示,可以为边框设置大小,样式,颜色等属性,边框的复合属性是:border:width style color

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
    <style>
        *{margin: 0;padding: 0;box-sizing: border-box;}
        body{background-color: lightcyan;}
        .container{width: 100px;height: 100px;text-align: center;line-height: 100px;margin: 20px 20px;}
    </style>
</head>
<body>
    <!--边框大小颜色样式-->
    <div class="container" style="border: 1px solid orangered;">Hello World</div>
    <div class="container" style="border: 3px solid orange">Hello World</div>
    <div class="container" style="border: 2px dashed orangered">Hello World</div>
    <div class="container" style="border: 2px dotted orange">Hello World</div>
    <!--边框圆角-->
    <div class="container" style="border: 1px solid orangered;border-radius: 5px;">Hello World</div>
</body>
</html>

border属性设置边框,也可以单独设置某一边的边框,比如border-left等等。border-radius可以设置边框圆角,border-image也可以设置边框用图片填充。

轮廓outline

轮廓的设置和边框一样,轮廓是元素的外边界,轮廓复合属性是:outline:width style color

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
    <style>
        *{margin: 0;padding: 0;box-sizing: border-box;}
        body{background-color: lightcyan;}
        .container{width: 100px;height: 100px;text-align: center;line-height: 100px;margin: 20px 20px;}
    </style>
</head>
<body>
    <!--轮廓大小颜色样式-->
    <div class="container" style="outline: 1px solid orangered;">Hello World</div>
    <div class="container" style="outline: 3px solid orange">Hello World</div>
    <div class="container" style="outline: 2px dashed orangered">Hello World</div>
    <div class="container" style="outline: 2px dotted orange">Hello World</div>
    
</body>
</html>

轮廓设置基本上和边框一样,轮廓在边框和外边距之外。

相关文章

  • CSS border outline

    边框和轮廓 边框和轮廓是位于外边距内外的线框,有时候,设置边框和轮廓属性对于网页布局很有用,尤其是边框。 边框bo...

  • css outline 和 border

    outline 官方解释如下:https://developer.mozilla.org/zh-CN/docs/W...

  • outline与border

    1.outline属性: 2.outline与border对比:

  • CSS-笔记

    border与outline的区别 border 可应用于几乎所有有形的html元素,而 outline 是针对链...

  • outline 与 border

    定义和用法 outline (轮廓)是绘制于元素周围的一条线,位于边框边缘的外围,可起到突出元素的作用。(注意:轮...

  • outline & border

    outline CSS2出现,CSS3作了扩展,突出元素的作用 1.针对链接、表单控件和ImageMap等元素设计...

  • outline和border

    outline (轮廓)是绘制于元素周围的一条线,位于边框边缘的外围,可起到突出元素的作用。 只有在规定了 !do...

  • CSS阶段四:border,outline,padding,ma

    盒子模型 CSS中将每一个元素都设置为了一个矩形的盒子,是为了方便页面的布局。(一切皆为框) 基本构成:内容区,内...

  • css 制作小图标

    1. outline 制作方块和加号 outline 不占空间, 像 box-shadow, border-rad...

  • 解决移动端input框样式问题终极方案

    input{ border:none; outline:none; background-color:tr...

网友评论

    本文标题:CSS border outline

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