css - 少边框合二为一
问题描述
如何用更少的代码编写下面的代码。如何以最佳方式缩短代码。提前致谢!
代码:
.border {
border: solid 1px;
}
.border-color-inherit {
border-color: inherit !important;
}
.border-top {
border-top: solid 1px;
}
.border-left {
border-left: solid 1px;
}
.border-bottom {
border-bottom: solid 1px;
}
.border-right {
border-right: solid 1px;
}
.border-none {
border: none !important;
}
我尝试:
@x: ~"solid 1px";
.res (@border)
{
border-top: @x;
border-left: @x;
border-right: @x;
border-bottom: @x;
}
.border-top{
.res (@x);
.border-left{
.res (@x);
}
}
所以,我尝试了很多方法来使它成为可能,但没有任何成功。它看起来不太好。
解决方案
Try it this way
.border {
border: solid 1px;
border-color: inherit !important;
}
.border-none {
border: none !important;
}
推荐阅读
- sql-server - T-SQL,如果第一个条件为真,则选择数据,否则从第二列获取最新的
- c++ - 如何使用 MATLAB 编码器将训练有素的神经网络用作函数?
- django-models - 如何将表单的多个输入字段数据存储到django中的单个表(模型)中
- postgresql - 如何使用 PostgreSql 在代码优先方法中自动创建表
- python - 如何获得单词的 TF-IDF 分数?
- java - Spring JPA:OneToMany List 更新导致重复条目
- angular - 在Angular 7中滚动div
- android - 即使手机处于静音/请勿打扰模式也播放声音
- firebase - 从 Expo 的缓存中以 base64 格式读取文件,写入 Firebase 存储(Cloud Storage for Firebase)
- android - 片段过渡动画导致 api 级别 22 中的 ANR