gpt4 book ai didi

css - 背景颜色不覆盖页面

转载 作者:行者123 更新时间:2023-12-04 21:57:43 25 4
gpt4 key购买 nike

您可以查看我的小网站here。我有两个问题:


我使用CSS渐变为背景着色。当使用高分辨率(例如1366 * 768)时,仅画了一半的页面。
我在底部的“ andale”按钮没有倾斜。在检查代码时,我注意到包含按钮的<div>覆盖了容器,我不知道为什么。


另外,如果您不喜欢jsFiddle,这是我的代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Rock-paper-scissers</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script src="rps.js"></script>
<style type="text/css">
body{
height: 100%;
font: 100.01% "Trebuchet MS",Verdana,Arial,sans-serif;
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#93e1d1), to(#d4c87c));
background-image: -webkit-linear-gradient(left, #93e1d1, #d4c87c);
background-image: -moz-linear-gradient(top, #93e1d1, #d4c87c);
background-repeat: no-repeat;
}
div#container {
text-align: center;
width: 80%;
margin: 0 auto;
}
div.InnerLeft {
width: 50%;
position: relative;
float: left;
}
div.InnerRight {
width: 50%;
position: relative;
float: right;
}
select {
background: transparent;
margin-top: 15px;
width: 220px;
font-size: 16px;
-webkit-appearance: none;
border: 0px;
height: 34px;
}
</style>
</head>
<body>
<div id="container">
<img src="header.png">
<div class="InnerLeft">
<img src="uno.png"><br>
<select id="p1" onchange="change('p1','rpsleft')">
<option value=0>Choose your weapon</option>
<option value=1>Rock</option>
<option value=2>Paper</option>
<option value=3>Scissors</option>
</select>
<p><img src="rpsL.png" id="rpsleft"></p>
</div>
<div class="InnerRight">
<img src="dos.png"><br>
<select id="p2" onchange="change('p2','rpsright')">
<option value=0>Choose your weapon</option>
<option value=1>Rock</option>
<option value=2>Paper</option>
<option value=3>Scissors</option>
</select>
<p><img src="rps.png" id="rpsright"></p>
</div>
<div id="footer">
<img src="andale.png" id="andale" onclick="rps(document.getElementById('p1').value,document.getElementById('p2').value)"
onMouseOver="document.getElementById('andale').src='andale2.png'"
onMouseOut="document.getElementById('andale').src='andale.png'">
</div>
</div>
</body>


有任何想法吗?谢谢!

最佳答案

请使用html {min-height: 100%;},而不要使用height:100%;,因为如果您的页面高度过长,您将看不到所有页面,因为浏览器的高度为100%

并添加#footer {text-align:center;}以使图像按钮居中

所有代码:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Rock-paper-scissers</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script src="rps.js"></script>
<style type="text/css">

html {min-height:100%;
}
body{
height: 100%;background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#93e1d1), to(#d4c87c));
background-image: -webkit-linear-gradient(left, #93e1d1, #d4c87c);
background-image: -moz-linear-gradient(top, #93e1d1, #d4c87c);
font: 100.01% "Trebuchet MS",Verdana,Arial,sans-serif;

background-repeat: no-repeat;
margin: 0;
padding: 0;
}
div#container {
text-align: center;
width: 80%;
margin: 0 auto;
}
div.InnerLeft {
width: 50%;
position: relative;
float: left;
}
div.InnerRight {
width: 50%;
position: relative;
float: right;
}
select {
background: transparent;
margin-top: 15px;
width: 220px;
font-size: 16px;
-webkit-appearance: none;
border: 0px;
height: 34px;
}

#footer {text-align:center;}
</style>
</head>
<body>
<div id="container">
<img src="header.png">
<div class="InnerLeft">
<img src="uno.png"><br>
<select id="p1" onchange="change('p1','rpsleft')">
<option value=0>Choose your weapon</option>
<option value=1>Rock</option>
<option value=2>Paper</option>
<option value=3>Scissors</option>
</select>
<p><img src="rpsL.png" id="rpsleft"></p>
</div>
<div class="InnerRight">
<img src="dos.png"><br>
<select id="p2" onchange="change('p2','rpsright')">
<option value=0>Choose your weapon</option>
<option value=1>Rock</option>
<option value=2>Paper</option>
<option value=3>Scissors</option>
</select>
<p><img src="rps.png" id="rpsright"></p>
</div>
<div id="footer">
<img src="andale.png" id="andale" onclick="rps(document.getElementById('p1').value,document.getElementById('p2').value)"
onMouseOver="document.getElementById('andale').src='andale2.png'"
onMouseOut="document.getElementById('andale').src='andale.png'">
</div>
</div>
</body>

关于css - 背景颜色不覆盖页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13325021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com