css网站排版中的3中字体样式

2021-01-13 10:53:15

在网页制作时,我们需要控制网页中字体的大小,颜色,粗细等,通过情况下,我们会使用以下的CSS样式去控制这个字体的样式:


字体的大小:font-size:14px;

字体的颜色:color:#FFF;

字体的粗细:font-weight:bold;


  合法的字体,更后我们有技术(浏览器支持),优化web字体。我使用的一些更受欢迎的Google web的字体。


  “Enriqueta” + “Georgia”



  这是一个大胆和高对比度的风格。注意到红色突出显示颜色可用于链接、子弹、按钮等。


  链接谷歌字体:

 


  这种风格的CSS代码:


h1 {

color: #262626;

font-family: "Enriqueta", serif;

font-size: 44px;

line-height: 48px;

margin: 0 0 30px;

}

h2 {

color: #262626;

font-family: "Enriqueta", serif;

font-size: 32px;

font-weight: normal;

line-height: 42px;

margin: 0 0 24px;

padding: 12px 0 0;

}

h3 {

color: #c73036;

font-family: "Enriqueta", serif;

font-size: 18px;

font-weight: bold;

line-height: 24px;

margin: 0 0 24px;

padding: 12px 0 0;

text-transform: uppercase;

}

p {

color: #2f2f2f;

font-family: Georgia, serif;

font-size: 17px;

line-height: 24px;

margin: 0 0 24px;

}

.post-info {

color: #aaaaaa;

font-family: Georgia, serif;

font-size: 12px;

font-style: italic;

line-height: 12px;

padding: 24px 0;

}

.post-info a {

color: #c73036;

font-family: "Enriqueta", serif;

font-style: normal;

font-weight: bold;

text-decoration: none;

text-transform: uppercase;

}


  “Playfair Display” + “Open Sans”



  这是一个优雅的风格与无衬线和无衬线字体的组合。因为标题字体不是如此强大,我用颜色突出了它。如果你想提高你的网站的性能,你可以很容易地替换“Open Sans”与另一个无衬线字体。记住,每一个外部字体,都会增加你网站的加载时间。


  链接谷歌字体:

 

  这种风格的CSS代码:


h1 {

color: #c65c3f;

font-family: "Playfair Display", serif;

font-size: 40px;

font-weight: normal;

line-height: 48px;

margin: 0 0 26px;

}

h2 {

color: #363636;

font-family: "Playfair Display", serif;

font-size: 26px;

font-weight: normal;

line-height: 36px;

margin: 0 0 18px;

padding: 12px 0 0;

}

h3 {

color: #c65c3f;

font-family: "Open Sans", sans-serif;

font-size: 16px;

font-weight: bold;

line-height: 18px;

margin: 0 0 18px;

padding: 12px 0 0;

text-transform: uppercase;

}

p {

color: #363636;

font-family: "Open Sans", sans-serif;

font-size: 14px;

line-height: 18px;

margin: 0 0 18px;

}

.post-info {

color: #b8b8b8;

font-family: "Open Sans", sans-serif;

font-size: 12px;

font-weight: bold;

line-height: 12px;

margin: 0 0 18px;

text-transform: uppercase;

}

  “Marvel” + “Lucida Sans”



  这是一个现代和轻型排版风格。保持完美的基线网格可能是困难的,因为不同的浏览器渲染引擎,但你可以注意文本的示例引用与段落的行。


  链接谷歌字体:

 


  这种风格的CSS代码:


h1 {

border-bottom: 5px solid #f0f1e7;

color: #b2b888;

font-family: "Marvel", sans-serif;

font-size: 54px;

font-weight: normal;

line-height: 48px;

margin: 0 0 26px;

padding: 0 0 24px;

text-transform: uppercase;

}

h2 {

color: #b2b888;

font-family: "Marvel", sans-serif;

font-size: 28px;

font-weight: normal;

line-height: 30px;

margin: 0 0 18px;

padding: 12px 0 0;

text-transform: uppercase;

}

p {

color: #363636;

font-family: "Lucida Sans", sans-serif;

font-size: 16px;

line-height: 24px;

margin: 0 0 24px;

}

blockquote {

border-left: 5px solid #f0f1e7;

color: #b2b888;

float: right;

font-family: "Marvel", sans-serif;

font-size: 20px;

font-style: italic;

line-height: 24px;

margin: 0 0 24px 30px;

padding-left: 30px;

width: 150px;

}

  结论


  我希望这些字体风格的例子对你有用。您也可以在未来项目中使用它们作为指导原则来创建自己的风格。记住,避免用太多的字体和颜色,尽量保持简洁。在网站建设中一定要时刻保持把控排版的整体风格。