gpt4 book ai didi

html - 为什么 span 和 outdiv 之间有 1px 的空间

转载 作者:太空宇宙 更新时间:2023-11-04 09:48:51 24 4
gpt4 key购买 nike

* {
margin: 0;
padding: 0;
}
.box {
width: 230px;
border: 1px solid red;
}
input {
width: 30px;
line-height: 20px;
background: #e5e5e5;
border: 0;
text-align: center;
padding: 0 5px;
font-size: 14px;
}
span {
padding: 0 2px;
cursor: pointer;
line-height: 20px;
font-size: 14px;
display: inline-block;
}
<div class="box">
<span>xx</span>
<input type="text" value="322xxx">

我想知道为什么span的底部和outdiv的底部之间有1px的空间?有人可以帮帮我吗?

最佳答案

您需要为 display: inline-block span 标签设置 vertical-align:top

*{
margin: 0;
padding: 0;
}
.box{
width: 230px;
border:1px solid red;
}
input{
width: 30px;
line-height: 20px;
background: #e5e5e5;
border: 0;
text-align: center;
padding: 0 5px;
font-size: 14px;
}
span{
padding: 0 2px;
cursor: pointer;
line-height:20px;
font-size: 14px;
display: inline-block;
vertical-align: top;
}
<div class="box">
<span>xx</span>
<input type="text" value="322xxx">

关于html - 为什么 span 和 outdiv 之间有 1px 的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39262685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com