freeCodeCamp/guide/chinese/css/tutorials/introduction-to-css/index.md

1.1 KiB
Raw Blame History

title localeTitle
Introduction to CSS CSS简介

CSS简介

什么是CSS

层叠样式表CSS描述了页面上的html应该如何显示。

在CSS开发人员在页面的每个节点上使用属性或特殊标记应用样式之前。这使得标记重复并且容易出错。

CSS允许选择器描述每个匹配内容的外观。

body { 
    font-size: 15px; 
 } 
 
 a { 
    color: rebeccapurple; 
    text-decoration: underline; 
 } 

使用CSS

外部样式表允许许多页面共享相同的样式。

<link href="styles.css" rel="stylesheet" type="text/css"> 

内部样式表将CSS应用于页面上的所有匹配标记。

<style> 
    h1 { 
        font-family: sans-serif; 
        margin-bottom: 1.5em; 
    } 
 </style> 

内联CSS将样式应用于单个标记。

<img src="..." style="border: 1px solid red;" /> 

更多信息: