有沒有辦法讓我的身體背景影像在任何移動視圖中都有回應?特別是當高度是412x980?我知道如何使用一些合適的背景封面
body {
background: url(../../something.jpg);
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
}
但我不想使用fixed,因為我需要將所有元素保留在該背景影像上。
編輯:
使用@VIKESIR 提供的代碼whitespace 后,我仍然嘗試調整每個移動視圖的大小,我在
uj5u.com熱心網友回復:
默認情況下,身體高度什么都不是,所以我們需要定義高度。這是除了最后一個中的body標簽之外的一些css,您可以在創建新樣式表時在每個style.css中進行配置。
* {
margin: 0;
padding: 0;
}
html,body {
width: 100%;
height: 100%;
box-sizing: border-box;
}
body {
background-color: #fa0;
}
.title {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.title h1 {
color: #000;
text-shadow: 1px 1px 0px #fff;
text-align: center;
}
@media (max-width: 479px) {
body {
background: url(https://www.psdstack.com/wp-content/uploads/2019/08/copyright-free-images-750x420.jpg) no-repeat center / cover;
width: 100%;
min-height: 100vh;
}
}
<body>
<div class="title">
<h1>TESTING<br>TESTING TESTING</h1>
</div>
</body>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/453263.html
