设置标题¶
¥Setting up the header¶
MkDocs 的标题栏材质可以自定义,显示滚动时消失的公告栏,并提供一些进一步配置的选项。它还包括搜索栏和显示项目git 仓库的位置,如专用指南中所述。
¥Material for MkDocs' header can be customized to show an announcement bar that disappears upon scrolling, and provides some options for further configuration. It also includes the search bar and a place to display your project's git repository, as explained in those dedicated guides.
配置¶
¥Configuration¶
自动隐藏¶
¥Automatic hiding¶
6.2.0
启用自动隐藏后,当用户滚动超过一定阈值时,标题将自动隐藏,从而留出更多空间用于内容。将以下几行添加到mkdocs.yml中:
¥When autohiding is enabled, the header is automatically hidden when the user scrolls past a certain threshold, leaving more space for content. Add the following lines to mkdocs.yml:
公告栏¶
¥Announcement bar¶
5.0.0
Material for MkDocs 包含一个公告栏,它是向用户展示项目新闻或其他重要信息的理想场所。当用户滚动到标题上方时,公告栏将自动消失。要添加公告栏,请扩展主题并覆盖“announce”块(默认情况下为空):
¥Material for MkDocs includes an announcement bar, which is the perfect place to display project news or other important information to the user. When the user scrolls past the header, the bar will automatically disappear. In order to add an announcement bar, extend the theme and override the announce block, which is empty by default:
{% extends "base.html" %}
{% block announce %}
<!-- Add announcement here, including arbitrary HTML -->
{% endblock %}
标记为已读¶
¥Mark as read¶
8.4.0
为了呈现可由用户标记为已读的临时公告,可以添加一个用于关闭当前公告的按钮。将以下几行添加到mkdocs.yml中:
¥In order to render temporary announcements that can be marked as read by the user, a button to dismiss the current announcement can be included. Add the following lines to mkdocs.yml:
当用户点击按钮时,当前公告将被关闭,并且不会再次显示,直到公告内容发生变化为止。此操作是自动处理的。
¥When the user clicks the button, the current announcement is dismissed and not displayed again until the content of the announcement changes. This is handled automatically.
滚动到此页面的顶部即可查看其运行情况。
¥Scroll to the top of this page to see it in action.