我是靠谱客的博主 成就康乃馨,这篇文章主要介绍html搜索框怎么设置?html搜索框input标签的使用方法实例,现在分享给大家,希望可以做个参考。

本篇文章主要讲述的是关于HTML 搜索框的设置,还有html 搜索框input标签的一些使用方法实例,接下来就让我们一起来阅读这篇关于html 搜索框的文章吧

首先我们来设置一个简单的搜索框:

复制代码
1
<input type="text" class="aa"><input type="button" value="搜索" class="bb">
登录后复制

这是一个最简单样式的搜索框,没有很复杂的样式。如果需要设计样式可以根据class="aa"来写样式,.aa{}在括号中添加代码即可,当然这是框的样式,按钮的样式.bb{}在括号中填写代码即可。在浏览器中显示的效果如图:

tuyi.png

这就是一个简单的搜索框的代码。

现在说说input标签的使用方法,先看个实例

我们来看点更高深的搜索框完整的代码:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>靠谱客</title> <meta name="description" content=""> <meta name="keywords" content=""> <link href="" rel="stylesheet"> <style type="text/css"> #box{ width: 380px; margin: 30px auto; font-family: 'Microsoft YaHei'; font-size: 14px; } input{ width: 260px; border: 1px solid #e2e2e2; height: 30px; float: left; background-image: url(images/search.jpg); background-repeat: no-repeat; background-size: 25px; background-position:5px center; padding:0 0 0 40px; } #search{ width: 78px; height: 32px; float: right; background: black; color: white; text-align: center; line-height: 32px; cursor: pointer; } </style> </head> <body> <div id="box"> <input type="text" name="search" placeholder="请输入关键字"> <div id="search">搜索</div> </div> </body> </html>
登录后复制

这个代码看效果图:

tuer.png

这个效果就比第一个好看太多了,就是多了点代码,都是基础的css样式的知识,如果有不懂的可以在下方留言。

注意: <input> 元素是空的,它只包含标签属性。

提示: 你可以使用 <label> 元素来定义 <input> 元素的标注。

好了,以上就是关于我们这篇关于html input标签的用法,有问题的可以在下方留言。

【小编推荐】

html空格代码怎么写?html空格代码的表现方式总结

html下拉菜单怎么做?html下拉菜单的代码实例介绍

以上就是html搜索框怎么设置?html搜索框input标签的使用方法实例的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是成就康乃馨最近收集整理的关于html搜索框怎么设置?html搜索框input标签的使用方法实例的全部内容,更多相关html搜索框怎么设置?html搜索框input标签内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(173)

评论列表共有 0 条评论

立即
投稿
返回
顶部