css样式怎么写

html-css06

css样式怎么写,第1张

css样式是HTML的一个补充,简单的css使用样式如下:

<html>

<body>

<div id=div></div>

</body>

<style type="text/css">

width:300px//设置div的宽度300像素

height:500px//设置div高度500像素

background-color:red//设置div的背景颜色为红色

</style>

</html>

css代码位于style之间,详细的css代码解释见代码注释。

<html>

<head>

<style type="text/css">

a.top:link {font-family: 宋体} /*链接字体*/

a.top:link {font-weight: normal} /*设置链接文字中的字符粗细*/

a.top:link {font-size: 12} /*设置链接文字的大小*/

a.top:link {text-decoration: none} /*设置链接文字没有下划线*/

a.top:hover {text-decoration: underline} /*鼠标放在链接上时有下划线*/

a.top:link {color: #000000} /*设置链接文字的颜色*/

a.top:visited {color: #000000} /*访问过的链接*/

a.top:hover {color: #B50000} /*鼠标放在链接上字体的颜色*/

a.tj:link {font-family: 宋体}

a.tj:link {font-weight: normal}

a.tj:link {font-size: 12}

a.tj:link {text-decoration: none}

a.tj:hover {text-decoration: none}

a.tj:link {color: #000000}

a.tj:visited {color: #0000ff}

a.tj:hover {background: #FFFFCC}

h1 {font-size:12px} 

h1 {font-family: "宋体"} 

h1 {font-weight: normal}

h1 {color: #000000}

h2 {font-size:14px} 

h2 {font-family: "宋体"} 

h2 {font-weight: normal}

h2 {color: #000000}

h3 {font-size:24px} 

h3 {font-weight: 1}

h3 {color: #000000}

body {

        margin-top: 1px /*上边距*/

        margin-bottom: 1px /*下边距*/

}

</style>

<meta http-equiv="Content-Type" content="text/html charset=gb2312"></head>

<body>

<p>Mouse over the links to see them change layout.</p>

<p><b><a href="default.asp" target="_blank" class="top">电脑对怀孕其实没啥影响</a></b></p>

<p><b><a href="default.asp" target="_blank" class="tj">电脑对怀孕其实没啥影响</a></b></p>

<h1>电脑对怀孕其实没啥影响</h1>

<h2>电脑对怀孕其实没啥影响</h2>

<h3>电脑对怀孕其实没啥影响</h3>

</body>

</html>

<html>

<head>

     <style type="text/css">

         .time span{

             line-height: 80px

             vertical-align: middle

             font-weight: bold

             color: white

             background-color: grey

             font-size: 60px

             padding:6px

         }

         span.sep {

             background-color: white

             color: grey

         }

     </style>

</head>

<body>

<div class = "time">

    <span>23</span>

    <span class ="sep">:</span>

    <span>30</span>

    <span class ="sep">:</span>

    <span>32</span>

</div>

</body>

</html>