styele里写css页面中间放一个搜索框 搜索框右边是蓝色按钮
时间: 2024-05-16 14:13:59 浏览: 14
你可以这样写:
HTML 代码:
```html
<div class="search-box">
<input type="text" placeholder="搜索...">
<button class="btn-blue">搜索</button>
</div>
```
CSS 代码:
```css
.search-box {
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
max-width: 400px;
}
input[type="text"] {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px 0 0 5px;
width: 100%;
font-size: 16px;
}
.btn-blue {
background-color: blue;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 0 5px 5px 0;
font-size: 16px;
cursor: pointer;
}
```
这里用了 flexbox 布局,将搜索框和按钮放在一起,并居中显示。搜索框的样式为灰色边框和圆角左侧,按钮的样式为蓝色背景和白色字体。