简体   繁体   English

CSS相对背景未在插入html代码时扩展

[英]CSS Relative background not expanding on insertion of html code

Thanks for any help you can offer me/point me in the write direction. 感谢您的帮助,您可以为我提供/将我指向写信方向。

I am not sure how to explain what is happening. 我不确定如何解释发生了什么。

I current have a page with an image background (the image is 4044,2160 so it is larger than you would view on a single screen (normally)). 我当前有一个带有图像背景的页面(图像为4044,2160,因此它比您在单个屏幕上(通常)所看到的要大)。

Currently when the page loads, the image is top-centered and is not on repeat and thus fills the background completely. 当前,在页面加载时,图像居于顶部居中,不再重复,因此完全填充了背景。

However when inserting html code (CRUD) via javascript, etc. with the resulting page becoming larger than the original in the y direction, the background stops and does not fill the space below. 但是,当通过javascript等插入html代码(CRUD)时,结果页面在y方向上变得大于原始页面,背景会停止并且不会填充下面的空间。

http://postimg.org/image/jqzx0vuzr/ http://postimg.org/image/jqzx0vuzr/

I am not sure what to do to fix it and most likely think it is a css problem. 我不确定该怎么做才能修复它,并且很可能认为这是一个CSS问题。

Below is code: HTML 下面是代码:HTML

<section id="index" class="index clinic">
    <div id="x_container">
        Javascript insertion of code
    </div>
</section>

CSS 的CSS

.clinic{
    width:100%;
    position:relative;
    background: url(../img/clinic.jpg) no-repeat top center;
}
.index{
    height: 100%;
    padding: 0;
}

#index.index {
    padding:15% 0 0 0;
}
#xcrud_container{
    width: 90%;
    margin: 0 auto;
}

It seems that the javascript does not matter as to what is inserted, (have tried lorem ipsum, etc.) But just to expand on what is inserted, the size of the x_container changes based on a state and this is altered by javascript. 看来javascript对插入的内容无关紧要(尝试过lorem ipsum等),但是只是为了扩展所插入的内容,x_container的大小会根据状态而变化,而javascript会对此进行更改。 (Thus page is not reloaded and background size recalculated) (因此不会重新加载页面,并且不会重新计算背景尺寸)

I have currently tried a clearfix solution (but to no avail) as well as attempting repeat-y on the background image. 我目前已经尝试过clearfix解决方案(但无济于事),并且尝试在背景图片上重复-y。

Lastly I have attempted to manually create the page through directly saving the html code (ie it is not inserted by anything and is apart of the html code of the page) to the page and attempting to see if the background expands. 最后,我尝试通过直接将html代码(即没有插入任何内容,并且与页面的html代码分开)直接保存到页面中,并尝试查看背景是否扩展,来手动创建页面。 It does not. 它不是。 The background fills the initial view area, however as soon as you scroll down the page, the white area reappears. 背景填充了初始视图区域,但是,当您向下滚动页面时,白色区域会再次出现。

Just to make sure this is known the background image is larger than area viewed, thus the white area should not be present. 只是要确保知道背景图像大于查看的区域,因此不应出现白色区域。

Any help would be greatly appreciated, as I have been at this for a few days... 任何帮助将不胜感激,因为我已经在此工作了几天。

Thanks 谢谢

Change % to Pixels as for example. 例如,将%更改为Pixels。

.index{
    height:1000px;
    padding: 0;
}

Thanks for you help guys, 谢谢你们的帮助

Through the comments and answer I have been able to figure out my own stupidity in trying to force a tag to define the background of the page rather than using body. 通过评论和答案,我能够弄清自己的愚蠢之处,试图强迫标签定义页面背景而不是使用正文。 ie . 即。

The reason for my defining it as a section tag is due to its use on previous pages where the was followed by another section and thus the white space area would not be a problem. 之所以将其定义为section标签,是因为它在以前的页面上使用,在上接有另一个section,因此空白区域不会成为问题。 (Also is the reasoning for the height:100%;, as I had to define the height of the section as being 100% in order to fully create the image within the section. (也是对height:100%的原因;因为我必须将段的高度定义为100%才能在段内完全创建图像。

Thanks again. 再次感谢。

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

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