css - circle with margin on border
I'd say to treat it like this:
Outer "border" - use a box shadow
Inner "margin" - use a white border
Inner area - use background color
All together you get:
.circle {
background-color: #F80;
border: 3px solid #FFF;
border-radius: 18px;
box-shadow: 0 0 2px #888;
height: 30px;
width: 30px;
}
<div class="circle"></div>
You can make the outer border more distinct by setting blur-radius to 0 on box-shadow.
.circle {
background-color: #F80;
border: 3px solid #FFF;
border-radius: 18px;
/* offset-x | offset-y | blur-radius | spread-radius | color */
box-shadow: 0 0 0 2px #888;
height: 30px;
width: 30px;
}
<div class="circle"></div>
As an alternative, you could use a second element:
.circle {
border: 1px solid #CCC;
border-radius: 19px;
display: inline-block;
}
.inner {
background-color: #F80;
border-radius: 15px;
margin: 3px;
height: 30px;
width: 30px;
}
<div class="circle">
<div class="inner"></div>
</div>
Try with:
.ui-corner-all { -moz-border-radius: 30px; -webkit-border-radius: 30px; border-radius: 30px; border: 1px solid black; margin: 2px; background: #fcc; width: 30px; height: 30px; }
Or with inner padding:
.ui-corner-all2 { -moz-border-radius: 30px; -webkit-border-radius: 30px; border-radius: 30px; border: 1px solid black; padding: 2px; background: #fcc; width: 30px; height: 30px; }
See also on this fiddle the difference when using margin vs padding CSS properties.
http://jsfiddle.net/MQx7r/4/
As others have said, only firefox supports this. Here is a work around that does the same thing, and even works with dashed outlines.
.has-outline {
background: #51ab9f;
border-radius: 50%;
padding: 5px;
position: relative;
width:200px;
height:200px;
}
.has-outline:after {
border-radius: 50%;
padding: 5px;
border: 2px dashed #9dd5cf;
position: absolute;
content: '';
top: -6px;
left: -6px;
bottom: -6px;
right: -6px;
}
<div class="has-outline">
</div>