【问题标题】:beautiful-jekyll theme: How to modify the page title color in CSS?如何通过 css(beautiful-jekyll 主题)修改标题颜色?
【发布时间】:2020-01-20 22:53:18
【问题描述】:

我已经建立了一个“美丽的 Jekyll”博客/GitHub 页面,我想更改页面标题和副标题的字体颜色。但是我在main.css中找不到合适的地方

以下是网站示例:

https://deanattali.com/beautiful-jekyll/

这里是 GitHub 页面:

https://github.com/daattali/beautiful-jekyll

我查看了index.htmlconfig.ymlcss 文件夹,但找不到更改颜色的位置。

我想改变文字的颜色:

Beautiful Jekyll
Build a beautiful and simple website in minutes

编辑:我有以下内容:

我拥有的main.css 文件的第 24 行到第 35 行:

h1,h2,h3,h4,h5,h6 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 800;
}

a {
  color: {{ site.link-col }};
}

.header_class {
  color: red;
}

在我拥有的index.html 文件的第 28 行:

<h1 class="header_class">{% if page.title %}{{ page.title }}{% else %}<br/>{% endif %}</h1>

哪个有效。

【问题讨论】:

    标签: html css github


    【解决方案1】:

    header.html 中的 page.title 有一个 &lt;h1&gt;

    一些挑战:

    • 父 div 有一个类 &lt;div class="{{ include.type }}-heading"&gt;,但元素本身没有可以在 css 中使用的类或 id。
    • 您需要在 html 中添加另一个类并在 css 中定义新样式以仅获取彩色 page.title
    • 如果您在 CSS 中仅定义现有 &lt;h1&gt; 的颜色,则每个文档的每个标题都会被着色,因为 CSS 为 &lt;h1&gt;&lt;h6&gt; 定义了相同的样式。

    测试 html 和 css 更改:

    • 您可以使用浏览器中的开发工具/检查器(按 F12)查看页面元素。
    • 您甚至可以测试添加/更改某些 css 属性时会发生什么。

    在这里你可以看看我的意思和how to do it on your own

    注意事项:

    当我对此进行测试时,结果发现副标题实际上有不同的类,你也许可以使用。为了测试,我给了&lt;h1&gt; 属性color: red,这肯定不是我上面概述的解决方案。

    如何在 html 中添加类并更新 css:

    注意,这是 h1 的示例,如果您不想为其重用现有的 css,它对子标题的工作方式相同。

    1. 转到header.html 中的第 28 行并将更改 &lt;h1&gt; 添加到 &lt;h1 class="your-test-class"&gt;
    2. 转到main.css 并在 h1,... 定义下方添加以下内容:
    .your-test-class {
      color: red;
    }
    

    有关 html 和 css 以及 specific use of classes in html and css 的完整教程,请参见此处。

    【讨论】:

    • 非常感谢!你能把代码发给我把&lt;h1&gt;改成红色吗?我或多或少地了解 css 发生了什么,但不是专家。如何在 html 文件中添加另一个类并定义 css 类?
    • 您的意思是在main.cssh1, h2, h3l, h4 h5. h6 部分下方? h1,h2,h3,h4,h5,h6?我有以下内容:h1,h2,h3,h4,h5,h6 { .my-header-class { color: red; } font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 800; } a { color: {{ site.link-col }}; }
    • .my-header-class 是一个单独的块,你有 h1,h2,h3,h4,h5,h6 { font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial , 无衬线字体;字体粗细:800; } a { 颜色:{{ site.link-col }}; } 和 .my-header-class { 颜色:红色; }
    • 我添加了我所做更改的编辑,颜色没有改变。
    • 编辑:是的,颜色确实改变了!我只需要等到网站更新!再次感谢!
    猜你喜欢
    • 1970-01-01
    • 2013-07-05
    • 1970-01-01
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    • 2022-09-30
    • 1970-01-01
    • 2015-02-19
    相关资源
    最近更新 更多