我有一个应该位于屏幕底部附近的图像。我有一个主图像,它是背景图像,将根据浏览器大小调整大小。无论屏幕大小或调整屏幕大小,我都需要背景图像上方的图像距底部 20-30 像素。(图像也必须居中。)
我不知道该怎么做。做这个的最好方式是什么?
这是我尝试过的代码:
.bottom{
position:absolute;
margin-left: -355px; /* Image is 710 in width */
left:50%;
bottom:-20px;
}
该代码使图像正确居中在页面上,但距离底部没有 20px。此外,我在图像下方有内容,我希望内容保持在图像下方,但它目前出现在图像上方。
HTML:
<img class="bottom" src="src-path.png" alt="Text" />
<p style="clear:both;"> </p>
<!-- More Content here that consist of img and p tags. -->