您好,我在 CSS 中的固定背景有一点问题。我需要把它固定在左下角。
background: url('./images/coura.png') no-repeat fixed;
width: 451px;
height: 736px;
position: fixed;
background-attachment: left bottom;
有什么办法吗?谢谢您的回答!
您好,我在 CSS 中的固定背景有一点问题。我需要把它固定在左下角。
background: url('./images/coura.png') no-repeat fixed;
width: 451px;
height: 736px;
position: fixed;
background-attachment: left bottom;
有什么办法吗?谢谢您的回答!
您的元素需要位于您希望背景所在的位置。添加left: 0px; bottom: 0px;
到固定定位。
最简单的解决方案是将图像设置background-image
为您的body
并将background-attachment
属性设置为fixed
:
html, body { height: 100%; }
body { background: url('./images/coura.png') 0 100% no-repeat fixed; }
另一种方法是将背景位置设置为bottom left
:
background: url('./images/coura.png') bottom left no-repeat fixed;