html - 我可以通过标签来组织 CSS,而不是将它们全部分开吗?

标签 html css

为了解释我希望实现的目标,假设我有一个包含许多类的长 css 文档。我有几个不同的“h1”标签和“h2”标签、“iframe”、“ul”,许多都有不同的类。是否可以将所有“h1”或其他标签(无论类别如何)组合在一起,并且所有“iframe”都可以在 Notepad++ 中组合在一起。

h1.left {
	font-family: Papyrus;
	font-size: 45px;
	color: white;
	margin-left: 15px;
}
h1.center {
	font-family: Papyrus;
	font-size: 30px;
	color: white;
	text-align: center;
<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <pre>PS: All code in this document is just
       so it would be seen as I meant it to be,
        and I hope you can read it right.<pre>
  <!--For example:-->
  + h1
  <!--And if i roll the h1 down, i can get all h1 in the document:-->
  <ul>
     <li> h1.left</li>
     <li>h1.center <li>
     <li>h1.right<li>
  <!--And if i open those again, I will get all the code that is inside them-->
</body>
</html>

最佳答案

不确定 Notepad++ 是否可以运行 SASS,但它听起来像你想要的。

h1 {
    color: white;
    font-family: Papyrus;
    text-align: center;

    &.left {
        font-size: 45px;
    }
    &.center {
        font-size: 30px;
    }
}

关于html - 我可以通过标签来组织 CSS,而不是将它们全部分开吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46191608/

相关文章:

jquery - 在 jQuery 中根据 ID 调用函数

html - 如何在 HTML/CSS 中制作两个比例列,其中左列在用户滚动时跟随用户?

html - Bootstrap-CSS 下拉菜单按钮样式

html - Nexus 7 screen.width 返回 800 但媒体查询最大宽度 : 720px still applies

html - 在嵌套的 DIV 中停止图像边框

html - 如何通过对齐的列表项填充空白

html - Twitter Bootstrap - 使井全宽

jquery - 如何使用 jQuery 在 div 中动态添加 div。它也应该首先显示?

javascript - Bootstrap 轮播在响应时没有反应

javascript - 在 CodeIgniter 中高效压缩 CSS 和 JS