css之心得

来源:互联网 发布:c语言编程题库 编辑:程序博客网 时间:2024/06/14 20:40

css的选择符分为以下三种:

1.HTML选择符

示例:table{border:1px solid red}这里设置的是表格的而不是文字。

demo.html //代码片段 ---------> a.css Table {border: 1px solid red}              

<body>
<table  border="1">
  <tr>
   <td>你好</td>
   <td>我很好</td>
  </tr>
<tr>
   <td>你吃了吗</td>
  <td>还没</td>
  </tr>
</table>
</body>

显示效果:

2.类选择符

css样式为 .center{text-align:center;}

引用方式<p class="center">xxxx</p>,xxxx会居中,示例略。

3.ID选择符

css样式:#ID{color:red;}(当ID=red时)

引用方式:<p id="red">xxxx</p>,xxxx的颜色是红色。示例略。

附加;逗号连接的表示共用;空格表示交集使用。

例如:h1,h2{color:blue;}--->共用;

           table a{color:green}--->交集使用

css的调用方式分为以下三种:

1.内嵌样式

<h1 style="font-size:20px;color:yellow;">xxx</h1>

2.内部样式:在head中写css样式

<style type="text/css">

      p{color:red;text-align:center;}

</style>

3.外部样式

单独成一个xx.css文件,引用方式为:在head中写<link rel="stylesheet" type="text/css" href="..x.css"->此为相对路径

0 0
原创粉丝点击