注意:所有显示要居中!切换搜索引擎按钮可以切换20款搜索引擎,不是对话框
时间: 2024-05-22 13:15:53 浏览: 92
中的输入框。
<html>
<head>
<title>搜索引擎</title>
<style>
body {
text-align: center;
font-family: Arial, sans-serif;
}
h1 {
margin-top: 50px;
font-size: 36px;
font-weight: bold;
}
form {
margin-top: 50px;
}
input[type="text"] {
padding: 10px;
width: 400px;
border-radius: 5px;
border: none;
box-shadow: 0 0 5px #ccc;
font-size: 18px;
outline: none;
}
input[type="submit"] {
padding: 10px 20px;
background-color: #4285f4;
color: #fff;
border: none;
border-radius: 5px;
font-size: 18px;
cursor: pointer;
transition: background-color 0.3s;
}
input[type="submit"]:hover {
background-color: #3367d6;
}
button {
margin: 20px 5px;
padding: 10px 20px;
background-color: #fff;
color: #4285f4;
border: none;
border-radius: 5px;
font-size: 18px;
cursor: pointer;
outline: none;
box-shadow: 0 0 5px #ccc;
transition: background-color 0.3s;
}
button.active {
background-color: #4285f4;
color: #fff;
}
button:hover {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>搜索引擎</h1>
<form action="#" method="get">
<input type="text" name="q" placeholder="请输入搜索内容">
<input type="submit" value="搜索">
</form>
<div>
<button class="active">Google</button>
<button>Bing</button>
<button>百度</button>
<button>搜狗</button>
<button>360搜索</button>
<button>好搜</button>
<button>谷歌学术</button>
<button>必应学术</button>
<button>知网</button>
<button>百度学术</button>
<button>豆瓣</button>
<button>淘宝</button>
<button>京东</button>
<button>天猫</button>
<button>苏宁</button>
<button>唯品会</button>
<button>当当</button>
<button>新浪微博</button>
<button>微信公众号</button>
</div>
<script>
var buttons = document.querySelectorAll('button');
var form = document.querySelector('form');
buttons.forEach(function(button) {
button.addEventListener('click', function() {
buttons.forEach(function(btn) {
btn.classList.remove('active');
});
button.classList.add('active');
form.action = 'https://www.' + button.innerHTML.toLowerCase() + '.com/search';
});
});
</script>
</body>
</html>
阅读全文