html百度搜索框代码
时间: 2023-06-25 08:02:24 浏览: 174
以下是一个简单的HTML代码示例,用于在页面上显示一个百度搜索框:
```
<form action="http://www.baidu.com/s" method="get" target="_blank">
<input type="text" name="wd" placeholder="请输入搜索关键字">
<button type="submit">搜索</button>
</form>
```
其中,`action` 属性指定了表单提交的URL,在这里设置为百度搜索的URL;`method` 属性指定了表单提交的方式,这里使用GET方法;`target` 属性指定了表单提交后打开的页面,设置为 `_blank` 表示在新标签页中打开搜索结果。`input` 标签定义了一个文本输入框,`name` 属性为 `wd` ,对应了百度搜索的关键字参数;`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和移动设备上都有良好的表现。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)