简体   繁体   English

相互定位div

[英]Positioning divs on each other

I have so much trouble figuring out where my mistake are. 我很难弄清楚我的错误在哪里。 I want to build website with some divs on the right to each other...later there should be a horizontal navigation which automatically scroll to the right via anchors. 我想建立一个在彼此右边有一些div的网站...后来应该有一个水平导航,它会自动通过锚点滚动到右边。 Anyways...each div has an image in the background and a container with some text. 无论如何...每个div在背景中都有一个图像,并带有一些文本的容器。 The navigation menu is fixed and is always displayed. 导航菜单是固定的,并且始终显示。

My trouble: Why is the text container not showing up on the first div? 我的麻烦:为什么文本容器没有显示在第一个div上? Please see my fiddle on http://jsfiddle.net/pvvFR/ 请在http://jsfiddle.net/pvvFR/上查看我的小提琴

Thank you in advance for reading and if so...for answering 在此先感谢您的阅读,如果可以的话……感谢您的答复

If I did got you right, if you use img to set a background (which I think is not good at all), you should exclude it from the common layer (for example position:absolute ), so the content could overlay it. 如果我做对了,如果您使用img设置背景(我认为一点也不好),则应将其从公共层中排除(例如position:absolute ),以便内容可以覆盖它。 Your problem is not in text, but in image. 您的问题不是文字,而是图像。

try to have each container a unique class and replace with for example and put the image to div background like 尝试使每个容器具有唯一的类并替换为例如,然后将图像放置到div背景中,例如

background:url('http://www.wiesenhof-online.de/upload/Chicken-Ribs-BBQ-quer.jpg');

http://jsfiddle.net/pvvFR/10/ http://jsfiddle.net/pvvFR/10/

Is this something like that a solution 这是解决方案吗

http://jsfiddle.net/pvvFR/7/ I've put a position absolute on you slider http://jsfiddle.net/pvvFR/7/我已将绝对位置放在滑块上

and i've put your container div out of the slider 而且我已经将您的容器div移出了滑块

EDIT : 编辑:

Look at this: http://jsfiddle.net/pvvFR/13/ everything is relative And i've given a height to your slider, and position your container to a negative top 看一下这个: http : //jsfiddle.net/pvvFR/13/一切都是相对的我已经为滑块指定了高度,并将容器放置在负值顶部

Well, answer to your question about the REASON behind this happening is that Z-INDEX only works with positioned elements and as you are not positioning your image element that's why 'some text' is buried behind the image and its z-index doesn't take effect. 好吧,对于这种情况背后的原因,您的回答是Z-INDEX仅适用于定位的元素,而您未定位图像元素,这就是为什么“某些文本”被掩埋在图像的后面而其z索引却没有的原因生效。

Check this. 检查一下。 http://jsfiddle.net/pvvFR/14/ http://jsfiddle.net/pvvFR/14/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM