将百度搜索嵌入自己的html网页(美化版)

时间:2021-07-25 09:31:03   收藏:0   阅读:14

网页添加百度搜索(已美化)

html5添加百度搜索引擎

 

话不多说直接上代码

下面是CSS美化代码

<style type="text/css">
.login-button { /* 按钮美化 */
width: 270px; /* 宽度 */
height: 40px; /* 高度 */
border-width: 0px; /* 边框宽度 */
border-radius: 3px; /* 边框半径 */
background: #1E90FF; /* 背景颜色 */
cursor: pointer; /* 鼠标移入按钮范围时出现手势 */
outline: none; /* 不显示轮廓线 */
font-family: Microsoft YaHei; /* 设置字体 */
color: white; /* 字体颜色 */
font-size: 17px; /* 字体大小 */
}

.login-button:hover { /* 鼠标移入按钮范围时改变颜色 */
background: #5599FF;
}

.text-frame{width:400px; height:40px;} 
</style>

下面是添加百度搜索代码

<body>
    <div style="text-align:center">
        <form action="https://www.baidu.com/s">
        <input type="text" class="text-frame" name="wd">
        <input type="submit" class="login-button" value="百度一下">
        </form>
    </div>
</body>

以上是完整代码

技术分享图片

效果请自行测试

测试网站 将源码直接复制粘贴即可

代码思路

 

技术分享图片

 

打开https://www.baidu.com,F12查看源码

可以看出

1.form 的 action="/s",表示数据提交到https://www.baidu.com/s

2.输入框的name=“wd”

 

知道了输入框的name及数据提交到哪儿,就可以实现了,代码如下:

<form action="https://www.baidu.com/s">
<input type="text" name="wd">
<input type="submit" value="百度一下">
</form>

效果如下

所以添加CSS美化代码

<style type="text/css">
.login-button { /* 按钮美化 */
width: 270px; /* 宽度 */
height: 40px; /* 高度 */
border-width: 0px; /* 边框宽度 */
border-radius: 3px; /* 边框半径 */
background: #1E90FF; /* 背景颜色 */
cursor: pointer; /* 鼠标移入按钮范围时出现手势 */
outline: none; /* 不显示轮廓线 */
font-family: Microsoft YaHei; /* 设置字体 */
color: white; /* 字体颜色 */
font-size: 17px; /* 字体大小 */
}

.login-button:hover { /* 鼠标移入按钮范围时改变颜色 */
background: #5599FF;
}

.text-frame{width:400px; height:40px;} 
</style>

并将css美化class添加到input框内

<input type="text" class="text-frame" name="wd">
<input type="submit" class="login-button" value="百度一下">

欢迎光临我的小站呀 ????我的小破站

 

原文:https://www.cnblogs.com/zhuzhushop/p/15056619.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!