经典论坛's Archiver

baishui 发表于 2008-8-26 10:20

请问 css 里的 [] 是什么作用

例如下面一句,请问那个中括号 [id] 起到什么作用?
#outer[id]{position:static;display:table;}

uuucat 发表于 2008-8-26 10:21

很少见css里这样用[]的,这个不是程序里写参数的那个符号吗?:confused:

baishui 发表于 2008-8-26 10:27

#outer{position:relative;width:100%;height:100%;border:1px solid #000;}
/*for ie*/
#middle{position:absolute;top:50%;}
#inner{position:relative;top:-50%;width:100%;text-align:center;}
/*for firefox*/
#outer[id]{position:static;display:table;}
#middle[id]{position:static;display:table-cell;vertical-align:middle;}

oncean 发表于 2008-8-26 10:49

难道是FF里面特有的?
我也求解~

jterjiao 发表于 2008-8-26 10:54

我也想知道  留个脚印等待高手回答

thelucky 发表于 2008-8-26 10:57

属性选择符,CSS2.0的东西
可惜万恶的IE不支持

lhnlj2 发表于 2008-8-26 11:02

CSS里属性选择符

dxformat 发表于 2008-8-26 11:06

属性选择符

feigege 发表于 2008-8-26 11:20

我建议大家不要那么极端的研究某些东西,最基础的,最实用的才是最合适的。

hansir 发表于 2008-8-26 11:51

[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
        .outer[id=xx]{position:static;display:table; background:#00f}
        #outer[class=xx]{position:static;display:table; background:#f00}
</style>
</head>
<body>
<div class="outer" id="xx">蓝色理想</div>
<div id="outer" class="xx">蓝色理想</div>
</body>
</html>
[/html]

FreeCity 发表于 2008-8-26 12:28

css2.0

dcchan 发表于 2008-8-26 13:07

[quote]原帖由 [i]feigege[/i] 于 2008-8-26 11:20 发表 [url=http://bbs.blueidea.com/redirect.php?goto=findpost&pid=4179063&ptid=2881760][img]http://bbs.blueidea.com/images/common/back.gif[/img][/url]
我建议大家不要那么极端的研究某些东西,最基础的,最实用的才是最合适的。 [/quote]
晕,这也叫极端?
IE7开始支持高级选择器了。等着ie6被淘汰了,我就疯狂的使用高级选择器,把id,class统统删掉。

loveface 发表于 2008-8-26 13:53

一旦这些高级的CSS2选择器得到广泛支持,在代码里添加额外的DIV或CLASS的需求就会大大的减少。

feigege 发表于 2008-8-26 15:37

[quote]原帖由 [i]dcchan[/i] 于 2008-8-26 13:07 发表 [url=http://bbs.blueidea.com/redirect.php?goto=findpost&pid=4179324&ptid=2881760][img]http://bbs.blueidea.com/images/common/back.gif[/img][/url]

晕,这也叫极端?
IE7开始支持高级选择器了。等着ie6被淘汰了,我就疯狂的使用高级选择器,把id,class统统删掉。 [/quote]
你继续使用,疯狂使用。谢谢,不打扰你。

feigege 发表于 2008-8-26 15:41

[quote]原帖由 [i]loveface[/i] 于 2008-8-26 13:53 发表 [url=http://bbs.blueidea.com/redirect.php?goto=findpost&pid=4179429&ptid=2881760][img]http://bbs.blueidea.com/images/common/back.gif[/img][/url]
一旦这些高级的CSS2选择器得到广泛支持,在代码里添加额外的DIV或CLASS的需求就会大大的减少。 [/quote]
是吗,那你等着那天吧。我很确定告诉你,无论多久属性选择符都不会成为主流。

Sandyluo 发表于 2008-8-26 16:05

[quote]原帖由 [i]feigege[/i] 于 2008-8-26 11:20 发表 [url=http://bbs.blueidea.com/redirect.php?goto=findpost&pid=4179063&ptid=2881760][img]http://bbs.blueidea.com/images/common/back.gif[/img][/url]
我建议大家不要那么极端的研究某些东西,最基础的,最实用的才是最合适的。 [/quote]


顶!

wyysf 发表于 2008-9-5 16:40

任何事情都不要说的那么肯定
随着时间的标准会有变化

5ivedance 发表于 2008-9-7 01:35

基于属性的内容来格式化一个元素:
p[class="rant"] {
font-weight: bold;
text-transform: uppercase;
}
<p class=”rant“>
Hi, I’m 5ivedance.</p>
同样,
div[id="main"] {
float=left;
}
<div id=”main“><p>Hi, I’m 5ivedance.</p></div>

页: [1]



Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.