css三种样式

一。行内样式
(不多使用)css

<h1>静夜思</h1>
    <p>床前明月光,</p>
    <p style="color: red;">疑是地上霜。</p>
    <p style="color: #0000FF;font-size: 1rem;">举头望明月,</p>
    <p>低头思故乡。</p>

二。内嵌样式
(经常使用于中小型网页)ide

<head>
    <meta charset="utf-8">
    <title>
    </title>
    <style type="text/css">
        h1{color: red;}
        #aa{color: #0000FF;}
        .bb{color: #00FF00;}
    </style>
</head>
<body>
    <h1>静夜思</h1>
    <p id="aa">床前明月光,</p>
    <p class="bb">疑是地上霜。</p>
    <p>举头望明月,</p>
    <p>低头思故乡。</p>
</body>

三。外部连接
(经常使用于大型网页)
新建.css文件,在css文件中不须要写<style>
链接方式1<link rel="stylesheet" type="text/css" href=".css"/>
链接方式2<style type="text/css">@import url("
.css");</style>url

样式表中:code

.red{color: red;}
  #green{color: green;}

链接方式1utf-8

<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/样式表.css"/>
</head>
<body>
    <h1>静夜思</h1>
    <p class="red">床前明月光,</p>
    <p>疑是地上霜。</p>
    <p id="green">举头望明月,</p>
    <p>低头思故乡。</p>
</body>

链接方式2rem

<head>
    <meta charset="utf-8">
    <title></title>
    <style type="text/css">
          @import url("样式表.css");
    </style>
</head>
<body>
    <h1>静夜思</h1>
    <p class="red">床前明月光,</p>
    <p>疑是地上霜。</p>
    <p id="green">举头望明月,</p>
    <p>低头思故乡。</p>
</body>
相关文章
相关标签/搜索