原先在筆記本和桌上型電腦上,惠惠的那個背景經常是不能完全顯示出來的,只能顯示出來半個身子,但是在手機上看我的部落格又是非常完美的......
所以說我採用了因人而治的手法,對不同設備進行了不同的背景設置:
/* 檢測用戶是否使用移動設備 */
@media only screen and (max-width: 767px) {
/* 改變樣式 */
body {
background-image: url(https://img1.imgtp.com/2023/05/01/mhyoOtKF.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center ;
background-attachment: fixed;
}
.mt-auto:after {
content: "您當前採用“手機端”打開此網頁";
font-style: italic;
font-weight: bolder;
color: wheat;
}
}
/* 檢測用戶是否使用桌面電腦 */
@media only screen and (min-width: 768px) and (max-width: 991px) {
/* 改變樣式 */
body {
background-image: url(https://img1.imgtp.com/2023/05/01/EiUP9R8D.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center ;
background-attachment: fixed;
}
.mt-auto:after {
content: "您當前採用“桌面電腦”打開此網頁";
font-style: italic;
font-weight: bolder;
color: wheat;
}
}
/* 檢測用戶是否使用筆記本電腦 */
@media only screen and (min-width: 992px) {
/* 改變樣式 */
body {
background-image: url(https://img1.imgtp.com/2023/05/01/EiUP9R8D.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center ;
background-attachment: fixed;
}
.mt-auto:after {
content: "您當前採用“筆記本電腦”打開此網頁";
font-style: italic;
font-weight: bolder;
color: wheat;
}
}