html百度搜索框代码
时间: 2023-08-12 22:07:55 浏览: 52
以下是一个简单的 HTML 百度搜索框代码:
```html
<form action="https://www.baidu.com/s">
<input type="text" name="wd" placeholder="请输入搜索关键词">
<button type="submit">搜索</button>
</form>
```
其中,`action` 属性指定搜索表单提交的地址,`input` 标签的 `name` 属性指定搜索关键词的参数名,`placeholder` 属性设置搜索框的占位文本,`button` 标签用于提交搜索表单。
相关问题
软件测试百度搜索框代码
以下是百度搜索框的代码,其中id为kw:
```html
<input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off">
```
如果要使用Python的selenium库来定位百度搜索框,可以使用以下代码:
```python
from selenium import webdriver
# 启动浏览器
browser = webdriver.Chrome()
# 打开百度首页
browser.get('https://www.baidu.com')
# 定位搜索框并输入关键字
input_box = browser.find_element_by_id('kw')
input_box.send_keys('软件测试')
# 提交搜索
submit_button = browser.find_element_by_id('su')
submit_button.click()
```
制作百度首页搜索栏的布局代码
下面是一个制作百度首页搜索栏布局的示例代码:
```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>百度首页</title>
<style>
.header {
height: 80px;
background-color: #fff;
border-bottom: 1px solid #ebebeb;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
width: 120px;
height: 60px;
background-image: url(logo.png);
background-repeat: no-repeat;
background-size: contain;
}
.search {
width: 500px;
height: 42px;
background-color: #f5f5f5;
border: 1px solid #ebebeb;
border-radius: 20px;
display: flex;
align-items: center;
padding: 0 20px;
}
.search-input {
flex: 1;
border: none;
background: none;
outline: none;
font-size: 16px;
}
.search-btn {
width: 80px;
height: 42px;
background-color: #3385ff;
border: none;
border-radius: 20px;
color: #fff;
font-size: 16px;
cursor: pointer;
margin-left: 10px;
}
</style>
</head>
<body>
<header class="header">
<div class="logo"></div>
<form class="search">
<input class="search-input" type="text" placeholder="请输入搜索内容">
<button class="search-btn" type="submit">搜索</button>
</form>
</header>
</body>
</html>
```
在上面的代码中,我们使用了Flex布局来实现头部的对齐,搜索框使用了圆角边框和阴影效果,搜索按钮使用了蓝色背景和白色文字。该布局可以在PC和移动设备上都有良好的表现。