Do you know color shades coding ??

Discussion in 'CSS' started by tptnyc, Aug 4, 2008.

  1. #1
    Many websites have background color showing on menu side going from dark to light in color shades, how do you do that combo shades # #?

    .navi {
    background: #FEFEFC;
    float: left;
    width: 26%;
    text-align:center;
    font: normal 0.8em Verdana;
     
    tptnyc, Aug 4, 2008 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    It's done with an image of the gradient.

    cheers,

    gary
     
    kk5st, Aug 4, 2008 IP
  3. tptnyc

    tptnyc Peon

    Messages:
    764
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That's not right. Look at Yahoo HomePage, for example, in menu side, this is not done thru image gradients. LOL
    http://www.yahoo.com/
     
    tptnyc, Aug 4, 2008 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    Maybe you should look a little closer.
    
    div.minimantle, #minimantle, #sizetoggle, #trough ul, #pa {    
      background-image:url(http://l.yimg.com/a/i/ww/thm/1/grd-4px_1.1.gif);
      background-repeat:repeat-x;
    }
    Code (markup):
    gary
     
    kk5st, Aug 4, 2008 IP
  5. tptnyc

    tptnyc Peon

    Messages:
    764
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    tptnyc, Aug 8, 2008 IP
  6. ing

    ing Well-Known Member

    Messages:
    500
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    195
    #6
    That's using an image too...

    
    background: #ebf5fc url('../img/body_bg.jpg') repeat-x 0 0;
    
    
    Code (markup):
     
    ing, Aug 8, 2008 IP
  7. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #7
    Look, to get a gradient background, you use an image of the gradient. No matter how much you'd like it to be otherwise, it just ain't happenin' under today's available specifications.

    Why is that so hard to believe or accept?

    This time, instead of throwing another example of the same thing for somebody else to find the image, look for it yourself.

    In the meantime, offer thanks to ing, myself and anyone else who jumps in and does the work for you for showing you the pathway to righteous gradients.

    gary
     
    kk5st, Aug 8, 2008 IP
  8. mshore

    mshore Peon

    Messages:
    416
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    As Gary has said it is easiest to use a gradient image (1 pixel wide and as tall as you need it) and repeat it across the area you choose to display it in. That being said an image isn't the ONLY way to get what you want, but it is by far the easiest.

    If you are developing for IE only you can use the proprietary gradient property, but again, that will ony work in IE.

    See http://slayeroffice.com/code/gradient/ for more details on how to do this withou using an image.
     
    mshore, Aug 8, 2008 IP
  9. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #9
    As a proof of concept, it's quite ingenious.

    From a realistic usage standpoint, it uses javascript to create badly structured, non-semantic and invalid markup. One look at the generated source, and I want to barf.

    Were I silly enough to actually use the script, I'd want to be sure that it was the last function to be called, as it could surely wreak havoc on other DOM scripting that depended on structure.

    By the way, it breaks with font resizing.

    cheers,

    gary
     
    kk5st, Aug 8, 2008 IP
  10. tptnyc

    tptnyc Peon

    Messages:
    764
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks to all of you. Info given by everyone is really helpful.
     
    tptnyc, Aug 9, 2008 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #11
    ... and it's broken in both IE and Opera on large font/120dpi machines (so likely also broken if you set X to 100dpi or manually change the default font size in FF).

    Gary is correct that it's an interesting concept - but DAMN the implementation could use a little help. Putting DIV between UL and it's LI? /FAIL/. DIV inside a SPAN? /FAIL/ - 99.99% more inlined presentation than should be neccessary? /FAIL/.

    For improvements, I'd suggest NOT declaring all those widths manually - wrap a div AROUND the element you are applying the styling to, then set all your nested DIV's to pad themselves in 1px on one side. Note I said nested - right now they are all siblings when it would be easier to nest them inside each-other. Only the outermost one would need position absolute and a width on it, the rest could be allowed to use their normal behavior to make them expand to available width - just use padding on one side to make them narrower and/or shorter.

    You could even do 3 'stripes' from one element instead of three - border is available after all. Border-left would be one 'stripe', border-right could be another, and the background color would be a third. Less elements to calculate the size of, less elements for the browser to render.

    Another 'objection' I have to it is that it puts presentation back into the markup via the color settings. I'd consider parsing border-left and border-right (and/or border-top/border-bottom) to extract the color from there so you could place color in the CSS where it belongs instead of the markup.... because THIS:

    class="gradient B8DEFD 4086BD vertical foo"

    Kind of defeats the point of separation of presentation from content and most of what modern markup is supposed to be about.

    ... Though at that point it might be simpler to just use an image.
     
    deathshadow, Aug 9, 2008 IP
  12. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #12
    Gee, ya think? :)

    Especially when at the command line, all you have to do is type:
    
    gt@koko:~$ [b]convert -size 10x400  gradient:skyblue-white gradient_range1.jpg[/b]
    Code (markup):
    If you have Imagemagick installed, and why wouldn't you, you get the attached image. Seems a lot easier to me. ;)

    cheers,

    gary
     

    Attached Files:

    kk5st, Aug 9, 2008 IP