JavaAndCSharp
JavaAndCSharp

Reputation: 1557

Why does my CSS3 gradient scroll, and how can I prevent it from doing so?

So I've finally made a website that looks great in every major modern browser. Even IE. Woohoo for me, you might say.

But I've got one final problem. My gradient scrolls.

Here's my gradient code:

padding:0;
margin:0;
font:normal 12px/16px Arial, Helvetica, sans-serif;
background: #4c4c4c; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPHJhZGlhbEdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iNzUlIj4KICAgIDxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiM0YzRjNGMiIHN0b3Atb3BhY2l0eT0iMSIvPgogICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjMmMyYzJjIiBzdG9wLW9wYWNpdHk9IjEiLz4KICA8L3JhZGlhbEdyYWRpZW50PgogIDxyZWN0IHg9Ii01MCIgeT0iLTUwIiB3aWR0aD0iMTAxIiBoZWlnaHQ9IjEwMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-radial-gradient(center, ellipse cover,  #4c4c4c 0%, #000000 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#4c4c4c), color-stop(100%,#000000)); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover,  #4c4c4c 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover,  #4c4c4c 0%,#000000 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover,  #4c4c4c 0%,#000000 100%); /* IE10+ */
background: radial-gradient(center, ellipse cover,  #4c4c4c 0%,#000000 100%); /* W3C */

Try it out yourself: It scrolls and fits itself to the page content. NO! I want it to fit itself to the browser size, not the total page size. That way, the content scrolls and not the background&the content.

How could I make the content scroll and not the background & the content?

Upvotes: 0

Views: 1605

Answers (1)

SpliFF
SpliFF

Reputation: 38976

Try setting background-attachment:fixed; under your background shortcuts. (You could also set it in the shortcuts by using complete declarations but the override would be less typing and more manageable).

Upvotes: 3

Related Questions