3

I have this:

<style type="text/css">
  .TopBorderPanel {
     position: relative;
     overflow: hidden; 
     border-top: 2px solid #bbbb9f;
     margin: 1px;
     width: 500px; 
    }
</style>

The top border has one color , #bbbb9f,
what i want to do is make it 2 colors
50% #bbbb9f and 50% #cccccc
Is it possible ?

Roland
  • 181
  • 1
  • 5
  • 11

3 Answers3

8

http://jsfiddle.net/CdWCA/

.TopBorderPanel {
    border-top: 2px solid #bbbb9f;
    position: relative;
}    

.TopBorderPanel:after {
    position: absolute;
    left: 50%;
    right: 0;
    top: -2px;
    border-top: 2px solid #cccccc;
    content: '';
}
​
RoToRa
  • 37,635
  • 12
  • 69
  • 105
2

Better use a background *.gif split equally into two colours, and use a single pixel of padding on the top:

.TopBorderPanel {
    border: 0;
    background-image: url(...);
    padding-top: 1px;
}
Bakabaka
  • 1,505
  • 1
  • 13
  • 21
0

I can think of 2 ways of doing this.

My first method would be to use a pseudo selector, what this does is add content, or styles :before or :after an element. So in effect you can have 2 styles for one element, just one as normal, and then some extras added either before or after this element.

I have added a border-top, as normal, and then added another border-top with the pseudo selector.

My second solution is to add a box-shadow, that instead of normally looking like a diffused shadow, it styled to look like a solid shadow above the element.

I've created a jsFiddle which will hopefully give you an idea, but if you don't understand just say.

jsFiddle

Alexander Wigmore
  • 3,157
  • 4
  • 38
  • 60
  • 1
    u have cut it horizontaly , what i want is to cut it vertically , like if it was 2 cells – Roland Aug 10 '12 at 11:33
  • Then instead of border-top, you could use `border-left` or `border-right`? – Alexander Wigmore Aug 10 '12 at 11:43
  • Just re-read your comment, and think I mis-understood, created another way of doing it, so the split is down y-axis. [jsFiddle](http://jsfiddle.net/wigster/SuFgj/) - May Look confusing in the CSS, but that's just all vendor prefix's so that it'll look the same in most browsers. – Alexander Wigmore Aug 10 '12 at 11:59