css入门基础知识

来源:互联网 发布:宝日龙梅 知乎 编辑:程序博客网 时间:2024/05/20 19:33

属性的值大于一个单词,要加上引号。

  • 外部样式表
    <link href = "mycss.css" type="text/css" rel = "stylesheet">

href是css文件,类型是text/css,rel是当前文档与外部文档的关系。

  • 内部样式表
    <style>        body{            color:red;        }    </style>

对html内部的标签进行样式化。
1. 选择器分组

h1, h2, p{    color: red;}

表示h1,h2,p标签的文本颜色全是红色的。
2. 继承

h1{    color: red;}body{    color: bisque;}

标签有单独自己的颜色,显示自己的,没有的显示body的。
3. 派生选择器

可以对派生的标签进行更改样式,而不影响其他的。

<p> <strong>this is p strong</strong></p><ul>    <li>        <strong>this is li strong</strong>    </li></ul><h1><strong>this is h1 strong </strong></h1><h2><strong>this is h2 strong </strong></h2>
p strong{     color:red; }li strong{    color:blue;}strong{    color:yellow;}

结果第一个是红色,第二个是蓝色,其余两个是黄色。

原创粉丝点击