CSS 问题,位置:绝对
我不知道如果父母有一个立场:绝对,我应该宣布什么样的立场。
这是代码,
<div id="new_map">
<div id="map_nbc_pop">
<div class="nm_bubbletop1"></div>
<div id="nm_bubblebg">
<ul class="nm_left">
<li><a href="#">Chetwynd</a></li>
<li><a href="#">Fort St James</a></li>
<li><a href="#">Fort St John</a></li>
</ul>
<ul class="nm_right">
<li><a href="#">McBride</a></li>
<li><a href="#">Prince George</a></li>
<li><a href="#">Prince Rupert</a></li>
</ul>
</div>
<div class="nm_bubblebelow1"></div>
</div>
</div>
这是示例 CSS,我只是删除了其他内容以供查看...
#new_map { position: static }
#map_nbc_pop { position: absolute }
对我来说问题在于 .nm_bubbletop1、#nm_bubblebg、.nm_bubblebelow1 我该使用什么位置?因为它们在浏览器上没有正确分层。
<div class="nm_bubblebelow1"></div>
<div class="nm_bubbletop1"></div>
<div id="nm_bubblebg"></div>
我想要的是这个,
<div class="nm_bubbletop1"></div>
<div id="nm_bubblebg"></div>
<div class="nm_bubblebelow1"></div>
谢谢!
I don't know what kind of position shall I announce if the parent has a position: absolute.
Here's the code,
<div id="new_map">
<div id="map_nbc_pop">
<div class="nm_bubbletop1"></div>
<div id="nm_bubblebg">
<ul class="nm_left">
<li><a href="#">Chetwynd</a></li>
<li><a href="#">Fort St James</a></li>
<li><a href="#">Fort St John</a></li>
</ul>
<ul class="nm_right">
<li><a href="#">McBride</a></li>
<li><a href="#">Prince George</a></li>
<li><a href="#">Prince Rupert</a></li>
</ul>
</div>
<div class="nm_bubblebelow1"></div>
</div>
</div>
here's the sample CSS, I just remove the other for viewing...
#new_map { position: static }
#map_nbc_pop { position: absolute }
The problem for me is in .nm_bubbletop1, #nm_bubblebg, .nm_bubblebelow1
What position shall I use? Because they are not properly layered on the browser.
<div class="nm_bubblebelow1"></div>
<div class="nm_bubbletop1"></div>
<div id="nm_bubblebg"></div>
What I want is this,
<div class="nm_bubbletop1"></div>
<div id="nm_bubblebg"></div>
<div class="nm_bubblebelow1"></div>
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您需要在不更改代码的情况下更改
的显示方式,position:absolute 是您的最佳选择:
话虽这么说,但它很 hacky。如果您可以在 HTML 中按照您想要的方式对它们进行排序,那么您的生活将会更轻松。
If you need to change how the
<div>
's appear without changing the code, position: absolute is your best option:That being said, it's hacky. If there's anyway you can just order them the way you want in the HTML, it'll make your life easier.
如果您给
#new_map
一个relative
位置,然后给您想要安排绝对位置的子项,这将使这些子项的位置相对于父项#new_map
即坐标原点将是#new_map
的左上角。然后,您可以根据#new_map
的位置更改子级的堆叠顺序 (z-index) 或位置(上、左、右、下)。if you give
#new_map
a position ofrelative
and then the children you want to arrange a position of absolute this will make the position of those children relative to the parent#new_map
ie your origin for coordinates will be the top left corner of#new_map
. You can then change the stacking order (z-index) or positioning (top, left, right, bottom) of the children as you like based on where#new_map
is.我想这就是你的意思>
还有 css:
这使得菜单变得灵活,并且顶部和底部始终就位。中间的边距使其无缝连接。
小提琴:http://jsfiddle.net/fmDhn/1/
This is what you mean i think >
And css:
This makes the menu flexible, and the top and bottom are always in place. The margin of the middle makes it seamlessly connect.
The fiddle: http://jsfiddle.net/fmDhn/1/