html - 如何删除此搜索框中的多余空格(输入字段和按钮之间)
问题描述
在此图像中,您可以在输入字段和搜索按钮之间看到一个可见的额外空间。我想删除这个空间并使它们关闭。如果我在编码中的某个地方出错,请告诉我解决方案。我该如何克服这个问题?
而且,这是我的代码:
input[type=text].search_input {
width: 350px;
height: 40px;
font-size: 16px;
background-color: white;
background-image: url('assets/imgs/asd.png');
background-position: 7px 4.5px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
border-top:2px solid #0073f5;
border-left:2px solid #0073f5;
border-bottom: 2px solid #0073f5;
border-right: 0px solid #0073f5;
outline: none;
font-size: 16px;
box-sizing: border-box;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
.search {
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
border-top:2px solid #0073f5;
border-left:2px solid #0073f5;
border-bottom: 2px solid #0073f5;
border-right: 0px solid #0073f5;
padding: 0px 19px 0px 19px;
width: 110px;
height: 40px;
font-size: 16px;
background:#0073f5;
outline: none;
color : white;
cursor: pointer;
}
<form action="search.php" method="GET">
<input class="search_input" id="search" type="text" name="q">
<button class="search" type="submit">SEARCH</button>
</form>
解决方案
我只想添加display: flex
到form
元素:
form {
display: flex;
}
input[type=text].search_input {
width: 350px;
height: 40px;
font-size: 16px;
background-color: white;
background-image: url('assets/imgs/asd.png');
background-position: 7px 4.5px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
border-top: 2px solid #0073f5;
border-left: 2px solid #0073f5;
border-bottom: 2px solid #0073f5;
border-right: 0px solid #0073f5;
outline: none;
font-size: 16px;
box-sizing: border-box;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
.search {
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
border-top: 2px solid #0073f5;
border-left: 2px solid #0073f5;
border-bottom: 2px solid #0073f5;
border-right: 0px solid #0073f5;
padding: 0px 19px 0px 19px;
width: 110px;
height: 40px;
font-size: 16px;
background: #0073f5;
outline: none;
color: white;
cursor: pointer;
}
<form action="search.php" method="GET">
<input class="search_input" id="search" type="text" name="q">
<button class="search" type="submit">SEARCH</button>
</form>
推荐阅读
- python - 尝试设置 django 会话值时,我有类型错误“十进制类型的对象不是 JSON 可序列化的”,而它是一个字符串值。为什么?
- python - 我正在使用 Python 制作 Hangman 游戏,但我不知道我的代码有什么问题
- google-analytics - 检测到多个安装的全局网站代码 (gtag.js)
- php - 如何在 PHP 中查询不同的 GET 请求
- flutter - 坏状态:使用flutter html渲染html文本时没有元素
- react-native - react native使用底部导航时如何跟踪屏幕标题?
- javascript - Javascript 你可能需要一个额外的加载器
- asp.net-core - 通过依赖注入从asp .net核心中的Redis缓存中获取所有键
- r - 为什么我的 RMarkdown 分页编辑器中的每个表格,而不是针织文档 (HTML)
- mysql - 无法连接 mysql - Web 应用程序