gpt4 book ai didi

html - CSS3 - 宽度 :100% - Height:Auto - Background-image?

转载 作者:太空宇宙 更新时间:2023-11-04 03:37:06 24 4
gpt4 key购买 nike

我的问题很简单...我想要一个背景图像,我的 Logo 位于中间。

示例:Example website

我觉得做起来没那么难,但我好像做不出来...

我希望背景图像(始终)填满整个宽度,并且我希望高度按比例调整。 (响应式)就像示例中一样。

出于某种原因,我的代码没有这样做。

有人能帮帮我吗?我如何将图像作为背景填充整个宽度和自动高度,并将我的 Logo 放在图像顶部。

问候,迈克尔

最佳答案

像这样为 body 分配背景:

 body{
background-image: url('../img/yourimagefilename.jpg');
background-position: top center;
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
background-color: #343433;
height: 100%;
}

关于html - CSS3 - 宽度 :100% - Height:Auto - Background-image?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25393219/

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