bookdown 中自定义块中的样式链接

style links in a custom block in bookdown

我正在尝试为 custom block in bookdown 中的链接设置样式。自定义块类型称为 "rmdcomment",我已将以下内容添加到 style.css 文件中:

.rmdcomment {
  padding: 1em 1em 1em 4em;
  margin-top: 30px;
  margin-bottom: 30px;
  background: #1f9ac9;
  position:relative;
  color: white;
}

.rmdcomment:before {
  content: "\f075";
  font-family: FontAwesome;
  left:10px;
  position:absolute;
  top:0px;
  font-size: 45px;
  color: white;
}

以上显示正确。

我还在(不成功的)链接样式尝试中添加了以下内容:

.rmdcomment a:link {text-decoration: underline; font-weight:bold; color:white;}
.rmdcomment a:visited {text-decoration: underline; font-weight:bold; color:white;}
.rmdcomment a:hover {text-decoration: underline; font-weight:bold; color:white;}

我相信这就是您所说的部分。

添加 !important,所以基本上你会覆盖以前的样式。

.rmdcomment a:link {text-decoration: underline !important; font-weight:bold !important; color:white !important;}

使用 !important 不是最佳做法。你总是可以用你的 CSS 更具体。尝试这样定位,您应该在不使用 !Important:

的情况下获得相同的结果
.book .book-body .page-wrapper .page-inner section.normal .rmdcomment a:hover {
    text-decoration: underline;
    font-weight: bold;
    color: white;
}