css - SVG 作为超大网站背景

标签 css html scroll background svg

我想建立一个固定宽度的网站,宽度为 960 像素并向左对齐。但是,我想使用宽度大于 960 像素的背景,如果用户的屏幕宽度大于 960 像素,它会填充右侧的空间。

使用背景图片很容易:

body {background:url(myreallywidebgimage.png) 0 0 no-repeat}
#wrapper {width:960px;}

但是我可以在背景为 SVG 且不出现水平滚动条的情况下执行此操作吗?

最佳答案

我唯一能想到的关闭水平滚动条的方法是执行如下操作:

#wrapper {width:960px; overflow-x:hidden}

编辑:经过进一步思考,我决定最好看看 Google 是否提供了其他可能的建议,我遇到了这个:http://helephant.com/2009/08/svg-images-as-css-backgrounds/ .上述解决方案仅在您将背景分配给该 div 元素时才有效。但是,您可以尝试将 overflow-x:hidden 分配给 body 本身,看看是否也能解决问题。希望这些建议对您有所帮助。

关于css - SVG 作为超大网站背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2281361/

相关文章:

Python 和 Selenium - 从多个 sibling 中抓取数据

java - 仅在必要时显示滚动条

python - PyGTK 2 : TreeView is extending out of my window even with scroll bar enabled

html - 下拉菜单中的文字应该是绿色而不是红色

image - CSS3 英雄图像 : Whats the best pixel dimension and Image Size for a full screen responsive background?

html - 清除 :right; in internet explorer 的问题

html - 如何在图像中间插入按钮?

javascript - 如何在 <button> 中将 <div> 居中?

html - 居中位置 : fixed div When Viewport Reaches a Designated Width

javascript - 无法让 Jquery 平滑滚动工作