gpt4 book ai didi

html - 背景图片未覆盖整个页面

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:53 27 4
gpt4 key购买 nike

我的网站有一个非常奇怪的问题。背景图像不会覆盖整个页面,当我调整窗口大小时,它会产生大的白色部分。但是,它只发生在某些 PC/笔记本电脑上。几个 friend 试用了该网站,并报告说他们在图像缩放方面没有问题,并且在调整窗口大小时它一直覆盖整个页面。

然而,它是这样显示给我的:https://gyazo.com/04a679edfb7a442d09d6e7ce8b196cf9请随时自行查看网站。

我真的希望有人能阐明发生了什么事。此外,图片不保持其宽高比,而是在调整大小时放大/缩小。

https://jsfiddle.net/dn3553pg/1/

HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>onepageskiw</title>
<link href="styles.css" rel="stylesheet" type="text/css">
<script src="js.js"></script>
</head>
<body>

<div id="forsidediv">
<img id="forsidepic" src="baggrund.jpg">
<nav>
<ul id="menu">
<li><a href="#">Top</a></li>
<li><a href="#">Om Eventet</a></li>
<li><a href="#">Lokation</a></li>
<li><a href="#">Kontakt</a></li>
</ul>
</nav>
</div>

<div id="logodiv">
<img src="../design/logotop.png">
</div>

<div id="overskrift">
<h1>EVENTET STARTER OM</h1>
</div>

<div id="countdowner">
<table id="table">
<tr>
<div id="countdown">
<td id="id1"></td>
<td id="id2"></td>
<td id="id3"></td>
<td id="id4"></td>
</div>
<tr>
<tr>
<td class="timeLabel">DAGE</td>
<td class="timeLabel">TIMER</td>
<td class="timeLabel">MIN</td>
<td class="timeLabel">SEK</td>
</tr>
</tr>
</tr>
</table>
</div>

<div id="information">
<div>
<h2>Hvad skal der ske?</h2>
</div>
</div>

<script>
CountDownTimer('06/25/2016 10:00 AM', 'id');

function CountDownTimer(dt, id)
{
var end = new Date(dt);

var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;

function showRemaining() {
var now = new Date();
var distance = end - now;
if (distance < 0) {

clearInterval(timer);
document.getElementById(id).innerHTML = 'EXPIRED!';

return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor((distance % _day) / _hour);
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);

document.getElementById(id+"1").innerHTML = days;
document.getElementById(id+"2").innerHTML = hours;
document.getElementById(id+"3").innerHTML = minutes;
document.getElementById(id+"4").innerHTML = seconds;
}

timer = setInterval(showRemaining, 1000);
}
</script>



</body>
</html>

CSS

@charset "utf-8";

@import url(https://fonts.googleapis.com/css? family=Montserrat:400|Raleway:100,400|);

body {
margin:0;
}

#forsidediv {
position:fixed;
bottom:0;
}

#forsidepic {
width: 100%;
}

#logodiv {
position:absolute;
text-align:center;
padding-top:15%;
}

#logodiv>img {
width:15%;
}

h1 {
font-family:raleway;
font-weight:100;
position:absolute;
width:100%;
text-align:center;
color:white;
letter-spacing:11px;
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-230%);
font-size:2.5em;
}

#countdowner {
font-family:sans-serif;
color:white;
position:absolute;
margin:0;
padding:0;
width:100%;
font-size:2em;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-20%);
}

#id1 {
font-size:2.5em;
}

#id2 {
font-size:2.5em;
}

#id3 {
font-size:2.5em;
}

#id4 {
font-size:2.5em;
}

.timeLabel {
font-size:0.7em;
color:#f1a01e;
font-family:montserrat;
font-weight:700;
}

#table {
margin:0 auto;
text-align:center;
}

#table td{
padding:0px 45px;
}

#menu {
position:absolute;
padding:0;
width:100%;
bottom:0;
text-align:center;
}

#menu>ul {
font-size:0;
}

#menu>li {
font-size:20px;
list-style:none;
display:inline-block;
text-transform:uppercase;
letter-spacing:3px;
font-family:raleway;
font-weight:400;
}

#menu>li>a {
padding:0 15px;
text-decoration:none;
color:white;
}

#menu>li>a:hover {
color:#f1a01e;
}

#information {
position:relative;
color:red;
}

最佳答案

你应该将图像设置为背景,并像这样设置它覆盖整个背景

html { 
background: url(background.jpg) no-repeat center center fixed;
background-size: cover;
}

关于html - 背景图片未覆盖整个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37487696/

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