html - 在页面上所有 DIV 部分的顶部显示图像

标签 html css joomla z-index

基于 Joomla 的网站,DIV 部分在模板中划分页面。

我需要在页面上的所有内容之上显示一个图形。使用 position: relative 或 position: absolute,它只调整当前 DIV 部分内的位置。

使用 position: fixed,我可以设置它的实际位置,这很棒。但是,无论我的 z-index 是什么,一些 DIV 都出现在上方,而另一些则出现在后面。

不知道如何在屏幕上的所有内容之上显示此图像,而不管它的 DIV、z-index 等。

最佳答案

使用绝对位置,但调整由于在该流中不显示 img 而引起的变化,例如边距、填充、高度等。如果您正在 float img,您也需要固定位置。

<div>  
    <div>before img</div>
    <img class="img--absolute" src="http://placekitten.com/50/60"/>
    <div  class="absolute-fix">after img</div>
</div>

.img--absolute{
    position: absolute;
}

.absolute-fix{
    margin-top: 70px;
}

<div class="img-container--float-fix">beffor img</div>
    <div>before img</div>
    <img class="img--float img--absolute" src="http://placekitten.com/50/60"/>
    <div class="absolute--float-fix">after img</div>
</div>


.img-container--float-fix{
    position: relative;
}

.absolute--float-fix{
    padding-right: 60px;
}

.img--float.img--absolute{
    right: 0;
}

http://jsfiddle.net/o5sboe1s/

关于html - 在页面上所有 DIV 部分的顶部显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28882449/

相关文章:

javascript - 如何存储将请求 POST 到远程 URL 的表单中的数据

php - Shopify Dev - 按行显示博客文章

html - css:如何在不增加整个文本行高的情况下增加一个字符的字体大小?

php - 博客文章 WordPress 定制

javascript - 如何在 sveltekit 应用程序中将菜单项设置为事件状态

html - 多个带有边距以填充父级宽度的 div

css - 正确的 CSS 语法

php - 将 Joomla 1.5 网站移动到新的(现代)托管... MySQL DB 不向后兼容吗?

joomla - 如何在 Joomla Controller 中显示 View ?

php - PHP中如何绕过函数参数?