HTML如何定义搜索栏

HTML定义搜索栏的方法:首先新建一个div,id名为Box;然后在内部添加一个input标签一个div标签;最后使用css为它们设计样式即可。

本教程操作环境:windows7系统、html5版,DELL G3电脑。

HTML定义搜索栏的方法

1、首先新建一个div,id名为Box,用来包裹搜索框;

2、然后在内部添加一个input标签一个div标签一个用来输入文字一个充当按钮;

3、最后使用css为它们设计样式即可。

<!DOCTYPE html>
<html>
<head>
<Meta charset=utf-8>
<Meta http-equiv=X-UA-Compatible content=IE=edge,chrome=1>
<title>Examples</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=search name=search placeholder=请输入关键字>
        <div id=search>搜索</div>
    </div>
</body>
</html>

相关学习推荐:html视频教程

相关文章

Mip是什么意思以及作用有哪些
怎么测试Mip页面运行情况
MIP安装的具体步骤有哪些
HTML添加超链接、锚点的方法及作用详解(附视频)
MIP的规则有哪些
Mip轮播图组件中的重要属性讲解