Jump to content


Stretching Content Box With Gradient


2 replies to this topic

#1 Mathijs1988

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 01 April 2009 - 05:52 AM

Does anyone know how to do it? I've searched google & browsed through many forums but I have yet to find an answer. I want to make a content box with a gradient in it and when I type something in there it should stretch (along with the gradient). Is this possible to achieve somehow in html/css/php or whatever? Please help me out :(

#2 lolzaka

    Young Padawan

  • Members
  • Pip
  • 21 posts

Posted 04 April 2009 - 05:40 PM

View PostMathijs1988, on Apr 1 2009, 05:52 AM, said:

Does anyone know how to do it? I've searched google & browsed through many forums but I have yet to find an answer. I want to make a content box with a gradient in it and when I type something in there it should stretch (along with the gradient). Is this possible to achieve somehow in html/css/php or whatever? Please help me out :(

You should save the gradient as an image, lets say its a gradient with the starting color of #ffffff (white) and an end color of #000000 (black). You shouls save the gradient as an image, lets say gradient.png

Now the css:

#menu {
background-image: url(gradient.png);
background-repeat: repeat-x;
background-color: #000000;
}

The repeat x stands for horizontal and the rest of the div will stretch with #000 because thats the end color of the gradient.

Good luck!

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 04 April 2009 - 07:35 PM

Note: That method would give the top of the box the gradient and the extended portion a solid color, which is about as good as it gets with HTML.

You can probably use JS to create a gradient that would stretch with the box rather than just fill in with solid color, but it would be extremely complex. I can't even imagine where i would want to start making something like that (and i've been at this for a while, so you should trust me when i say that you should stick to the above method).

As a side note though, i prefer short hand:
#menu { background: #000000 url(gradient.png) repeat-x left top; }






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users