How to accomplish this div border using css:
I tried using dashed border but leads to this:
http://jsfiddle.net/23qGr/
div {width: 20px;
height: 20px; border: 6px #6a817d dashed;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
Answer: Use the CSS box-shadow property If you want to place or draw the borders inside of a rectangular box there is a very simple solution — just use the CSS outline property instead of border and move it inside of the element's box using the CSS3 outline-offset property with a negative value.
If there are contents within the div that has the curved corners, you have to set overflow: hidden because otherwise the child div's overflow can give the impression that the border-radius isn't working. This answer worked for me.
Width and height values apply to the element's content only. The padding and border are added to the outside of the box. padding-box : Width and height values apply to the element's content and its padding. The border is added to the outside of the box.
You could use pseudo element and transparent/black borders : DEMO
div {
width: 20px;
height: 20px;
padding:6px;
position:relative;
}
div:before , div:after {
content:'';
border:6px solid transparent;
position:absolute;
}
div:before {
left:2px;
right:2px;
top:0;
bottom:0;
border-top-color:black;
border-bottom-color:black;
}
div:after {
top:2px;
bottom:2px;
left:0;
right:0;
border-right-color:black;
border-left-color:black;
}
If you increse border-width, it looks better : demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With