在网页设计中,搜索框是一个非常重要的元素,它可以提高网站的可用性和用户体验。而为了实现一个漂亮的搜索框,CSS是一个不可忽视的工具。首先,我们需要为搜索框创造一个容器。使用以下代码创建一个搜索框容器:...
在网页设计中,搜索框是一个非常重要的元素,它可以提高网站的可用性和用户体验。而为了实现一个漂亮的搜索框,CSS是一个不可忽视的工具。
首先,我们需要为搜索框创造一个容器。使用以下代码创建一个搜索框容器:
<div class="search">
<input type="text" placeholder="Search">
<button type="submit">Go</button>
</div> .search {
width: 320px;
margin: 0 auto;
text-align: center;
} input[type="text"] {
width: 250px;
height: 34px;
padding: 6px 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button[type="submit"] {
height: 34px;
padding: 6px 12px;
background-color: #428bca;
border: none;
color: #fff;
border-radius: 4px;
}