将背景图像放置在CSS底部



我试图将我的背景图像定位为中心底部,我知道有一个backgorund-position属性,但它不会改变任何东西给我。

目前我让图像响应,但它只是没有底部。

下面是我的代码:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
display: block;
position: fixed;
background: #2d8eb8 url("https://i.ibb.co/Cn1P5vk/bg.jpg") 50% 50%;
background-repeat: repeat-x;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-position: center bottom;
}
</style>
</head>
<body>

</body>
</html>

如果可能的话,我想把样式放在一个而不是整个body中,我自己做不到

设置background-size: 100%而不是使用cover,因为cover将倾向于覆盖整个宽度

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
html {height: 100%;}
body {
display: block;
position: fixed;
background: #2d8eb8 url("https://i.ibb.co/Cn1P5vk/bg.jpg") 50% 50%;
background-repeat: repeat-x;
-webkit-background-size: 100%;
-moz-background-size: 100%;
-o-background-size: 100%;
background-size: 100%;
background-position: center bottom;
}
</style>
</head>
<body>
</body>
</html>

最新更新