html - 回退到 element.style 媒体查询?

标签 html css

我想知道是否可以在某个媒体查询中使用 element.style。

我在一个应用程序中工作,其中 div 宽度由 javascript 在文档加载时设置。像这样:

<ul style="width: 593.531px;" class="width-fix">

<style>
    .width-fix { 
        width:100%!important;
        min-width:100%;
    }
</style>

我想要的是某个断点只是回退到 element.style。

我应该使用 jquery 来切换还是可以通过媒体查询来完成?

最佳答案

你可以用“反向”的方式来写它。

@media screen and (min-width: ###px)  {
  .width-fix { 
        width:100%!important;
        min-width:100%;
    }
}

此媒体查询仅在窗口超过一定宽度时才会激活。这意味着当你落入其中时,!important 规则将被删除,内联 css 将启动。

关于html - 回退到 element.style 媒体查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35336203/

相关文章:

php - 表格日期输入从(日期)到(日期)或我不知道一个或两个选择

css - CSS 中带星号的属性是什么意思?

html - 在视口(viewport)中居中元素而不是包含 Bootstrap 列

javascript - 如何在父级之上显示 iframe 弹出窗口?

java - 移动时更改鼠标光标

JavaScript,将值传递给函数

javascript - 寻找类似于 Google Flights 的 Html 日期范围

c# - 动态显示 XML 内容

html - 在 anchor 标记内放置两个绝对 div

javascript - ng-model 到我的服务器上的异步 xhr get/set 字段