用css,我给你一篇代码,或与你能用到,我也是萌新,看不懂,只能你自己琢磨了。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>COCC Home</title>
<style>
body {
margin: 0;
padding: 0;
}
div {
position: absolute;
margin: 0 auto;
left: 653px;
top: 70px;
}
input {
position: absolute;
outline: none;
font-size: 20px;
border: 2px solid #4e6ef2;
border-radius:10px;
width: 185%;
height: 40px;
left: -75%;
top: 100%;
}
button {
position: absolute;
outline: none;
font-size: 15px;
border-radius:10px;
color: white;
background: #4e6ef2;
width: 25%;
height: 44px;
left: 113%;
top: 100%;
}
button:hover {
background: #2D5EE3;
}
</style>
<script>
window.onload = function (){
var oBtn = document.getElementsByTagName("button")[0];
var oTxt = document.getElementsByTagName("input")[0];
function click() {
if (oTxt.value == "") {
location.reload();
} else {
window.open("https://www.baidu.com/s?wd=" + oTxt.value);
}
}
oBtn.onclick = click;
oTxt.onkeydown = function(e) {
if (!e) e = window.event;
if (e.keyCode == 13) {
click();
}
}
}
</script>
</head>
<body>
<div>
<h1 style="font-size:350%">
COCC Home</h1>
<input type="text">
<button>Go</button>
</div>
<style tpye="text/css">
.代码{
position: absolute;
width:268px;
height:300px;
}
.代码 p{
position: absolute;
bottom: 0;
width:140%;
text-align:center;
}
</style>
<div class="代码">
<p>©COCC Home-2021(Mingwei Wei)</p>
</div>
</body>
</html>