简体   繁体   English

图像下方有很多空白

[英]A LOT of White Space Below Image

I am trying to use an image as a background (I did this before I knew there was a background attribute in HTML itself) and for some reason it has a LOT of whitespace below it. 我试图将图像用作背景(我在不知道HTML本身有background属性之前就做了此操作),由于某种原因,它下面有很多空白。

I tried removing the image completely so that I can use the "background" function in HTML, but as soon as I remove the image, all the information (except the image in the middle) disappears! 我尝试完全删除该图像,以便可以使用HTML中的“背景”功能,但是一旦删除该图像,所有信息(中间的图像除外)都将消失!

If I put the image in (in HTML) with no CSS, then it appears below all the text on the site, and it seems that the space it takes up (before I move it up) is the whitespace when it is moved. 如果我将图像放入不带CSS的HTML中,则该图像将显示在网站上所有文本的下方,并且看起来(在将其向上移动之前)占据的空间是移动时的空白。

I've been looking for a long time and can't find a solution. 我已经找了很长时间,找不到解决方案。

HTML HTML

 <div class="Images">

    <img id="MalcomPic" src="../Assets/Malcom.jpg" alt="Malcom X"/>

    <img id="MalcomBack" src="../Assets/MalcomBacks.jpg" alt="Malcom X"/>
    </div>

CSS CSS

   #MalcomBack {
   position: relative;
   bottom: 707px;
   z-index: -1;
    }

I tried adding display: block to the image, but it doesn't do anything. 我尝试将display: block添加到图像,但是它什么也没做。

Here is what it currently looks like: http://imgur.com/a/evyMl 这是当前的样子: http : //imgur.com/a/evyMl

I want it to end at the bottom of the picture. 我希望它在图片的底部结束。 Thanks for any help 谢谢你的帮助

I think the problem is that the outer div is not big enough. 我认为问题在于外部div不够大。 The image cuts right after the text because that's where the outer div ends. 图片在文字之后立即剪切,因为那是外部div的结束位置。 (A div with relative position doesn't affect the size of the parent) (具有相对位置的div不会影响父级的大小)

try adding the following to the outer div: 尝试将以下内容添加到外部 div中:

position: absolute;
height: 100%;
top: 0;

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

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