Solved

how can i set gradient color at a html table

Posted on 2012-03-25
4
286 Views
Last Modified: 2012-03-28
hi

how can i set a color bakcground gradient to a table?...this is my code:

<table width="953" height="316" border="0" bgcolor="#CCCCCC" hspace="20" align="center" class="bordesred">
  <tr>
    <td width="42" >
    <p></td > 
    <td width="352"><p><span title="mouse over description here">normal text</p> </td><td width="42"></td>
    <td width="499" rowspan="4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
index.html
0
Comment
Question by:tenriquez199
4 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37765731
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 37765776
Something like this perhaps:

<table width="953" height="316" border="0" bgcolor="#CCCCCC" hspace="20" align="center" class="bordesred" style="filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');" >
  <tr>
    <td width="42" >
    <p></td >
    <td width="352"><p><span title="mouse over description here">normal text</p> </td><td width="42"></td>
    <td width="499" rowspan="4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  </table>

http://www.web-source.net/html_background_gradient.htm
0
 
LVL 30

Accepted Solution

by:
LZ1 earned 500 total points
ID: 37765785
Background gradients only work in CSS3 and modern browsers. If your users are going to be using IE, I would suggest using a background image.  

And to be completely honest, I'd probably use a background image anyways. You'll get a cleaner looking gradient and you don't have to worry about the browser trying to generate the CSS3 every time the user refreshes.
0
 
LVL 8

Expert Comment

by:Jen0910
ID: 37765833
you could apply it directly to the TABLE element, or wrap it in a div. Personally, I'd wrap it in a div tag, and style the div like so:

That way if you have multiple tables, you retain the ability to style them separately, which could be useful.

#div.table {
 /* fallback for very old browsers */
  background-color: #810303;
  
  /* Safari 4-5, Chrome 1-9 */
  background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#970101), to(#5f0202));
  
  /* Safari 5.1, Chrome 10+ */
  background: -webkit-linear-gradient(top, #970101, #5f0202);
  
  /* Firefox 3.6+ */
  background: -moz-linear-gradient(top, #970101, #5f0202);
  
  /* IE 10 */
  background: -ms-linear-gradient(top, #970101, #5f0202);
  
  /* Opera 11.10+ */
  background: -o-linear-gradient(top, #970101, #5f0202);

  /* basic fallback */
  linear-gradient(top, #970101, #5f0202);
}

Open in new window


CSS3 PIE is very useful for older IE browsers if you want to support them. Add the following to the above after downloading the package:

#div.table {behavior: url(path/to/PIE.htc);
 /* fallback for very old browsers */
  background-color: #810303;
 
  /* Safari 4-5, Chrome 1-9 */
  background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#970101), to(#5f0202));
 
  /* Safari 5.1, Chrome 10+ */
  background: -webkit-linear-gradient(top, #970101, #5f0202);
 
  /* Firefox 3.6+ */
  background: -moz-linear-gradient(top, #970101, #5f0202);
 
  /* IE 10 */
  background: -ms-linear-gradient(top, #970101, #5f0202);
 
  /* Opera 11.10+ */
  background: -o-linear-gradient(top, #970101, #5f0202);

  /* basic fallback */
  linear-gradient(top, #970101, #5f0202);

  /* PIE fallback */
  -pie-background:
}

Hope that helps!
http://css3pie.com/documentation/supported-css3-features/#pie-background

Open in new window

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

Suggested Solutions

Title # Comments Views Activity
Accessing specific element - DOM PHP HTML 8 46
REST endpoint query with a parameter 1 36
Navigation Menu Does Not Show on iPad 4 31
Use "if not" in a condition 2 19
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 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