css盒模型的border

lunabird 2015-06-12 08:21:48
这是代码:

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>Stylin' with CSS - Figure 3.4 Box Padding</title>
<style>
p {font:16px helvetica, sans-serif; width:220px; border:2px solid red; background-color:#caebff;}
</style>
</head>

<body>
<p>Here is a short paragraph of text. Without any padding, the text can touch the border on all four sides, which gives the layout a very crowded appearance. It's not something you really want to read.</p>



</body>
</html>



设置的 border:2px,但是在火狐浏览器中显示盒模型的时候是这样的?



为什么文本的width设置成220变成222了,还有border设置的2px变成1px了?
...全文
143 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lunabird 2015-06-12
  • 打赏
  • 举报
回复
在chorme中是正确的,为什么火狐不对呢?
KK3K2005 2015-06-12
  • 打赏
  • 举报
回复
*{ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } 你大概是想要这个

61,115

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧