Solved

Gradient background scrolling in Firefox

Posted on 2013-01-10
3
561 Views
Last Modified: 2013-01-11
I'm having an issue with trying to get a CSS gradient background not to scroll in Firefox. It stays static in IE, but not in Firefox. Can someone please help?

Here's the example code:

<HTML>
      <HEAD>
            <style>
                  body
                  {
                        /*  establish the gradient for all pages  */
                         width: 100%;
                      height:100%;
                      margin: "0";
                        padding: "0";
                             
                        /* default background colour, for all layout engines that don't implement gradients */
                        background: #ffffff;
                      background-repeat: no-repeat;
                        color: #000000; /* text colour (black) */
                       
                        filter: progid:DXImageTransform.Microsoft.Gradient (startColorstr='#005595', endColorstr='#dddedf', gradientType='0'); /* IE based browsers */
                        background: -moz-linear-gradient(top, #006595 0%, #dddedf 100%); /* Mozilla (Firefox) based browsers */
                        background: -webkit-gradient(linear, left top, left bottom, from(#006595), to(#dddedf)); /* webkit based browsers */
                       
                        FONT-WEIGHT: normal;
                      FONT-SIZE: 9pt;
                      FONT-STYLE: normal;
                      FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
                  }

            </style>
      </HEAD>
      <BODY>
            <P>&nbsp;</P>
            <center>
                  <table width=50% height=2000 bgcolor=white>
                        <tr>
                              <td>&nbsp;</td>
                        </tr>
                  </table>
            </center>
            <P>&nbsp;</P>
      </BODY>
</HTML>

Cut that into a .htm file or open the attached file in both IE and Firefox and scroll to see what my issue is.

Thanks for your assistance.
gradient-test.html
0
Comment
Question by:LandyJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 22

Accepted Solution

by:
Kim Walker earned 250 total points
ID: 38766848
To prevent the background from scrolling, use the background-attachment property
background-attachment: fixed;

Open in new window

0
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 250 total points
ID: 38766974
Yeah, what @xmediaman said.

Interesting though that when you add a doctype and correct some of the other markup validation errors, the inconsistency between IE and FF disappears. In fact, the results become consistant across all browsers. Having a doctype and valid markup should be your starting point BEFORE implementing @xmediaman's suggestion. Here's your markup with corrections:
<!DOCTYPE html>
<html>

	<head>

		<style type="text/css">

			body

			{

				/*  establish the gradient for all pages  */

			 	width: 100%;

			    height:100%;

			    margin: "0"; 

				padding: "0";

					

				/* default background colour, for all layout engines that don't implement gradients */

				background: #ffffff;

			    background-repeat: no-repeat;

				color: #000000; /* text colour (black) */

				

				filter: progid:DXImageTransform.Microsoft.Gradient (startColorstr='#005595', endColorstr='#dddedf', gradientType='0'); /* IE based browsers */

				background: -moz-linear-gradient(top, #006595 0%, #dddedf 100%); /* Mozilla (Firefox) based browsers */

				background: -webkit-gradient(linear, left top, left bottom, from(#006595), to(#dddedf)); /* webkit based browsers */

				

				font-weight: normal;

			    font-size: 9pt;

			    font-style: normal;

			    font-family: Verdana, Arial, Helvetica, sans-serif

			}



		</style>

	</head>

	<body>

		<p>&nbsp;</p>

		<center>

			<table style="width:50%;height:2000px;background-color:#fff">

				<tr>

					<td>&nbsp;</td>

				</tr>

			</table>

		</center>

		<p>&nbsp;</p>

	</body>

</html>

Open in new window

0
 
LVL 7

Author Closing Comment

by:LandyJ
ID: 38767801
Thank you both. Both parts were missing from my code, so I will split the points.

Much appreciated.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question