【发布时间】:2015-11-17 17:57:37
【问题描述】:
这是一个顶级问题,更多的是基于我对 css 的无知。我正在尝试在 css 中创建两种段落样式,一种字体大小为 20px,另一种字体大小为 14px。但是,无论我做什么,字体都是一样的。附件是我现在正在做的一个例子,如果有人能指出我的解决方案,我将不胜感激。为简洁起见,我省略了不必要的代码。
html 代码如下所示
<p>This is the html section with 20 px font</p>
<p class="new_font"> This is the html section with 8px font</p>
/* I have also tried this with a <div class="new_font"> and and <p id="new_font>"*/
css 代码如下所示
p {
/*text-indent: 1.5em;*/
font: 20px Helvetica, Sans-Serif;
color: white;
overflow: hidden;
padding: 15px;
text-align: justify;
background: rgb(0, 0, 0,0.3); /* fallback color */
background: rgba(0, 0, 0, 0.7);
}
p new_font {
/*text-indent: 1.5em;*/
font: 14px Helvetica, Sans-Serif;
color: white;
overflow: hidden;
padding: 15px;
text-align: justify;
background: rgb(0, 0, 0,0.3); /* fallback color */
background: rgba(0, 0, 0, 0.7);
}
【问题讨论】:
-
只需将
p new_font更改为p.new_font -
也不需要重复所有的css只需更改
font-sizejsfiddle.net/2Lzo9vfc/114