爲什麼這個工作:CSS,爲什麼一件事情可以工作,而不是另一件事情?
<div style="background-color: #ccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #000;
padding: 10px;">testing 10,9,8,7
</div>
這不?
<div style="roundedCornerBox">
testing 10,9,8,7
</div>
當我創建了一個CSS文件,上面寫着:
body {
background-color: #FFFFFF;
text-align: center;
}
roundedCornerBox {
background-color: #ccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #000;
padding: 10px;
}
這裏是我的HTML代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title></title>
<link rel="stylesheet" href="lib/css/style.css" />
</head>
<body>
<div style="roundedCornerBox">
testing 10,9,8,7
</div>
<div style="background-color: #ccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #000;
padding: 10px;">
testing 10,9,8,7
</div>
</body>
</html>
http://www.w3.org/TR/REC-html40/present/styles.html#adef-style 樣式屬性的定義。 較少的技術和再次有用的w3schools細分的差異:http://www.w3schools.com/CSS/css_howto.asp – Kzqai 2010-03-01 23:50:46