HTML代码:
html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="css/search.css"/>
<script src="js/search.js"></script>
<script src="js/jquery-1.4.2.min.js"></script>
</head>
<body>
<!--
search-wrapper作为容器,用它来包裹和居中搜索框。在它里面是一个.input-holder子容器,它有固定的宽度,在它里面放置的是搜索框的占位文本和按钮。
search-input采用绝对定位,宽度为父容器的100%宽度。而搜索按钮则是右浮动的。
span.close元素,它用于制作关闭按钮。关闭按钮的小叉叉采用该元素的::before和::after伪元素来制作。
-->
<span onclick='window.open("https://en.wikipedia.org/wiki/Special:Random")' class="random">Click me to try random search</span>
<div class="search-wrapper">
<div class="input-holder">
<input type="text" class="search-input" onkeypress="if(event.keyCode==13){searchToggle(this, event)}" placeholder="Type to search" />
<button class="search-icon" onclick="searchToggle(this, event);"><span></span></button>
</div>
<span class="close" onclick="closeinput()"></span>
</div>
<span class="hint">Click icon to start search</span>
<div class="content">
<div class="sub"></div>
</div>
</body>
</html>
CSS代码&