在另一个内继承风格
- 内继承风格
我在一些 HTML 中具有以下结构:
<ul class="li_inline"> <li> <ul class="li_block"> <li>Stuff</li> <li>Stuff under stuff</li> </ul> </li> <li> <ul class="li_block"> <li>Stuff</li> <li>Stuff under stuff</li> </ul> </li> </ul>
使用这样的 CSS:
.li_inline li { display: inline; } .li_block li { display: block; }
我希望发生的情况是让两个内部 并排,但任何
< li>
在它们内部,彼此位于下面。这样我就可以并排获得侧边栏和主体,但其中的元素表现正常(即一个在另一个之下)。
有人可以建议我使用一些 CSS,以便内部 (li_block
) 列表的
元素显示为块元素,但
;
本身并排显示?谢谢,
詹姆斯
I have the following structure in some HTML:
<ul class="li_inline"> <li> <ul class="li_block"> <li>Stuff</li> <li>Stuff under stuff</li> </ul> </li> <li> <ul class="li_block"> <li>Stuff</li> <li>Stuff under stuff</li> </ul> </li> </ul>
With the CSS like this:
.li_inline li { display: inline; } .li_block li { display: block; }
What I would like to happen is to have the two inner <ul>
s side by side, but any <li>
s inside them to be below each other. This is so I can get a sidebar and main body side by side, but elements inside them behave normally (ie. one below the other).
Can someone suggest some CSS I can use so that the inner (li_block
) lists' <li>
elements are displayed as block elements, but the <ul>
s themselves are displayed side by side?
Thanks,
James
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
使用重置规则。
在您的情况下,使用
!important
可以完成您的工作。但尽量不要使用它更新解决
方案: http://jsfiddle.net/Starx/KHjmP/ ( FF3+、Safari 4+、IE8+)
Use a reset rule.
In your case using the
!important
can get your job done. But try not to use itUPDATE
Solution: http://jsfiddle.net/Starx/KHjmP/ (FF3+, Safari 4+, IE8+)
它不漂亮,但你明白了它的要点:)
it ain't pretty but you get the jist of it :)
这对我有用:
This worked for me:
您应该能够执行如下简单的操作。我在 Firefox、Chrome 和 IE7 中进行了测试。
http://jsfiddle.net/fzBnG/
You should be able to do something as simple as the following. I tested it in Firefox, Chrome and IE7.
http://jsfiddle.net/fzBnG/
首先感谢大家的帮助!我真的很抱歉看起来我忽略了您的辛勤努力,但我已经记下了您的所有答案,而且它们都非常方便。
我想出的解决方案是简单地对两个内部的
ul
使用display: inline-block
,而外部的则保留默认值。再次感谢大家的帮助。
詹姆斯
First, thanks for everyone's help! I'm really sorry to look like I'm ignoring your hard efforts away, but I have taken note of all your answers, and they're all very handy.
The solution I have come up with is to simply use
display: inline-block
for both innerul
s, with the outer one left default.Once again, thanks for your help everyone.
James