【问题标题】:Why does changing left-margin of a span increase the width of the span's content box?为什么更改跨度的左边距会增加跨度内容框的宽度?
【发布时间】:2022-11-18 01:58:42
【问题描述】:

话不多说,来看看:

跨度没有左边距

body {
  background-color: red;
}

span {
  background-color: green;
  margin-left: 0px;
}
<span>text<span>

箱体型号:

跨距为 100px 左边距

body {
  background-color: red;
}

span {
  background-color: green;
  margin-left: 100px;
}
<span>text<span>

箱体型号:

为什么当我将 span 的左边距从 0px 更改为 100px 时,内容框的宽度会发生变化?

【问题讨论】:

  • 我给你做了 sn-ps 并将错字从 left-margin 改成了 margin-left

标签: html css width margin margin-left


【解决方案1】:

*{
    margin: 0;
    padding: 0;
}
body {
    background-color: red;
}

span {
    background-color: green;
}
<span>text</span>

【讨论】:

    猜你喜欢
    • 2015-03-03
    • 1970-01-01
    • 1970-01-01
    • 2011-05-02
    • 2020-02-19
    • 1970-01-01
    • 2012-07-08
    • 1970-01-01
    • 2016-09-11
    相关资源
    最近更新 更多