【发布时间】:2021-10-09 16:14:02
【问题描述】:
早上好,
我为我的网站创建了一个媒体查询。我感觉它正在减慢我的网站,因为它没有优化。 在手机上,我有一个特定的图像。对于平板电脑和台式机,我要显示另一个图像。 我的媒体查询工作得很好。但它没有优化。 谁能帮我优化一下?
这是查询:
body, html {
height : 100%;
width: 100%;
margin:0;
}
@media only screen and (min-width: 320px) {
.Frontpage-image {
background-image: url("https://dit.be/wp-content/uploads/2021/01/mobiel-01.svg");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
height: 100vh;
}
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
.Frontpage-image {
background-image:url("https://dit.be/wp-content/uploads/2021/01/desktop-01.svg");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
height:100vh;
}
}
@media screen and (min-width: 768px) {
.Frontpage-image{
background-image:url("https://dit.be/wp-content/uploads/2021/01/desktop-01.svg");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
height: 100vh;
}
}
@media screen and (min-width: 1025px) {
.Frontpage-image {
background-image:url("https://dit.be/wp-content/uploads/2021/01/desktop-01.svg");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
height:100vh;
}
}
【问题讨论】:
-
嗨,您是指更短/更整洁的代码还是运行时优化?
-
其实两者都有,但运行时优化对我来说更重要
-
本页底部有一个代码审查 stackexchange 站点。
标签: css media-queries