gpt4 book ai didi

html - 在浏览器中定位内容以匹配重复的背景

转载 作者:行者123 更新时间:2023-11-28 13:39:48 25 4
gpt4 key购买 nike

我有一个重复的背景和这样的位置:

body
{
background-image: url(images/background.jpg);
background-repeat: repeat;
background-position: 50% 50%;
}

这很好用。现在我想将页面的内容居中。如果我有一张 1000x560 像素的图像,我希望它对齐以匹配现在在浏览器中居中的背景。

最佳方法?

enter image description here

最佳答案

对于内容 div,您可以使用 position:absolute 。像这样写:

.content{
width:1000px;
height:560px;
top:50%;
margin-top:-230px;
left:50%;
margin-left:-500px
}

关于html - 在浏览器中定位内容以匹配重复的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8149444/

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