gpt4 book ai didi

html - 背景里面的背景

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

我一直在尝试在我的网站上将背景放在背景中。我可以用这段代码设置我想要的背景颜色:

<body bgcolor="#F5F2D4">
<div class="Gallery">
<h1> Gallery </h1>
</div>
</body>

之后,在 CSS 中我做了以下操作

.Gallery h1 {
text-align: center;
font-family: 'Century Gothic', CenturyGothic, AppleGothic, sans-serif;
font-size: 55px;
font-style: normal;
font-variant: normal;
font-weight: 500;
line-height: 26.3999996185303px;
background-color: White;
}

背景看起来像这样(B=米色,W=白色:

-------------------------
|BB|WWWWWWWWWWWWWWWWWW|BB|
|BB|WWWWWWWWWWWWWWWWWW|BB|
|BB|WWWWWWWWWWWWWWWWWW|BB|
|BB|WWWWWWWWWWWWWWWWWW|BB|
|BB|WWWWWWWWWWWWWWWWWW|BB|
-------------------------

这在背景中制作了我想要的颜色,但没有缩放。直到白开始,它与浏览器的边框只有几个像素的差异,有什么办法可以使距离增加吗?

还有,有没有办法让白色背景一直向下滚动?

非常感谢。

最佳答案

htmlbody.gallery 都设置一个 height: 100% 来制作 .gallery 占据整个屏幕的高度。

如果您希望 .gallery 具有固定宽度(如下例所示),请为其指定一个 width 并添加 margin: 0 auto 让它在屏幕中水平居中。如果您不希望它具有固定宽度,请在 body 上添加一个 padding: 0 100px 如果您希望它的左侧和右侧各有 100 像素.gallery 为米色。

html,
body {
height: 100%;
}

body {
background-color: beige;
margin: 0;
}

.gallery {
background-color: white;
width: 960px;
margin: 0 auto;
height: 100%;
}
<div class="gallery">
</div>

关于html - 背景里面的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27634659/

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