如何有一个非固定的全屏背景图片?

编程入门 行业动态 更新时间:2024-10-25 08:26:51
本文介绍了如何有一个非固定的全屏背景图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

据我所知,几种技术存在有全屏背景图像,无论是与CSS3或绝对定位和100%的高度/宽度。

I am aware that several techniques exist to have a fullscreen background image, either with CSS3 or with absolute positioning and 100% height/width.

然而,所有这些技术导致固定的背景图像,也就是说,如果你有一些内容比需要滚动屏幕越大,背景图片将保持滚动时固定的。

However, all these techniques result in fixed background images, meaning that if you have some content bigger than the screen that needs a scrollbar, the background image will stay fixed when scrolling.

时有可能有背景图像stetch的页的宽度/高度,而不是在屏幕

Is it possible to have the background image stetch to the width/height of the page, instead of the screen?

推荐答案

我不得不为我建立一个fullsceen幻灯片同样的问题:固定位置使画面留在地方,而滑动包含的元素,而不是让他们与此元素滑动...

I had the same problem as I'm building a fullsceen slideshow: fixed position makes images stay in place while sliding containing element instead of letting them sliding with this element...

我尝试了很多解决方法的使用这些技术

I tried a lot of workaround using those techniques:

  • 的CSS仅技术#1:正常工作与设置为相对位置,但不verticaly居中图像
  • 真棒,很简单,进CSS3道:我妄图所有的可能性之前认识到,不充盈位置值工作(真正真棒)

  • CSS-Only Technique #1: works fine with position set to relative, but doesn't center the image verticaly.
  • Awesome, Easy, Progressive CSS3 Way : I tried all possibilities in vain before to realise that not filling the position value worked (really awesome)!

html { background: url(images/bg.jpg) no-repeat center center; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; }

更多推荐

如何有一个非固定的全屏背景图片?

本文发布于:2023-07-11 12:25:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094055.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:全屏   有一个   背景图片

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!