我想要的是绿色背景刚好在文本的后面,而不是100%的页面宽度。这是我当前的代码:
h1 { text-align:中心; 背景颜色:绿色; } <h1>埃里克·琼斯最后的遗嘱和遗嘱<h1>
我想要的是绿色背景刚好在文本的后面,而不是100%的页面宽度。这是我当前的代码:
h1 { text-align:中心; 背景颜色:绿色; } <h1>埃里克·琼斯最后的遗嘱和遗嘱<h1>
当前回答
可以使用html5标记标签内的段落和标题标签。
<p>lorem ipsum <mark>高光文本</mark> dolor sit.</p>
其他回答
HTML
<h1 class="green-background"> Whatever text you want. </h1>
CSS
.green-background {
text-align: center;
padding: 5px; /*Optional (Padding is just for a better style.)*/
background-color: green;
}
你可以使用HTML5 <mark>标记。
HTML:
<h1><mark>The Last Will and Testament of Eric Jones</mark></h1>
CSS:
mark
{
background-color: green;
}
H1是块级元素。你需要使用像span这样的东西,因为它是一个内联级元素(即:它不跨越整行)。
针对你的情况,我建议如下:
style.css
.highlight
{
background-color: green;
}
html
<span class="highlight">only the text will be highlighted</span>
可以使用html5标记标签内的段落和标题标签。
<p>lorem ipsum <mark>高光文本</mark> dolor sit.</p>
<h1 style=" font - family:宋体;">埃里克·琼斯最后的遗嘱< h1> .