gpt4 book ai didi

css - 没有参数的@media 有什么作用吗?

转载 作者:技术小花猫 更新时间:2023-10-29 11:39:43 25 4
gpt4 key购买 nike

我从一位……有问题的……网络开发人员那里继承了一些代码。该站点的每个页面都引用了数百个样式表,每个样式表都充斥着额外的 @media 标签,这些标签看起来格式不正确。他们只是:

@media {
/* A bunch of CSS rules */
}
@media {
/* A bunch more CSS rules */
}

我正在努力简化代码库,以便于我维护它。我的问题是:像没有媒体类型或媒体函数参数那样单独使用 @media 是否有任何可能的目的?

最佳答案

来自MDN page :

A media query is composed of an optional media type and any number of media feature expressions. Multiple queries can be combined in various ways by using logical operators. Media queries are case-insensitive.

然后

Media types describe the general category of a device. Except when using the not or only logical operators, the media type is optional and the all type will be implied.

基本上,您的媒体查询将适用于所有设备,没有任何限制,因此从技术上讲,您可以省略 @media 并且您将获得相同的结果。

还有 the support of @media即使对于某些旧浏览器也非常好,因此您也应该得到相同的结果。

关于css - 没有参数的@media 有什么作用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57145703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com