Css

来源:互联网 发布:数控编程培训学校 编辑:程序博客网 时间:2024/05/26 20:22

浏览器默认的样式表、外部样式表、内嵌样式表(在<head>内)、行内样式表(html元素内)。

外部样式表(可应用到很多页面)

<head>

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

</head>

内嵌样式表(只应用于当前页面)

<head>

    <style type="text/css">

        hr{color:red}

        p{text-align:center}

    </style>

</head>

行内样式表(只是用于一行)

<p style="color:red;text-align:center">行内样式</p>

由选择器、属性和值组成:selector{property:value}。若有多个元素,用分号分开。
P{text-align:center;color:red}。
选择器组合:h1,h2,h3,h4,h5,h6{color:green}

类选择器

样式如下:

p.right{text-align:right}

p.center{text-align:center}

使用:

<p class="right">此段落右对齐</p>

<p class="center">此段落中心对齐</p>

id选择器

P#right{text-align:right}

P#center{text-align:center}

使用:

<p id="right">此段落右对齐</p>

<p id="center">此段落中心对齐</p>



原创粉丝点击