嵌套的div样式表问题 [英] nested div stylesheet question

查看:52
本文介绍了嵌套的div样式表问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有嵌套的div组合,我可以只为特定的嵌套组合调用

吗?


这是3个列表< li> ;,在一个页面上,需要不同的样式。


< div id = list1>< li> < a id =" t1" href = ...> main< / a>< / li>< div>


< div id = list2>< li> < a id =" t1" href = ...> main< / a>< / li>< div>


< div id = list3>< li> < a id =" t1" href = ...> main< / a>< / li>< div>

我需要< li>在menu1中宽度为10%;和

< li>在menu2和menu3中宽度为100%。

我怎么称呼这个?


#list1..li ... ????? ? {

宽度:10%

}


#list2 + 3,li ?????? {

宽度:100%

}


谢谢,

Theo

解决方案

2005年2月21日星期一14:48:29 -0600,theo< th ** @ nospam.com>写道:

如果我有嵌套的div组合,我可以只为特定的嵌套组合调用
吗?

这是3个列表< li>,在一个页面上,需要不同的样式。

< div id = list1>< li> < a id =" t1" href = ...> main< / a>< / li>< div>

< div id = list2>< li> < a id =" t1" href = ...> main< / a>< / li>< div>

< div id = list3>< li> < a id =" t1" href = ...> main< / a>< / li>< div>


例如,这不是嵌套的意思。嵌套会像

< div>

< div>

< div>< / div>

< / div>

< / div>


就像第一个div包含其他人而第二个div只包含

中间一个。


其次,您是否尝试验证该标记?我敢打赌你不会。把清单放在

项目中,就像那样不聪明。列表项是应包含在有序列表或无序列表中的元素,例如


< ul>

< li>< / li>

< li>< / li>

< li>< / li>

< / ul>

我需要< li>在menu1中宽度为10%;和
< li>在menu2和menu3中为100%宽度。




你已经设置了一个带有宽度的父元素,所以10%和100%

实际上可以与之相关,是吗?


我在你提供的代码中的任何地方都没有看到menu1,所以我不得不猜测一些/>
这里。我的猜测是,这就是你要做的事情(不要使用空格作为

起始字符;如果需要,可以在元素上设置合适的填充):


< ul id =" menu">

< li class =" narrow">< a id =" t1" href = ...> main< / a>< / li>

< li>< a ...>某事< / a>< / li>

< li>< a ...>别的< / a>< / li>

< / ul>


ul#menu {width:


长度; }


#menu li {width:100%; }


#menu li.narrow {width:10%; }


-

, - - < - @ - PretLetters:''woest wyf'',遇见了vele interesses: - --------。

|博客| http://home.wanadoo.nl/b。 de.zoete / _private / weblog.html |

| webontwerp | http://home.wanadoo.nl/b。 de.zoete / html / webontwerp.html |

| zweefvliegen | http://home.wanadoo.nl/b。 de.zoete / html / vliegen.html |

` --------------------------- ----------------------- - < - @ ------------''

"西奥" <第** @ nospam.com>写道:

如果我有嵌套的div组合,我可以只为特定的嵌套组合调用
样式吗?


是的,如果他们有不同的等级和/或身份证明


if I have nested div combinations, can I call
for styles only to specific nested combos?

It''s 3 lists <li>, on one page, needing different styles.

<div id=list1><li> <a id="t1" href=...>main</a></li><div>

<div id=list2><li> <a id="t1" href=...>main</a></li><div>

<div id=list3><li> <a id="t1" href=...>main</a></li><div>
I need the <li> in menu1 to be 10% width; and the
<li> in menu2 and menu3 to be 100% width.
How would I call this one?

#list1..li...?????? {
width:10%
}

#list2+3,li?????? {
width:100%
}

Thanks,
Theo

解决方案

On Mon, 21 Feb 2005 14:48:29 -0600, theo <th**@nospam.com> wrote:

if I have nested div combinations, can I call
for styles only to specific nested combos?

It''s 3 lists <li>, on one page, needing different styles.

<div id=list1><li> <a id="t1" href=...>main</a></li><div>

<div id=list2><li> <a id="t1" href=...>main</a></li><div>

<div id=list3><li> <a id="t1" href=...>main</a></li><div>

For one, this is not what nested means. Nested would be like
<div>
<div>
<div></div>
</div>
</div>

Like the first div embraces both others and the second div embraces just the
middle one.

Secondly, did you try validate that markup? I bet you it won''t. Putting list
items in the wild like that isn''t smart. List items are elements that should be
contained in either an ordered list or an unorderd list, like

<ul>
<li></li>
<li></li>
<li></li>
</ul>
I need the <li> in menu1 to be 10% width; and the
<li> in menu2 and menu3 to be 100% width.



You''ve set something of a parent element up with a width, so the 10% and 100%
actually can relate to that, did you?

I don''t see a menu1 anywhere in the code you provided, so I have to guess some
here. My guess is, this is what you are trying to do (don''t use a space as a
starting character; set an appropriate padding on the element if you need it):

<ul id="menu">
<li class="narrow"><a id="t1" href=...>main</a></li>
<li><a ...>something</a></li>
<li><a ...> something else</a></li>
</ul>

ul#menu { width:


length; }

#menu li { width:100%; }

#menu li.narrow { width:10%; }

--
,-- --<--@ -- PretLetters: ''woest wyf'', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------''


"theo" <th**@nospam.com> wrote:

if I have nested div combinations, can I call
for styles only to specific nested combos?
Yes if they have different class and/or id a


这篇关于嵌套的div样式表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆