CSS different border widths overlapping themselves -


i'm having trouble borders overlapping because of different width border-top has.

here example code of problem: http://jsfiddle.net/u7khx/

.border{ width: 200px; height: 200px; border-top:5px solid #894b9d; border-right: 1px solid #dad9d9; border-bottom: 1px solid #dad9d9; border-left: 1px solid #dad9d9; 

as can see purple part not complete.

any ideas?

you can make top border perfect rectangle , still have other borders way want them using div's ::after pseudo element.

put top border on div , other 3 borders on pseudo-element.

for example:

.border {     width: 200px; height: 200px; border-top:5px solid #894b9d;     padding: 0 1px 1px 1px;     position:relative; } .border::after {     display:block; content:'';     position:absolute; top:0; left:0;     width:200px; height:200px;     border-color:#dad9d9; border-style:solid; border-width:0 1px 1px 1px; } 

see updated fiddle.

edit:
or if don't want rely on given width , height, this:

.border {     display:inline-block;     position:relative;     padding:.5em;     border-top:5px solid #894b9d; } .border::after {     display:block; content:'';     position:absolute; top:0; left:0;     width:100%; height:100%;     -webkit-box-sizing:border-box;     -moz-box-sizing:border-box;     box-sizing:border-box;     border-color:#dad9d9; border-style:solid; border-width:0 1px 1px 1px; } 

i've made inline-block, show works fine dynamic content sizes, can work kinds of widths.

more updated fiddle.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -