Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 将背景扩展到div元素之外_Html_Css_Background_Image - Fatal编程技术网

Html 将背景扩展到div元素之外

Html 将背景扩展到div元素之外,html,css,background,image,Html,Css,Background,Image,是否可以将div中的背景元素扩展到div框架之外 还有一个关于我发现的解决方法的后续问题: 我在HTML代码中放置了一个,放在我的主要内容后面。正确显示整个背景图像,但有滚动条延伸图像的整个长度,当然图像是可选的。是否有办法删除滚动条并使该图像不可选择 我之所以不将背景图像放在CSS的正文样式中,是因为我想在调整浏览器窗口大小时将背景附加到我的内容。也许你应该尝试使用CSS中的图像背景,然后其他元素将不会自动调整大小?也许你应该尝试使用该图像CSS中的背景和其他元素将不会自动调整大小?我可能在脑

是否可以将div中的
背景
元素扩展到div框架之外

还有一个关于我发现的解决方法的后续问题:

我在HTML代码中放置了一个
,放在我的主要内容后面。正确显示整个背景图像,但有滚动条延伸图像的整个长度,当然图像是可选的。是否有办法删除滚动条并使该图像不可选择


我之所以不将背景图像放在CSS的
正文
样式中,是因为我想在调整浏览器窗口大小时将背景附加到我的内容。

也许你应该尝试使用CSS中的图像背景,然后其他元素将不会自动调整大小?

也许你应该尝试使用该图像CSS中的背景和其他元素将不会自动调整大小?

我可能在脑海中看不到您想要的东西。。。但是有CSS属性可以从项目中删除滚动条,只需使用overflow属性并将其设置为hidden

如果您只是想阻止DIV上的滚动条,那就是。如果您知道图像的大小,或者它总是相同的,只需将DIV宽度和高度设置为与图像相同,它就会显示所有内容


据我所知,没有办法使背景内容大于显示它的项目

我的脑子里可能没有看到你想要的东西。。。但是有CSS属性可以从项目中删除滚动条,只需使用overflow属性并将其设置为hidden

如果您只是想阻止DIV上的滚动条,那就是。如果您知道图像的大小,或者它总是相同的,只需将DIV宽度和高度设置为与图像相同,它就会显示所有内容


据我所知,没有办法使背景内容大于显示它的项目

尝试使用附加包装,并在其上设置背景图像。

尝试使用附加包装,并在其上设置背景图像。

问题1:否

问题2:使用
背景图像
属性而不是
。您可以将其放在内容后面的包含
的容器中,或与内容放在同一个框中。使用
背景图像
不会显示任何滚动条。

问题1:否


问题2:使用
背景图像
属性而不是
。您可以将其放在内容后面的包含
的容器中,或与内容放在同一个框中。使用
背景图像
不会提供任何滚动条。

您可以将背景图像放在分区之外,但在调整浏览器大小时使用CSS定位将其保持在正确的位置。一种常见的解决方案是将背景位置设置为中心,分区也设置为中心,这样可以使它们保持在同一位置。

您可以将背景图像放置在分区之外,但在调整浏览器大小时,可以使用CSS定位将其保持在正确的位置。一种常见的解决方案是,背景位置设置为中心,分割也设置为中心,使它们保持在同一位置。

是否可以将div中的背景元素扩展到div帧之外

您可以通过调整2 div的边距和填充值来产生错觉。它是纯CSS,顶部的div也可以根据您的需要任意增长。底部div必须是一个设定的高度。我已经在多个浏览器上测试过了,还没有发现任何问题

<div id="top" style="padding:0 0 300px 0; margin:0 auto -700px; background:red;" >
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
</div>

<div id="bottom" style="margin:400px 0 0; padding:0; height:300px;">
my bottom content at a set height - required!<br /><br />
</div>

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的底部内容在设定的高度-必需

希望这有帮助!下面是一个示例,您可以立即看到它的外观

“是否可以将div中的背景元素扩展到div帧之外?”

您可以通过调整2 div的边距和填充值来产生错觉。它是纯CSS,顶部的div也可以根据您的需要任意增长。底部div必须是一个设定的高度。我已经在多个浏览器上测试过了,还没有发现任何问题

<div id="top" style="padding:0 0 300px 0; margin:0 auto -700px; background:red;" >
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
my top content which can grow in height as much as possible.<br /><br />
</div>

<div id="bottom" style="margin:400px 0 0; padding:0; height:300px;">
my bottom content at a set height - required!<br /><br />
</div>

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的顶级内容,可以尽可能地增加高度。

我的底部内容在设定的高度-必需


希望这有帮助!下面是一个示例,您可以立即看到它的外观

如果我在CSS中使用
背景
功能,则在调整窗口大小时,图像不会“跟随”内容。我的内容通过自动边距居中。即使您设置背景:居中不重复url(您的图像所在的位置),如果我使用CSS中的
background
功能,则在调整窗口大小时,图像不会“跟随”内容。我的内容通过自动页边距居中。即使设置背景:居中否