我可以在响应式 css 说明中引用媒体尺寸吗?
Can I reference the media size in responsive css instructions?
我熟悉在响应式 CSS 中使用媒体查询断点设置规则,但是我想知道我是否可以使用相同的方法为 CSS 提供格式化 [=] 的说明18=]?
例如我能有一些类似
的东西吗
#image {
max-width:([whatever the media width is]-20) px;
}
?
由于媒体宽度为 100%,您可以使用 calc() 方法使用它:
#image {
max-width: calc(100% - 20px);
}
查看浏览器 compatibility。
我熟悉在响应式 CSS 中使用媒体查询断点设置规则,但是我想知道我是否可以使用相同的方法为 CSS 提供格式化 [=] 的说明18=]?
例如我能有一些类似
的东西吗#image {
max-width:([whatever the media width is]-20) px;
}
?
由于媒体宽度为 100%,您可以使用 calc() 方法使用它:
#image {
max-width: calc(100% - 20px);
}
查看浏览器 compatibility。