美国大停电事件 造人:请问css中的#号 是什么意思?

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/27 23:17:30
初学web标准,查看了一些网站的源代码,发现#,不理解。举例如下,一般在dreamweaver中自动生成的css代码为.style1,.style2等等

今看到腾讯拍拍网 www.paipai.com 的页面定义

#content{margin:0 auto;width:760px;text-align:left}
#foot{clear:both;float:left;margin-top:20px;width:100%;text-align:center}
#foot_link{margin:7px auto;border-bottom:1px solid #D7D7D7;padding-bottom:4px;width:760px}
#foot_list{border-right:#FEBB46 4px solid;border-left:#FEBB46 4px solid}
#foot_list #td_1{border-right:#FEBB46 1px solid}
#foot_list #td_2{border-right:#FEBB46 5px solid}
#foot_list #td_3{border-left:#FEBB46 1px solid}

不知道#号是什么意思

#是id选择器的标识:

用CSS布局主要用层"div"来实现,而div的样式通过"id选择器"来定义。例如我们首先定义一个层>>

<div id="menubar"></div>然后在样式表里这样定义:

#menubar {MARGIN: 0px;BACKGROUND: #FEFEFE;COLOR: #666;}
其中"menubar"是你自己定义的id名称。注意在前面加"#"号。

id选择器也同样支持派生,例如:

#menubar p { text-align : right; margin-top : 10px; }
这个方法主要用来定义层和那些比较复杂,有多个派生的元素。

以#content{margin:0 auto;width:760px;text-align:left}为例

下面一定有一个id为content的标签,这个标签里面的内容就引用了{}里的样式