css - 如何将这两个 Less @Media 查询与 "Or"条件结合起来?

标签 css sass responsive-design less media-queries

假设我有一些像这样的 less 代码:

@desktop-min-width:         1024px;
@phone-max-width:           768px;

@desktop:          ~"only screen and (min-width: @{desktop-min-width})";
@tablet:           ~"only screen and (min-width: @{phone-max-width}) and (max-width: @{desktop-min-width})";
@phone:            ~"only screen and (max-width: @{phone-max-width})";

.hola {

  @phone {
    height: 100vh;
    top:    10px;
  }

  @tablet {
    height: 30vh;
    top:    30%;
  }

  @desktop {
    height: 30vh;
    top:    30%;
  }

}

// ...more styles...

我有办法结合@tablet 和@desktop 并减少重复吗?我想象的是这样的:

@tablet or @desktop {
  height: 30vh;
  top:    30%;
}

最佳答案

只需使用逗号即可完成您想要的操作:

@tablet, @desktop  {
  ...
}

关于css - 如何将这两个 Less @Media 查询与 "Or"条件结合起来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53210654/

相关文章:

html - 在固定的 div 中对齐和居中图像

使用 BEM 和 Sass 悬停时的 CSS 过渡

html - 如何在将鼠标悬停在另一个 <li> 上时阻止我的 <li> 元素移动?

visual-studio-code - 如果路径包含 $lib 别名,VSCode 无法在 Svelte 组件中找到 scss 导入

css - 如何在移动优先响应网格中以两列三行棋盘显示内容

html - 响应定位图像

iframe - 如何以百分比设置 twitter 的嵌入式时间线宽度(响应式/流畅设计)

html - 查看图像重叠导航栏的问题

html - svg 图像在表格中不缩放

与浏览器尺寸相同的 css div 少 30 px 宽度和高度