Html 在 div 中设置 h1 样式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19766401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 15:01:09  来源:igfitidea点击:

style h1 inside a div

htmlcss

提问by user2952265

I want to style a h1 headline inside a div, but no matter what I try it always remains bold.

我想在 div 中设置 h1 标题的样式,但无论我尝试什么,它始终保持粗体。

js fiddle

js小提琴

html

html

<div class="header">
<h1> Hello World </h1>

css

css

.header h1{
font-style: normal;
color: grey;
}

采纳答案by álvaro González

font-stylehas nothing to do with bold:

font-style无关大胆

The font-style CSS property allows italic or oblique faces to be selected within a font-family.

font-style CSS 属性允许在字体系列中选择斜体或斜面。

You want font-weightinstead:

你想font-weight,而不是

The font-weight CSS property specifies the weight or boldness of the font. However, some fonts are not available in all weights; some are available only on normal and bold.

font-weight CSS 属性指定字体的粗细。但是,某些字体并非适用于所有粗细;有些仅在正常和粗体上可用。

回答by melancia

You need font-weight:

你需要font-weight

.header h1{
    color: grey;
    font-weight: normal;
}

Demo: http://jsfiddle.net/h6EtB/2/

演示:http: //jsfiddle.net/h6EtB/2/