gpt4 book ai didi

html - 加载背景图片的bug

转载 作者:行者123 更新时间:2023-11-28 03:08:05 26 4
gpt4 key购买 nike

我现在有一个奇怪的问题。我写了一个非常简单的网站,看起来像:

enter image description here

显示正常。但是当我尝试刷新它时,不经常刷新,可能一次刷新 10 次,背景照片的显示出现错误,如下所示:

enter image description here

我是前端设计的新手,我不知道发生了什么。有人能帮我吗?这是我的 html 和 css 代码,这个错误只出现在 chrome 上,在 firefox 上效果很好。

HTML代码:

<!doctype html>
<html>

<head>
<meta charset = "utf8">
<meta http-equiv="Pragma" content="no-cache">
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='login.css') }}">
<title> Login page :) </title>
</head>

<body>
<div id="div_title">
<span id="title"> Welcome to wentong's website! </span>
</br>
<a href="{{ url_for('homepage') }}" id="guestlink">Entrance for guests here :)</a>
</div>

{% for message in get_flashed_messages() %}
<div class=flash>{{ message }}</div>
{% endfor %}

<form action="{{ url_for('login') }}" method=post>
<div id = "div_login">
<span class="label">Username:</span>
<input class="input" type=text name=username>
<br/>
<span class="label">Password: </span>
<input class="input" type=password name=password>
<br/>
<input id="submit" type=submit value=Login style="display:none">
</div>
</form>
</body>
</html>

和背景 CSS:

html {
background: url(images/aurora.jpg) no-repeat center center fixed;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
}

最佳答案

您可以尝试使用这样的 css 规则放置背景图片,例如单独的 img 标签:

.full-screen-background-image {
z-index: -999;
min-height: 100%;
min-width: 1024px;
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0;
}

并将它放在布局标记的最底部

<!doctype html>
<html>
<head>
...
</head>
<body>
...
<img class="full-screen-background-image" src="you-image.jpg" />
</body>
</html>

关于html - 加载背景图片的bug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45851813/

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