gpt4 book ai didi

javascript - 调整大小时在主体上滚动背景图像

转载 作者:行者123 更新时间:2023-11-28 17:32:07 25 4
gpt4 key购买 nike

我想要网站正文中的图片,为此我使用了这个 CSS:

body {
background-color: #000;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(image.jpg);
background-repeat: no-repeat;
background-position:center top;
}

当我调整浏览器大小时,我希望看到滚动条出现,以便可以滚动图像。我错过了什么?

最佳答案

您应该根据图像的宽度和高度为您的body 设置min-widthmin-height:

body {
background-color: #000;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(http://theactsoftheapostles.com/images/yesu-ki-jai-bg.jpg);
background-repeat: no-repeat;
background-position:center top;
min-width: 1390px;
min-height: 903px;
}

JSFiddle Demo .


不过我认为最好避免使用水平滚动条。

关于javascript - 调整大小时在主体上滚动背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25830477/

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