我知道这听起来很可笑,但是我可以在内联样式中使用css媒体查询吗?原因是我在PHP中回显背景,如果设备是视网膜,则需要使用视网膜大小的图像。
ie: <div style="background:url(normal.png); <- need to add style for retina device
发布于 2012-10-23 11:38:07
据我所知,不在内联样式声明中。
但是,如果是从PHP和div内部回显,那么确实不能访问样式表,我建议使用媒体查询回显一个内联<style />
元素,并为div使用一个类。
,即
<style type="text/css">
.bg {
background: url(background.jpg);
}
@media only screen and (max-device-width: 480px) { /* Change to whatever media query you require */
.bg {
background: url(background_highres.jpg);
}
}
</style>
<div class="bg">...</div>
https://stackoverflow.com/questions/13023157
复制相似问题