Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS-位置绝对值&;文件流_Css_Position_Positioning_Absolute - Fatal编程技术网

CSS-位置绝对值&;文件流

CSS-位置绝对值&;文件流,css,position,positioning,absolute,Css,Position,Positioning,Absolute,是的,我知道position absolute不起作用,但是有没有一种方法可以显示元素“在下面”(代码中的后面)而不是后面 例如: <img src="image.jpg" style="width: 500px; height: 400px; position: absolute; top: 0;" /> <h2 style="padding: 15px" >This text is behind not below the image</h2> 此文

是的,我知道position absolute不起作用,但是有没有一种方法可以显示元素“在下面”(代码中的后面)而不是后面

例如:

<img src="image.jpg" style="width: 500px; height: 400px; position: absolute; top: 0;" /> 
<h2 style="padding: 15px" >This text is behind not below the image</h2>

此文本位于图像的后面而不是下面
除了绝对定位外,是否有其他方法可以在图像下方显示h2

例如:

<img src="image.jpg" style="width: 500px; height: 400px; position: absolute; top: 0;" /> 
<h2 style="padding: 15px" >This text is behind not below the image</h2>


(是的,我必须在我的例子中使用绝对值和下面的动态边框内容,我迷路了:D)

我能够完成您要求的唯一方法是设置
h2
top
属性,即将文本定位在图像之后

PS:
位置:块
不存在。仅适用于h2的
绝对值
相对值
静态值
、和
固定值

指定与图像高度相等的上边距

例如


简单,只需删除绝对位置。(测试)
如果未定义对象,它将自动转到相邻对象的右侧或下方

将图像和标题包装在绝对块中如何?此解决方案将标题放在图像之后,因为h2在默认情况下是一个块,并且您的内容仍然处于绝对位置

<style type="text/css">
.wrapper{
    position: absolute;
    top: 0;
}
h2 {
    padding: 40px;
}
</style>

<div class="wrapper">
    <img src="image_url" alt="image!" />
    <h2>Am I invisible? (not!)</h2>
</div>

.包装纸{
位置:绝对位置;
排名:0;
}
氢{
填充:40px;
}
我是隐形的吗?(不是!)

h2{margin top:400px}有什么问题吗?我认为你的例子可能有点做作;你需要让我们更好地了解你在做什么。