首页 > 解决方案 > 将 CSS 规则链接到子工作表

问题描述

我希望能够在多张工作表中链接到“按钮”类的规则,并将其定义在一张工作表中,这样我只需编辑一次即可编辑我的所有按钮。

例子:

mystyle.css 内容如下:

.button{ 
  font-family: Arial, Helvetica, sans-serif;
  font-size: 30px;
  height: 45px;
  width: 140px;
  background-color: #9999ff;
  text-align: center;
  padding-top: 6px;
  border-radius: 25px;
}

我希望在创建新页面时能够说出类似的话

.button {
  url:("../mystyle.css/.button")
}

标签: htmlcss

解决方案


This one was down to me not understanding how HTML loads styles.

<html>
<head>
  <link rel="stylesheet" type="text/css" href="../mystyle.css">
  <link rel="stylesheet" type="text/css" href="./newpage.css">
</head>

Will load all the CSS for the buttons and then if both files define the same element, style according to newpage.css


推荐阅读