中心小猫?在 jsFiddle 中!强制背景下降
http://jsfiddle.net/TurtleWolf/P7xKm/
所以我只想背景图像不要低于 html 的其余部分。这是埃文在第二个链接中已经帮助我做的事情的后续...因此图像将调整到任何窗口的大小,但现在它不充当背景图像...html5 中的最佳实践是什么对于这种情况?
http://jsfiddle.net/TurtleWolf/P7xKm/
So I just want the background image to not be below the rest of the html. This is a follow up to what Evan has already helped me with in the second link... So the image will re-size to any window, but now it's not acting as a background image... What's the best practices in html5 in for this situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此处更新了方法: http://jsfiddle.net/irama/P7xKm/24/
打破它向下...
您想要添加一个内容层:
然后您想要从文档流中取出“容器”元素,以便您可以将内容分层在顶部:
然后您可以根据需要选择或保留 JavaScript图像垂直是否居中。
Updated approach here: http://jsfiddle.net/irama/P7xKm/24/
Breaking it down...
You want to add a content layer:
Then you want to take the 'container' element out of the document flow, so you can layer content on top:
You can then either take or leave the JavaScript depending on whether you want the image vertically centred or not.
鉴于图像的高度可能会发生变化,因此当窗口大小发生变化时,您需要 JavaScript 来重新计算位置。
将其扔到 jsfiddle 中的 JavaScript 区域并设置“nowrap (body)”:
请参阅:http://jsfiddle .net/irama/P7xKm/22/
或者,对于 jsfiddle 之外的情况,请在结束 之前添加此内容标签:
Given that the height of the image can change, you'll need JavaScript to recalculate the position when the window size changes.
Throw this in the JavaScript area in jsfiddle and set 'nowrap (body)':
See: http://jsfiddle.net/irama/P7xKm/22/
Or, for outside of jsfiddle, add this before your closing <body> tag: