1. 程式人生 > >CSS描述了網頁的布局

CSS描述了網頁的布局

cnblogs rmi -c idt align center margin class 註釋

1.CSS格式

CSS 規則由兩個主要的部分構成:選擇器,以及一條或多條聲明;CSS聲明總是以分號(;)結束,聲明組以大括號({})括起來:

.style{color:red;text-align:center;}

2.CSS 註釋:/**/

3.CSS 選擇器
HTML元素以id屬性來設置id選擇器,CSS 中 id 選擇器以 "#" 來定義

#terminal
{
text-align:center;
color:red;
}

class 選擇器在HTML中以class屬性表示, 在 CSS 中,類選擇器以一個點"."號顯示

.center {text-align:center;}

指定特定的HTML元素使用class

p {text-align:center;}


4.CSS 創建
插入樣式表的方法有三種:內聯樣式)Inline style > (內部樣式)Internal style sheet >(外部樣式)External style sheet > 瀏覽器默認樣式

外部樣式表(External style sheet)

<head>
<link rel="stylesheet" href="../css/box.css">
</head>

內部樣式表(Internal style sheet)

<head>
<style>
.bigBox{overflow:hidden;left: 0px; right: 0px;width: 
100%;} .LeftBox { float: left;width: 63%; height:98%; margin-top:1%;margin-bottom:1%;margin-left:1%;margin-right:1%;} .RightBox { float: left;width: 33%; height:98%; margin-top:1%;margin-bottom:1%;margin-left:1%;margin-right:1%;} .box { position: relative; background: #003; border-top: 1px solid #d2d6de; border
-top-color: #383838; } </style> </head>

內聯樣式(Inline style)

<div id="full" class="bigBox" style="height:1000px;">

CSS描述了網頁的布局