【发布时间】:2017-07-21 07:49:28
【问题描述】:
谁能解释这种奇怪的行为,为什么在按钮之间添加额外的间距。
案例-
以下是 HTML 代码,如果这样写,它会在按钮之间添加额外的空间 -
<div class="wrapper">
<button class="btn one">First long button with a long text length</button>
<button class="btn two">Second long button with a long text length</button>
</div>
输出 -
但是如果我这样写,那么就没有空间了-
代码 -
<div class="wrapper">
<button class="btn one">First long button with a long text length</button><button class="btn two">Second long button with a long text length</button>
</div>
输出 -
CSS 代码 -
* {
margin: 0;
padding: 0;
}
.wrapper {
padding: 10px;
}
.btn {
font-size: 14px;
line-height: 28px;
background: #FFFFFF;
border: 1px solid #C3C3C3;
position: relative;
padding: 10px;
display: inline;
}
.btn:before {
content: "";
position: absolute;
width: 4%;
height: 5px;
background: #FFF;
right: 0px;
top: -5px;
}
.two {
display: inline;
}
【问题讨论】:
标签: html css whitespace