侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

css – 将媒体查询放入mixin中

2022-12-27 星期二 / 0 评论 / 0 点赞 / 27 阅读 / 1205 字

我有很多css文件和很多次出现: @media all and (max-width: 400px),(orientation: portrait) { ....//In each f

... . . 我有很多css文件和很多次出现:

@media all and (max-width: 400px),(orientation: portrait) {    ....//In each file different style that relevant to the component the file represnt}

我正在使用手写笔.
有一天,我的老板让我将该媒体查询更改为:

@media all and (max-width: 400px),(max-height: 400px) {    ....}

现在我需要搜索我的所有文件并替换为新的媒体查询.

有没有选择将这个媒体查询放入mixin或其他东西?

.

解决方法

. 取自 question I answered previously.这是我使用的黑客:

在variables.styl中

smartphoneWidth = 748pxtabletWidth     = 1012pxmqSmartphone = "only screen and (max-width: " + smartphoneWidth + ")"mqTablet     = "only screen and (max-width: " + tabletWidth     + ")"

现在在您的其他手写笔文件中,您可以使用:

@media mqSmartphone    // Styles go here@media mqTablet    // Styles go here

虽然仍然很难看,但我觉得它比使用unquote()稍微优雅一点

. . .. ...

广告 广告

评论区