css - CSS 中缩放渐变背景

标签 css background gradient

第一次提问,请多多包涵

我正在尝试为使用 JQuery Mobile 的 Web 应用程序制作背景渐变。一般来说,我对 CSS 和 UI 设计一无所知。

我希望渐变填充整个页面的空间。现在,它填充到原始窗口的大小,但向下滚动时会“切断”。

大多数建议都指向这一点:

html 
{
  height: 100%;
} 

...这对我不起作用。这是我所拥有的:

content: " ";
width: 100%;
height: 100%;
float: left;
position: relative;
z-index: -1;
top: 0;
left: 0;
background-repeat: no-repeat;
background-attachment: fixed;
background: -moz-linear-gradient(-45deg, rgba(0,0,0,1) 40%, rgba(0,0,0,0.5) 100%) fixed;
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,rgba(0,0,0,1)), color-stop(100%,rgba(0,0,0,0.5))) fixed;
background: -webkit-linear-gradient(-45deg, rgba(0,0,0,1) 40%,rgba(0,0,0,0.5) 100%)fixed;
 background: -o-linear-gradient(-45deg, rgba(0,0,0,1) 40%,rgba(0,0,0,0.5) 100%) fixed;     background: -ms-linear-gradient(-45deg, rgba(0,0,0,1) 40%,rgba(0,0,0,0.5) 100%) fixed;
 background: linear-gradient(135deg, rgba(0,0,0,1) 40%,rgba(0,0,0,0.5) 100%) fixed;
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#00000000',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */

最佳答案

当您使用height:100%;时,有时会出现此问题。由于它意味着填充 100% 的浏览器窗口,因此它不会填充其余部分,因为那将超过 100%。

尝试稍微调整一下并像这样写:

html 
{
  min-height: 100%;
} 

现在它可以填充超过 100%,因此它应该填充背景的其余部分。

关于css - CSS 中缩放渐变背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14330909/

相关文章:

android - 选择时更改操作背景颜色(ActionBarSherlock)

ios - `BGAppRefreshTask` 与 `BGProcessingTask` 理解时序

python - 如何在 Folium Heat Map 中添加图例/渐变?

css - 更改按钮的颜色并在悬停时上课

html - :hover won't trigger because bounding box is in the way

jquery - 模糊 div 的背景

html - CSS 背景渐变,图像

html - 用户名密码按钮

php - ffmpeg后台进程完成后如何管道新命令?

android - 渐变显示红色