学点css基础

时间:2024-03-24 00:06:38

中午时间学点css,附带http://www.w3cschool.cc/css/css-tutorial.html这个链接!

中午的时间学了这些东西!如下图:

学点css基础

附带代码:

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>css_1</title>
</head>
<style>
p{
/*这是设置颜色的*/
color: red;
/*这是设置对齐方式的*/
text-align: center; }
/*CSS Id 和 Class */
/*HTML元素以id属性来设置id选择器,CSS 中 id 选择器以 "#" 来定义。ID属性不要以数字开头,数字开头的ID在 Mozilla/Firefox 浏览器中不起作用。*/
#para1
{
text-align: center;
color: red;
}
/*class 选择器用于描述一组元素的样式,class 选择器有别于id选择器,class可以在多个元素中使用。*/ /*class 选择器在HTML中以class属性表示, 在 CSS 中,类选择器以一个点"."号显示: */
.center
{
text-align: center; } /*-- 你也可以指定特定的HTML元素使用class。类名的第一个字符不能使用数字!它无法在 Mozilla 或 Firefox 中起作用。 */
p.center
{
text-align:center;
}
/*多重样式:如果某些属性在不同的样式表中被同样的选择器定义,那么属性值将从更具体的样式表中被继承过来。/*/
/*多重样式将层叠为一个:因此,内联样式(在 HTML 元素内部)拥有最高的优先权,这意味着它将优先于以下的样式声明: 标签中的样式声明,外部样式表中的样式声明,或者浏览器中的样式声明(缺省值)。*/ </style> <body>
<!-- 调用P这个selector -->
<p>Hello World!</p>
<p id="para1">Hello World!</p>
<!-- 在以下两个的例子中,所有拥有 center 类的 HTML 元素均为居中。 -->
<h1 class="center">标题居中</h1>
<p class="center">段落居中</p>
<!-- 在以下实例中, 所有的 p 元素使用 class="center" 让该元素的文本居中: -->
<p class="center">This paragraph will be center-aligned</p>
<p style="color: sienna;margin-left: 20px;" > This is a paragraph.</p> </body>
</html>
 /*不要在属性值与单位之间留有空格。假如你使用 "margin-left: 20 px" 而不是 "margin-left: 20px" ,
它仅在 IE 6 中有效,但是在 Mozilla/Firefox 或 Netscape 中却无法正常工作。*/
hr{color: sienna;}
p{margin-left: 20px;}
body{border-image: url("/images/back40.gif");}