Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
css中内边框是什么_创想鸟

css中内边框是什么

css中,内边框是用box-sizing属性设置的,只需要给元素添加“box-sizing:border-box;”样式即可。box-sizing属性值为border-box,表示指定宽度和高度确定元素边框。

css中内边框是什么

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

下面我们先来看看css设置内边框的示例。

                div.container {        width: 30em;        height: 106px;        border: 1em solid;      }      div.box1 {        width: 50%;        border: 1em solid red;        float: left;      }      div.box2 {        box-sizing: border-box;        -moz-box-sizing: border-box;        /* Firefox */        width: 50%;        border: 1em solid red;        float: left;      }            
普通边框!!
内边框!!

3C@}2UN7]ANXD)P0A4CP@5U.png

box-sizing属性

立即学习“前端免费学习笔记(深入)”;

box-sizing 属性允许您以特定的方式定义匹配某个区域的特定元素。

例如,假如您需要并排放置两个带边框的框,可通过将 box-sizing 设置为 “border-box”。这可令浏览器呈现出带有指定宽度和高度的框,并把边框和内边距放入框中。

语法

box-sizing: content-box|border-box|inherit;

属性值:

content-box:这是 CSS2.1 指定的宽度和高度的行为。指定元素的宽度和高度(最小/最大属性)适用于box的宽度和高度。元素的填充和边框布局和绘制指定宽度和高度除外

border-box:指定宽度和高度(最小/最大属性)确定元素边框。也就是说,对元素指定宽度和高度包括了 padding 和 border 。通过从已设定的宽度和高度分别减去边框和内边距才能得到内容的宽度和高度。

inherit:指定 box-sizing 属性的值,应该从父元素继承。

示例:

                div.container {        width: 30em;        height: 74px;        border: 1em solid;      }      div.box {        box-sizing: border-box;        -moz-box-sizing: border-box; /* Firefox */        width: 50%;        border: 1em solid red;        float: left;      }            
这个 div 占据了左边的一半。
这个 div 占据了右边的一半。

效果图:

ME}1QS_X0V78T7S2X@F2985.png

以上就是css中内边框是什么的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1620469.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
css怎样将li的序号取消
上一篇 2025年12月24日 07:09:24
css中如何定义使用变量
下一篇 2025年12月24日 07:09:29

相关推荐

发表回复

登录后才能评论
关注微信