如何使用css突出显示blockquote标签

时间:2015-02-17 01:40:32

标签: html css

我希望我的blockquote中的单词看起来像是用黑色使用css突出显示的。我不知道该怎么做。相反,黑色背后形成一个大的方形背景。

blockquote{
color:white;
background:black;}

它应该如下所示: enter image description here

2 个答案:

答案 0 :(得分:2)

使某些文字突出显示的标准方法是将background-color应用于一段内联文字,使用类似

的内容

.highlight {
    background-color: yellow;
}
<p>Hello this <span class='highlight'>is pluribum text </span> typed randomly</p>

你无法突出显示blockquote本身,因为它是一个块级元素,设置其背景颜色不会产生高光效果。如果您希望突出显示blockquote的整个文本,则必须将highlighted类应用于blockquote中的所有文本,以便它仍然是一个块元素及其内联内容可以有不同的风格

.highlight {
  color:white;
  background:black;
  line-height: 150%;
}
Hello testing something Hello testing something Hello testing something Hello testing something Hello testing something Hello testing something Hello testing something
<blockquote><span class="highlight">
 Hello testing something Hello testing something Hello testing something Hello testing something Hello testing something Hello testing something Hello testing something  
</span></blockquote>
 Hello testing something Hello testing something Hello testing something Hello testing something Hello testing something Hello testing something

答案 1 :(得分:0)

display:inline;添加到.blockquote的CSS。

(我假设您创建了一个名为&#39; blockquote&#39;的CSS类,因为您的样式声明在该单词前面有句点。如果您打算将其应用于标记blockquote当然你会删除这段时间。)