Double border in CSS

Discussion in 'CSS' started by Koos, Jul 7, 2008.

  1. #1
    I wonder if someone can help. I want to create a table with a double border in css. I know it can be done like this:

    <style>
    DIV.outer {BORDER: 5px solid;BORDER-COLOR:#000000}
    DIV.inner {BORDER: 5px solid;BORDER-COLOR:#D1D1E1}
    </style>

    <div class="outer">
    <div class="inner">
    Koos
    </div>
    </div>

    Which will result in a table as shown in this screenshot:
    http://koos.50webs.com/images/koos_border.html

    But the problem is, I need to create this double css border in a single DIV, ie:

    <div class="new">
    Koos
    </div>

    Is this possible?
     
    Koos, Jul 7, 2008 IP
  2. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Dunno why you're making a table out of divs? If it's a table, make it a table.

    No, I don't know of any way to do what you want... if they were the same colour, you could set them as double lines... but two different colours, unless they change something for CSS3, I'm pretty sure can't be done yet.

    Usually there are other elements in the div though, and often you can get them to make your borders for you. Like:

    <div class="koos">
    <h3>Foo</h3>
    <p>textitty text text text...</p>
    </div>

    There is a possibility that p has side and bottom borders to do the grey, while the h3 can have side and top borders... assuming the div called "koos" has no padding and the h3 and p have no margins.
     
    Stomme poes, Jul 7, 2008 IP
  3. Koos

    Koos Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the advice. That is probably the best I can do: making use of the existing elements in the div.
     
    Koos, Jul 7, 2008 IP
  4. faithnomoread

    faithnomoread Peon

    Messages:
    174
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It can be done with the 'double'
    I would do it like this:
    .doubleborder {border:10px double;}
    as for the color thing with this attribute u can only choose 1 color. ur original way is the only other way. U can change the colors of the 4 side though:
    border-top or border-color-top
    border-bottom or border-color-bottom etc.....
     
    faithnomoread, Jul 7, 2008 IP
  5. yankzilla

    yankzilla Peon

    Messages:
    159
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would go with what Stomme poes said, and try to use a P element and add a border to that was well. You might want to add padding to the div and P such as this:

    <style>
    * {padding: 2px; }
    div { border: 1px #000 solid }
    p { border: 1px red solid; margin: 0px }
    </style>
    Code (markup):
    That way this:
    <div> 
    <p>test</p> 
    </div>
    Code (markup):
    Formats correctly, and everything works out good and dandy. Just wrap the P tags around everything in the div.

    You can see an example here: http://csscharm.com/test
     
    yankzilla, Jul 7, 2008 IP
  6. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Have you tried using a background on the one element, and setting a padding? I've used this with mixed successes with white backgrounds. As long as not too much is going on with the interior padding, it seems to work [most of the time].

    <div style='background-color:#D1D1E1; padding:5px; margin:0px; border:5px solid #000;'>
    <p style='width:100%; background-color:white; margin:0px; padding:0px;'>Koos</p>
    </div>
    Code (markup):
     
    Altari, Jul 7, 2008 IP
  7. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Oh yeah, the padding thing (or margins on the children) would work nicely too-- here, the parent div could even have a background image with, I dunno, a texture or something, so you're no longer limited to flat colours-- you could have gradient borders and the like, and the thickness set by the padding width : )
     
    Stomme poes, Jul 8, 2008 IP