简体   繁体   English

添加JavaScript代码后,容器之间的空白

[英]white space between container after I add javascript code

So i find this piece of javascript code online to solve text scalable problem. 因此,我在网上找到了这段JavaScript代码来解决文本可扩展性问题。 view-source: http://www.spookandpuff.com/examples/dynamicTextSize.html 查看源代码: http : //www.spookandpuff.com/examples/dynamicTextSize.html
After I add this on my code. 在我的代码上添加之后。 there are some white space between my containers which are all images. 我的容器之间有一些空白,都是空白。 The white space only come out after i add script, it will disappear if i delete it. 只有在添加脚本后才会出现空白,如果删除它,它将消失。 Anyone knows how to remove this white space? 有人知道如何删除此空白吗?

Note: there are no space between my div tag. 注意:我的div标签之间没有空格。

.page1{
position:relative;
width:100%;
}

first_page_image{
width:100%;
}

.page1_text{
 position:absolute;
 bottom: 4%;
    margin-left:14%;
}
}
page2{
position:relative;
width:100%;
}

.second_page_image{
width:100%;
}

page2_text{
position:absolute;
margin-left:14%;
}

page1 and page2 are containers. page1和page2是容器。 image and text are all in the container 图片和文字都在容器中

If I understand you correctly, then try to add a css property: 如果我对您的理解正确,请尝试添加CSS属性:

img {
    display: block;
}

Image by default is inline element so this style will help to remove whitespace below image. 图像默认为内联元素,因此此样式将有助于移除图像下方的空白。

That's because images by default are displayed inline, vertically aligned with text. 这是因为默认情况下,图像以内联方式显示,并与文本垂直对齐。 You can solved this in two ways: 您可以通过两种方式解决此问题:

Either set display:block on your images, or set vertical-align:top, if you wish to keep images displayed inline. 如果您希望使图像保持内嵌显示,请在图像上设置display:block,或者设置vertical-align:top。

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

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