全屏背景html [英] full screen background html

查看:108
本文介绍了全屏背景html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试显示图片作为我网站的背景,因此我使用以下代码

I'm trying to show a picture as the background of my website so I'm using the following code

HTML:

<div>
     <img src="images/background.jpg" id="bg" alt="background_image" />
</div>

Css:

#bg {
    width: 100%;
    height: 75%;
    position: absolute;
    z-index: -5000;
}

我想知道如何限制背景的大小

I was wondering how can I put a limit on how big is the background going to get because I don't want it to stretch more than 2000px.

感谢

推荐答案

只需在CSS中包含max-width。

Just include max-width in your CSS.

 #bg {
    width: 100%;
    max-width: 2000px;
    height: 75%;
    position: absolute;
    z-index: -5000;
}

这篇关于全屏背景html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆