Scss

181 字
1 分钟
Scss

响应式#

  1. 当某一个元素需要添加响应式时,可直接在类名样式内添加@media属性
.codeBox {
display: flex;
justify-content: center;
@media screen and (max-width: 576px) {
scale: 0.5;
}
}
  1. 当需要根据某一个元素进行响应式时,可以生命父级容器并通过 @container 进行响应式
.list {
// 声明为容器(父级元素)
container-type: inline-size;
container-name: product-list;
.item {
@container (inline-size > 576px) {
width: 50%;
}
@container (inline-size < 576px) {
width: 100%;
}
}
}

同一元素,样式相同 颜色不同#

当碰到多个元素样式相同,只是颜色不同时,可通过&.class的方式选中

.bar {
width: 1em;
height: 1em;
border-radius: 1em;
font-size: 14px;
&.red {
background-color: #f75554;
}
&.yellow {
background-color: #f7c54a;
}
&.green {
background-color: #5fcf5f;
}
}

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!

打赏
Scss
https://blog.ddlyt.top/posts/2024/1225/
作者
兜兜里有糖
发布于
2024-12-25
许可协议
CC BY-NC-ND 4.0

评论区

Profile Image of the Author
兜兜里有糖
越努力,越幸运。
公告
欢迎来到 DBlog,这里记录前端开发、技术学习和一些实用工具。
分类
标签
最新动态
站点统计
文章
21
分类
2
标签
18
总字数
15,966
运行时长
0 天
最后活动
0 天前
访问次数
--
站点信息
构建平台
EdgeOne Pages
博客版本
Firefly v2.0.0
文章许可
CC BY-NC-ND 4.0
文章目录