css - 当值相同时缩短css
问题描述
如果值相同,如何缩短css?
例如:如何将其合并为一个字符串(与一个auto!important
)?
*{width: auto!important}
*{height: auto!important}
似乎我已经看到了这种可能性(作为一种新奇事物)但找不到。
解决方案
您可以将声明缩短为一个:
*{
width: auto!important;
height: auto!important
}
并且您可以使用 css 自定义变量将值缩短为 1,因此每次您想更改值时,请从一个地方进行:
:root{
--foo:auto!important;
}
*{
width:var(--foo);
height: var(--foo);
}
推荐阅读
- gcc - CentOS 7 升级了 gcc / g++ 但似乎无法使用?
- sql - 尝试在 SQL 中创建新表时出错
- javascript - Google 登录不仅适用于网络移动设备
- kubernetes - Nginx 入口控制器安装错误,“dial tcp 10.96.0.1:443: i/o timeout”
- javascript - 模态元素没有隐藏 [React & React - Bootstrap]
- android - 使用函数将一个活动移动到另一个活动
- python - Python:我如何抓取 ESPN 的比赛对决
- python - pyqtgraph.opengl VS OpenGL.GL - 如何在 PyQt5 OpenGL 嵌入式小部件上显示轴
- javascript - 试图用复选框过滤掉结果
- c++ - 找不到未解析的外部符号 _wWinMain@16 的解决方案