Imgs不会进入div(Imgs don't get inside div)

编程入门 行业动态 更新时间:2024-10-28 02:22:29
Imgs不会进入div(Imgs don't get inside div)

我有一个div容器,我想放置两个图像,一个在另一个上面,其中唯一可见的图像将是检查的图像。 我给我的容器position:relative和我的imgs position:absolute; ,因此它与容器有关。 但相反,数字标签的所有内容都远离容器,我不知道为什么。

这就是我所拥有的: https : //jsfiddle.net/rckecf2b/1/

I have a div container where i want to put two images, one above the other, where the only visible image will be the one checked. I give my container position:relative and my imgs position:absolute;, so it will be absolute in relation to the container. But instead, all the content of the figure tag are going away from the container, and i don't know why.

Here's what i have: https://jsfiddle.net/rckecf2b/1/

最满意答案

如果我理解正确,你需要让div具有绝对位置和相对于父亲的图像,就像这样

当某物具有绝对位置时,它会忽略其他设定位置。 如果你想让这些位置在div中看起来是绝对的,你需要它们是相对的

#container-fim-ap{ border:solid 5px #ABB7B7; width:50%; word-wrap:break-word; border-radius:2%; /*visibility: hidden;*/ position:absolute; height:auto; } #container-fim-ap figure{ position: relative; left:0; }

https://jsfiddle.net/rckecf2b/3/

玩一下吧

Well it turns out that givin' height:200px to #container-fim-ap solved the problem.

#container-fim-ap{ border:solid 5px #ABB7B7; width:80%; word-wrap:break-word; border-radius:2%; /*visibility: hidden;*/ position:relative; height: 200px;

http://jsfiddle.net/rckecf2b/2/ Thanks for the help everybody.

更多推荐

本文发布于:2023-08-07 16:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464753.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Imgs   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!