【发布时间】:2020-05-25 05:15:24
【问题描述】:
我找不到将我的输入字段(搜索框)及其相关图标(放大镜)设置为 float 的方法,位于我网站导航栏的右侧(同时将我的徽标留在左侧的导航)。有什么建议吗?
HTML:
<nav>
<div class="nav-container">
<div class="logo">
<a href="">
<h1>MyWebsiteName.com</h1>
</a>
</div>
<form action="javascript:redirect()" autocomplete="off">
<input type="search" name="search" id="search" class="form-control">
<ul class=mylist list-group" id="result"></ul> <!--this line is for JS-->
<button type="submit">
<svg width="50" height="50" viewBox="0 0 77 77" fill="none"
xmlns="http://www.w3.org/2000/svg">
</svg> </button>
</form>
</div>
</nav>
CSS:
.nav-container {
display: flex;
align-items: center;
padding: 16px 0;
position: relative;
}
.nav-container form {
display: flex;
align-items: center;
justify-content: center;
}
nav input {
font-size: 1.20em;
border: solid 2px #E5E5E5;
border-radius: 25px;
background: none;
color: #F4F4F4;
padding: 14px;
margin: 0 20px 0 0;
width: 260px;
}
form {
float: right;
}
【问题讨论】:
-
可能是......如果没有看到你完成的 css,我们不确定。
-
抱歉,刚刚添加了CSS! @Manjuboyz
-
感谢分享css,你有答案了:)
标签: html css input flexbox css-float