简体   繁体   English

在 Markdown 中改变颜色<mark>标签</mark>

[英]Changing colour in Markdown <mark> tag

I currently discovered the markdown element, which lets me mark some text我目前发现了 markdown 元素,它可以让我标记一些文本

<mark>Marked text</mark>

This results in this very nice looking pdf-text:这导致了这个非常漂亮的 pdf 文本:

在此处输入图像描述

But how do I change the colour from it's default yellow to another colour?但是如何将颜色从默认的黄色更改为另一种颜色?

The mark tag is not for Markdown, but to mark or highlight text for notation purposes. 标记标签不是用于 Markdown,而是为了标记或突出显示文本。 It essentially is used to make text appear to have been highlighted with a highlighter, which explains the yellow background.它本质上是用来使文本看起来像是用荧光笔突出显示的,这解释了黄色背景。 Using the inspect tool in my browser, I see that the default styles for mark are:在我的浏览器中使用检查工具,我看到mark的默认 styles 是:

mark {
  background-color: yellow;
  color: black;
}

So, to change the color, define some CSS.因此,要更改颜色,请定义一些 CSS。 For example:例如:

mark {
  background-color: GreenYellow;
}

i would suggest something like this (using inline css).我会建议这样的事情(使用内联css)。 Note that i used !important because in some browsers it may be necessary to force the process.请注意,我使用!important是因为在某些浏览器中可能需要强制执行该过程。

 <mark style="background: #00ced1!important">Marked text</mark>

alternatively, something like this (using external css).或者,像这样的东西(使用外部CSS)。

 mark {background: red!important}
 <mark>Marked text</mark>

in this case the property is applied to all the mark tags in the webpage.在这种情况下,该属性将应用于网页中的所有标记标签
While this method works and is absolutely legitimate, it would be better, and more conventional, to use a css property like this:虽然此方法有效且绝对合法,但使用如下 css 属性会更好,也更传统:

 <p>this is a pretty paragraph with some <span style="background: blue">marked text</span></p>

hope this helped:) 希望这有帮助:)

You can write你可以写

<mark style="background-color:burlywood;">Marked text</mark>

You can replace "burlywood" to any color of your choice.您可以将“burlywood”替换为您选择的任何颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM