用户:
楊錦和jrf6查看:0 回复:2 评论:0 创建时间:2023-02-01T21:03:35
Html
<!--版本:0.1.1-->
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta http-equiv="Window-target" content="_top">
<title>深谷搜索引擎</title>
<link rel="stylesheet" type="text/css" href="../CSS/Style.css">
<link rel="shortcut Icon" type="image/x-icon" href="../IMG/favicon.ico" media="screen">
</head>
<body>
<section>
<div class="main">
<div class="PageName">
<header>
<h1 class="one">深</h1>
<h1 class="two">谷</h1>
<h1 class="three">浏览器</h1>
</header>
</div>
<div class="searchBox">
<div class="search">
<ion-icon name="search-outline"></ion-icon>
</div>
<div class="searchInput">
<input type="text" name="searchInput" placeholder="深谷搜索" class="query" value="" id="input">
</div>
<div class="close">
<ion-icon name="close-outline"></ion-icon>
</div>
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.e喵.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
</div>
<div class="button">
<button class="searchBtn">深谷搜索</button>
</div>
<script type="text/javascript" src="../JS/Search Box.js"></script>
</div>
</section>
</body>
</html>
Style
@import url("https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;700&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Ubuntu', sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(45deg, #4E65FF, #92EFFD);
}
button {
display: block;
margin: 0 auto;
height: 40px;
}
ion-icon {
color: #000000;
}
input {
border: 0px;
outline: none;
background-color: #FFFFFF;
color: #000000;
}
input::-webkit-input-placeholder {
color: #808080;
}
header {
display: flex;
}
h1 {
font-size: 72px;
margin-top: -200px;
font-weight: normal;
}
h1.one {
color: #7CFC00;
}
h1.two {
color: #FFD700;
}
h1.three {
color: #FFA500;
}
section .main {
width: 580px;
margin: 0 20px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.searchBox {
position: relative;
width: 60px;
height: 60px;
background: #ffffff;
display: flex;
justify-content: space-between;
transition: 0.5s;
overflow: hidden;
box-shadow: 0 25px 35px rgba(0, 0, 0, 0.1);
}
.searchBox.active {
width: 360px;
}
.searchBox .search {
position: relative;
min-width: 60px;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
justify-content: center;
font-size: 1.5em;
cursor: pointer;
}
.searchBox .close {
position: relative;
width: 60px;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
font-size: 1.25em;
scale: 0;
transition: 0.5s;
}
.searchBox.active .close {
scale: 1;
transition-delay: 0.5s;
}
.searchBox .searchInput {
position: absolute;
left: 60px;
width: calc(100% - 120px);
height: 100%;
line-height: 60px;
}
.searchBox .searchInput input {
position: absolute;
width: 100%;
height: 100%;
border: none;
outline: none;
font-size: 1.5em;
}
JS
let search = document.querySelector('.search');
let close = document.querySelector('.close');
let searchBox = document.querySelector('.searchBox');
search.onclick = function(){
searchBox.classList.add('active');
}
close.onclick = function(){
searchBox.classList.remove('active');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
let query = document.querySelector('.query');
let searchBtn = document.querySelector('.searchBtn')
searchBtn.onclick = function(){
let url = 'https://www.so.com/s?q='+query.value;
window.open(url, '_self');
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
img
"""由于编程猫不支持.ico文件,所以请大家将<link rel="shortcut Icon">直接删掉就行。"""