我有一个背景渐变,它看起来不错,但我有一个问题,在短页面背景太长,导致不必要的滚动条和长页面背景将开始重复而不是延伸来填充整个页面。背景渐变 - 填充页面没有滚动条或重复
这里是我使用的CSS:
html, body{
font-size:1em;
font-family: "ff-dagny-web-pro", Helvetica, Arial, sans-serif;
line-height:1.438em;
color:#222;
margin: 0;
padding: 0;
text-align: justify;
background: rgb(0,0,0); /* Old browsers */
background: -moz-linear-gradient(top, rgba(0,0,0,1) 25%, rgba(209,209,209,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(25%,rgba(0,0,0,1)), color-stop(100%,rgba(209,209,209,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,0,0,1) 25%,rgba(209,209,209,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,0,0,1) 25%,rgba(209,209,209,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,0,0,1) 25%,rgba(209,209,209,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0,0,0,1) 25%,rgba(209,209,209,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#d1d1d1',GradientType=0); /* IE6-9 */
}
当我添加height: 100%;
它会导致短期的网页滚动条。我试图通过使用overflow: hidden;
删除它们,但导致长页面上的任何内容不显示!另外,如果我不使用height: 100%;
,那么渐变只填充大约一半的页面并重复。
我有点困惑,该怎么做或尝试解决这个问题。
注意:虽然我更喜欢CSS解决方案,但如果有解决方案(使用jQuery)的JavaScript解决方案,我会愿意尝试这个工作。
但高度使上,我宁愿避短页面滚动条。 – L84
@Lynda比你可以习惯于像这样的特定div http://tinkerbin.com/u8Z8QOH0 –
@Lynda我认为你看起来像这样: - http://tinkerbin.com/HexPYkx7 –