html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title> 搜索框 title>
<link rel="stylesheet" href="http://at.alicdn.com/t/font_1309180_m0vigzfu7y.css">
<style type="text/css">
.bod1
{
/*background: -webkit-linear-gradient(to right, #f7797d, #FBD786, #C6FFDD);*/
/*background-image: url(" 2558.jpg");*/
/*background-size:cover;*/
background: #aa4b6b; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #3b8d99, #6b6b83, #aa4b6b); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #3b8d99, #6b6b83, #aa4b6b); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.search-box
{
position: absolute;
top: 50%;
left: 50%;
transform: translate( -50%,-50%);
background: #FD2C6B;
height: 40px;
border-radius: 30px; /*圆角边框*/
padding: 10px;
}
.search-box:hover> .search-text
{
width: 400px;
}
.search-box:hover> .search-btn
{
background: white;
color: #26087b;
}
.search-btn
{
color: white;
float: right;
width: 40px;
height: 40px;
border-radius: 50%;
background:#FD2C6B;
display: flex;
justify-content: center;
align-items: center;
transition: 0.5s;
}
.search-text
{
border: none;
background: none;
outline: none;
float: left;
padding: 0;
color: white;
font-size: 20px;
font-family: "Microsoft YaHei UI Light";
transition: 0.5s;
line-height:40px;
width: 0px;
}
style>
head>
<body class="bod1">
<div class="search-box">
<input class="search-text" name="inputs" value="点我是想老公亲亲嘛qwq">
<a class="search-btn" href="#">
<i class="iconfont iconchazhao">i>
a>
div>
body>
html>
搜索引擎?是要输入会显示联想词吗?去网上找个联想词api发送请求就行
自己写点假数据,然后用indexof往出匹配吧,要不还得搞接口
这样?
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title> 搜索框 </title>
<link rel="stylesheet" href="http://at.alicdn.com/t/font_1309180_m0vigzfu7y.css">
<style type="text/css">
.bod1
{
/*background: -webkit-linear-gradient(to right, #f7797d, #FBD786, #C6FFDD);*/
/*background-image: url(" 2558.jpg");*/
/*background-size:cover;*/
background: #aa4b6b; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #3b8d99, #6b6b83, #aa4b6b); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #3b8d99, #6b6b83, #aa4b6b); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.search-box
{
position: absolute;
top: 50%;
left: 50%;
transform: translate( -50%,-50%);
background: #FD2C6B;
height: 40px;
border-radius: 30px; /*圆角边框*/
padding: 10px;
}
.search-box:hover> .search-text
{
width: 400px;
}
.search-box:hover> .search-btn
{
background: white;
color: #26087b;
}
.search-btn
{
color: white;
float: right;
width: 40px;
height: 40px;
border-radius: 50%;
background:#FD2C6B;
display: flex;
justify-content: center;
align-items: center;
transition: 0.5s;
}
.search-text
{
border: none;
background: none;
outline: none;
float: left;
padding: 0;
color: white;
font-size: 20px;
font-family: "Microsoft YaHei UI Light";
transition: 0.5s;
line-height:40px;
width: 0px;
}
#list {
position: absolute;
top: 55%;
left: 48%;
<!-- background: #FD2C6B;-->
}
.animals {
font-size: 20px
}
</style>
</head>
<body class="bod1">
<div class="search-box">
<input class="search-text" name="inputs" placeholder="Search animals.." type="text" onkeyup="search_animal()" id="searchbar">
<a class="search-btn" href="#">
<i class="iconfont iconchazhao"></i>
</a>
</div>
<ol id='list'>
<li class="animals">猫</li>
<li class="animals">狗</li>
<li class="animals">男人</li>
<li class="animals">基佬</li>
<li class="animals">女人</li>
<li class="animals">金钱</li>
<li class="animals">苹果</li>
<li class="animals">女人</li>
<li class="animals">基佬</li>
<li class="animals">男人</li>
<li class="animals">老公</li>
</ol>
<script type="text/javascript">
function search_animal() {
let input = document.getElementById('searchbar').value
<!-- alert(input)-->
input=input.toLowerCase();
let x = document.getElementsByClassName('animals');
for (i = 0; i < x.length; i++) {
if (!x[i].innerHTML.toLowerCase().includes(input)) {
x[i].style.display="none";
}
else {
x[i].style.display="list-item";
}
}
}
</script>
</body>
</html>
iframe内嵌页面应该可以满足你的需求,可以参考这里:https://blog.csdn.net/cainiaoyihao_/article/details/115908633?