首页 > 代码库 > 简易仿百度首页
简易仿百度首页
html:部分
<html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta name="description" content="百度一下 你就知道"> <meta name="keywords" content="百度一下 你就知道"> <title>百度搜索框</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="search"> <div class="search-logo"> <img src="https://www.baidu.com/img/bd_logo1.png" width="270px" height="129px" /> </div> <div class="searchBar"> <form id="searchForm"> <div class="searchTxt" id="searchTxt"> <input type="text" id="searchInput"> </div> <div class="searchBtn"> <input type="submit" value="百度一下"> </div> </form> </div> <p><a>1212,要爱要爱</a></p> <div class="suggest" id="search-suggest" style="display: none"> <ul> <li>搜索结果1</li> <li>搜索结果2</li> <li>搜索结果3</li> </ul> </div> </div> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="baidu.js" type="text/javascript"> </script> </body> </html>
css部分:
body, input, ul, li{ margin: 0; padding: 0; } body { font: 12px arial; } input { outline: none; border: none; } .search { width: 640px; margin: 0 auto; } .search-logo { margin-bottom: 30px; text-align: center; } .searchBar { width: 640px; height: 38px; } .searchTxt { float: left; border: 1px solid #3385ff; width: 540px; height: 36px; } .searchTxt input{ padding-left: 5px; width: 540px; height: 36px; } .searchBtn { float: right; width: 98; height: 38px; } .searchBtn input{ letter-spacing: 1; font-size: 14px; color: #fff; width: 98; height: 38px; background: #3385ff; cursor: pointer; } .search p { margin-top: 50px; text-align: center; color: #c9c9c9; font-size: 12px; } p a{ text-decoration: underline; } .suggest { width: 540px; border: 1px solid #3385ff; } .suggest ul { list-style: none; } .suggest ul li { padding: 3px; font-size: 14px; height: 25px; cursor: pointer; } .suggest ul li:hover { text-decoration: underline; background-color: #e5e5e5; }
js部分:
$(‘#searchInput‘).bind(‘keyup‘,function() { $(‘#search-suggest‘).show().css({ top:$(‘#searchTxt‘).offset().top + $(‘#searchTxt‘).height(), left:$(‘#searchTxt‘).offset().left, position:‘absolute‘ }); }) $(document).bind(‘click‘,function(){ $(‘#search-suggest‘).hide(); })
还有一些功能要添加,静候
简易仿百度首页
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。