gpt4 book ai didi

html - input 的边框比 div 的边框更细

转载 作者:可可西里 更新时间:2023-11-01 13:27:48 25 4
gpt4 key购买 nike

我目前有这个输入和 div 彼此相邻:

Input box with search button

如您所见,输入框的边框比包含搜索图标的 div 边框细得多。这是代码:

HTML

.location_input {
width: 150px;
height: 20px;
float: left;
padding-left: 3px;
display: inline-block;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
padding: 3px 15px;
font: normal 16px/normal"Open Sans", sans-serif;
-o-text-overflow: clip;
text-overflow: clip;
-webkit-transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1);
-moz-transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1);
-o-transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1);
transition: all 200ms cubic-bezier(0.42, 0, 0.58, 1);
margin-left: 6px;
position: relative;
top: 42%;
transform: translateY(-42%);
}

.update_location_wrapper {
float: left;
height: 30px;
width: 30px;
position: relative;
border-left: none;
display: inline-block;
background-color: none;
border-top: 1px solid #bbb;
border-right: 1px solid #bbb;
border-bottom: 1px solid #bbb;
position: relative;
top: 42%;
transform: translateY(-42%);
}
<input type='text' class='location_input' placeholder='Enter a location' id='location_input'>
<div class='update_location_wrapper'>
<div class='update_location_text'>
<img src="//i.imgur.com/0p5bSIO.png" alt="Search" height="20" width="20">
</div>
</div>

有没有办法让div的边框匹配输入边框?

最佳答案

由于输入边框在不同浏览器上看起来有些不同,您可以添加带边框的包装器,或者您可以这样做,增加输入的右侧填充并将搜索按钮移到其中。

.location_input {
width: 150px;
height: 20px;
float: left;
padding-left: 3px;
display: inline-block;
box-sizing: content-box;
padding: 3px 35px 3px 15px;
font: normal 16px/normal "Open Sans", sans-serif;
margin-left: 6px;
position: relative;
}

.update_location_wrapper{
margin-top: 4px;
margin-left: -25px;
float: left;
height: 30px;
width: 30px;
border-left: none;
display: inline-block;
position: relative;
}
<input type='text' class='location_input' placeholder='Enter a location' id='location_input'>
<div class='update_location_wrapper'>
<div class='update_location_text'><img src="http://placehold.it/20x20" alt="Search" height="20" width="20"></div>
</div>

关于html - input 的边框比 div 的边框更细,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34980827/

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