按钮¶
¥Buttons¶
Material for MkDocs 为主要和次要按钮提供了专用样式,可添加到任何链接、 label或button元素。这对于带有专用行动号召的文档或登录页面尤其有用。
¥Material for MkDocs provides dedicated styles for primary and secondary buttons that can be added to any link, label or button element. This is especially useful for documents or landing pages with dedicated call-to-actions.
配置¶
¥Configuration¶
此配置允许使用简单的语法向所有内联和块级元素添加属性,从而将任何链接转换为按钮。将以下几行添加到mkdocs.yml中:
¥This configuration allows to add attributes to all inline- and block-level elements with a simple syntax, turning any link into a button. Add the following lines to mkdocs.yml:
查看其他配置选项:
¥See additional configuration options:
用法¶
¥Usage¶
添加按钮¶
¥Adding buttons¶
要将链接渲染为按钮,请在其后添加花括号,并添加.md-button类选择器。按钮将采用所选的主色和强调色(如果处于活动状态)。
¥In order to render a link as a button, suffix it with curly braces and add the .md-button class selector to it. The button will receive the selected primary color and accent color if active.
添加主要按钮¶
¥Adding primary buttons¶
如果您想要显示一个填充的主按钮(就像在 Material for MkDocs 的登录页面上一样),请同时添加.md-button和.md-button--primary CSS 类选择器。
¥If you want to display a filled, primary button (like on the landing page of Material for MkDocs), add both, the .md-button and .md-button--primary CSS class selectors.
添加图标按钮¶
¥Adding icon buttons¶
当然,可以使用图标语法和任何有效的图标短代码将图标添加到所有类型的按钮中,只需通过我们的图标搜索按几次键就可以轻松找到它们。
¥Of course, icons can be added to all types of buttons by using the icon syntax together with any valid icon shortcode, which can be easily found with a few keystrokes through our icon search.