gpt4 book ai didi

css - 对齐背景图像(:relative) to right

转载 作者:行者123 更新时间:2023-11-28 12:06:21 26 4
gpt4 key购买 nike

我的网站有一个 header background-image,它使用以下 CSS 设置样式:

.header {
position: relative;
min-height: 436px;
background: url("../img/holland-canal.jpg") no-repeat;
background-size: cover;
}

就像现在一样,在较低分辨率下调整窗口大小时,图像会向左对齐,因此图片的右侧部分会被截断。图片的右侧包含桥梁,我希望它始终可见。

是否可以将 background-image 定位为始终向右对齐,即当调整为较小的窗口大小时图像的左侧部分被切除?

最佳答案

将此添加到您的 CSS:

.header{
background-position:right;
}

因为具有 header 类的 div 包含背景图像

输出

enter image description here

有关更多信息,请查看 this

关于css - 对齐背景图像(:relative) to right,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39327565/

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