[SCSS] Organize Styles with SCSS Nesting and the Parent Selector
2024-08-31 19:58:44
SCSS nesting can produce DRYer code by targeting child elements without having to write the parent class. Nesting up to 3 levels deep can help us understand relationships between styles. The SCSS parent selector represents the parent class, so it can DRY up targeting pseudo-elements/classes and be an asset for naming conventions.
.box { &-container { /* .box-container, & --> .box*/
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
} transition: all 0.8s ease-in-out;
&:hover {
background-color: #ff4d4d;
transform: rotate(360deg);
}
background-color: #5fb3ce;
border: 1px solid burlywood;
font-size: 1.5em;
width: 200px;
height: 200px;
}
To css:
.box {
transition: all 0.8s ease-in-out;
background-color: #5fb3ce;
border: 1px solid burlywood;
font-size: 1.5em;
width: 200px;
height: 200px; }
.box-container {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh; }
.box:hover {
background-color: #ff4d4d;
transform: rotate(360deg); }
最新文章
- 使用ASP.NET Web API Help Pages 创建在线接口文档
- struts2 框架处理流程
- ionic android双击退出应用和物理返回按钮隐藏键盘的实现
- Android开发:第四日番外——Assets文件夹和RAW文件夹区别
- centos -bash-4.1$ 不显示用户名路径
- 51nod-1686 第K大区间(二分+尺取法)
- 【风马一族_Android】android的新发现
- python3 学习总结与建议
- linux 内核驱动加载过程中 向文件系统中的文件进行读写操作
- Delphi String 与wideString 的完美转换
- ajax请求响应中用window.open打开新窗口会被浏览器拦截的解决方式
- 使用eclipse写C
- [HNOI2015]接水果
- asp.net动态添加控件学习
- CSS:与input相关的一些样式设置问题
- Android平台下利用zxing实现二维码开发
- mysql-数据库管理安装
- Jsp俩大内置对象学习
- NYOJ 542 试制品(第五届河南省省赛)
- ASP.NET MVC HtmlHelper 类的扩展方法
热门文章
- java匿名内部类使用场景列举
- JavaScript 进度条重复加载
- vue使用marked.js实现markdown转html并提取标题生成目录
- Vue Cli 打包之后静态资源路径不对的解决方法
- 1.1 Introduction中 Distribution官网剖析(博主推荐)
- Android 图片缓存处理
- VC error link
- PatentTips - Method, apparatus and system for instructing a virtual device from a virtual machine
- cmake的使用笔记
- Oracle10g中阻塞锁查询更简单