gpt4 book ai didi

html - CSS3图片全屏

转载 作者:行者123 更新时间:2023-11-28 10:26:24 25 4
gpt4 key购买 nike

如何在我的网站上制作全屏图片??我已经尝试了很多方法,但还是做不对。

我这样做了:

    width: 100%;
height: 100%;
text-align: center;
background:url(images/top.png);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;

好吧,一切都很好,但要使其全宽,我必须插入大量文本或
更改图片的高度...

比我试试这个:

width: 100%;
height: 100%;
text-align: center;
position: absolute;
background:url(images/top.png);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-attachment: fixed;
min-width: 100%;
min-height: 100%;

此方法非常有效,但是当我在第一个 DIV 下添加第二个 DIV 时,我的第二个 DIV 在第一个 DIV 上......

所以问题是,如何在我的网站上制作全屏图片!我想要 100% 的高度和 100% 的宽度,当我添加第二个 DIV 时,所有内容都将位于第一个之下。

感谢您的帮助。

最佳答案

{
position: absolute;
background-image: url(images/top.png);
background-attachment: fixed;
top: 0px;
left: 0px;
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
z-index: value;
}

z-index属性指定元素的堆叠顺序。

关于html - CSS3图片全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23720303/

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