Border styling of a circle to be ticks
I have a circle that has dotted borders. However, instead of dots the border should be more like vertical dashes.
Is there a way to make the border exactly the same as the design (the vertical dashes one not the thick solid line) with css?
I want to change this class: "OtherCaptionBorder"
My css:
.caption_circle{
position: absolute;
top: 450px;
left: 7%;
z-index: 10;
padding-top: 35px;
padding-bottom: 20px;
color: #fff;
text-align: center;
height: 245px;
width: 245px;
background-color: #373737;
opacity: 0.83;
border-radius: 50%;
display: inline-block;
border-color: #fff;
border-style: solid;
border-width: 7px;
font-family: open_sansregular;
font-weight: 600;
}
.OtherCaptionBorder{
position: absolute;
top: 2px;
left: 1%;
z-index: 10;
padding-top: 35px;
padding-bottom: 20px;
color: #fff;
text-align: center;
border-radius: 50%;
display: inline-block;
height: 228px;
width: 228px;
border-radius: 50%;
border: 2px dotted #ffffff;
}
.InnerCircleText{
margin-top: 8px;
font-size: 18px;
font-family: open_sansregular;
font-size: 24.3px;
font-weight: bold;
font-style: normal;
font-stretch: normal;
line-height: 1.11;
letter-spacing: 0.8px;
text-align: center;
color: #ffffff;
}
Here is my HTML :
<div class="caption_circle">
<div class="OtherCaptionBorder">
<p class="InnerCircleText">
DOCTOR-<br>
RECOMMENDED<br>
FOR IBS, IBD,<br>
CELIAC<br>
& SIBO<br>
<hr class="HRHomepage">
</p>
</div>
</div>
Here is how I want my circle to look like:
html css svg geometry stroke-dasharray
add a comment |
I have a circle that has dotted borders. However, instead of dots the border should be more like vertical dashes.
Is there a way to make the border exactly the same as the design (the vertical dashes one not the thick solid line) with css?
I want to change this class: "OtherCaptionBorder"
My css:
.caption_circle{
position: absolute;
top: 450px;
left: 7%;
z-index: 10;
padding-top: 35px;
padding-bottom: 20px;
color: #fff;
text-align: center;
height: 245px;
width: 245px;
background-color: #373737;
opacity: 0.83;
border-radius: 50%;
display: inline-block;
border-color: #fff;
border-style: solid;
border-width: 7px;
font-family: open_sansregular;
font-weight: 600;
}
.OtherCaptionBorder{
position: absolute;
top: 2px;
left: 1%;
z-index: 10;
padding-top: 35px;
padding-bottom: 20px;
color: #fff;
text-align: center;
border-radius: 50%;
display: inline-block;
height: 228px;
width: 228px;
border-radius: 50%;
border: 2px dotted #ffffff;
}
.InnerCircleText{
margin-top: 8px;
font-size: 18px;
font-family: open_sansregular;
font-size: 24.3px;
font-weight: bold;
font-style: normal;
font-stretch: normal;
line-height: 1.11;
letter-spacing: 0.8px;
text-align: center;
color: #ffffff;
}
Here is my HTML :
<div class="caption_circle">
<div class="OtherCaptionBorder">
<p class="InnerCircleText">
DOCTOR-<br>
RECOMMENDED<br>
FOR IBS, IBD,<br>
CELIAC<br>
& SIBO<br>
<hr class="HRHomepage">
</p>
</div>
</div>
Here is how I want my circle to look like:
html css svg geometry stroke-dasharray
1
You can't. Use an image instead.
– Quentin Veron
Nov 24 '18 at 11:46
@QuentinVeron its not possible to do vertical dashes? or make the dots longer in height?
– john
Nov 24 '18 at 12:35
2
It's possible with SVG, just as @ksav suggests. Imo a lot more viable and flexible solution than using a static image.
– agrm
Nov 24 '18 at 13:25
add a comment |
I have a circle that has dotted borders. However, instead of dots the border should be more like vertical dashes.
Is there a way to make the border exactly the same as the design (the vertical dashes one not the thick solid line) with css?
I want to change this class: "OtherCaptionBorder"
My css:
.caption_circle{
position: absolute;
top: 450px;
left: 7%;
z-index: 10;
padding-top: 35px;
padding-bottom: 20px;
color: #fff;
text-align: center;
height: 245px;
width: 245px;
background-color: #373737;
opacity: 0.83;
border-radius: 50%;
display: inline-block;
border-color: #fff;
border-style: solid;
border-width: 7px;
font-family: open_sansregular;
font-weight: 600;
}
.OtherCaptionBorder{
position: absolute;
top: 2px;
left: 1%;
z-index: 10;
padding-top: 35px;
padding-bottom: 20px;
color: #fff;
text-align: center;
border-radius: 50%;
display: inline-block;
height: 228px;
width: 228px;
border-radius: 50%;
border: 2px dotted #ffffff;
}
.InnerCircleText{
margin-top: 8px;
font-size: 18px;
font-family: open_sansregular;
font-size: 24.3px;
font-weight: bold;
font-style: normal;
font-stretch: normal;
line-height: 1.11;
letter-spacing: 0.8px;
text-align: center;
color: #ffffff;
}
Here is my HTML :
<div class="caption_circle">
<div class="OtherCaptionBorder">
<p class="InnerCircleText">
DOCTOR-<br>
RECOMMENDED<br>
FOR IBS, IBD,<br>
CELIAC<br>
& SIBO<br>
<hr class="HRHomepage">
</p>
</div>
</div>
Here is how I want my circle to look like:
html css svg geometry stroke-dasharray
I have a circle that has dotted borders. However, instead of dots the border should be more like vertical dashes.
Is there a way to make the border exactly the same as the design (the vertical dashes one not the thick solid line) with css?
I want to change this class: "OtherCaptionBorder"
My css:
.caption_circle{
position: absolute;
top: 450px;
left: 7%;
z-index: 10;
padding-top: 35px;
padding-bottom: 20px;
color: #fff;
text-align: center;
height: 245px;
width: 245px;
background-color: #373737;
opacity: 0.83;
border-radius: 50%;
display: inline-block;
border-color: #fff;
border-style: solid;
border-width: 7px;
font-family: open_sansregular;
font-weight: 600;
}
.OtherCaptionBorder{
position: absolute;
top: 2px;
left: 1%;
z-index: 10;
padding-top: 35px;
padding-bottom: 20px;
color: #fff;
text-align: center;
border-radius: 50%;
display: inline-block;
height: 228px;
width: 228px;
border-radius: 50%;
border: 2px dotted #ffffff;
}
.InnerCircleText{
margin-top: 8px;
font-size: 18px;
font-family: open_sansregular;
font-size: 24.3px;
font-weight: bold;
font-style: normal;
font-stretch: normal;
line-height: 1.11;
letter-spacing: 0.8px;
text-align: center;
color: #ffffff;
}
Here is my HTML :
<div class="caption_circle">
<div class="OtherCaptionBorder">
<p class="InnerCircleText">
DOCTOR-<br>
RECOMMENDED<br>
FOR IBS, IBD,<br>
CELIAC<br>
& SIBO<br>
<hr class="HRHomepage">
</p>
</div>
</div>
Here is how I want my circle to look like:
html css svg geometry stroke-dasharray
html css svg geometry stroke-dasharray
edited Nov 24 '18 at 17:46
ksav
5,35821331
5,35821331
asked Nov 24 '18 at 11:26
johnjohn
828
828
1
You can't. Use an image instead.
– Quentin Veron
Nov 24 '18 at 11:46
@QuentinVeron its not possible to do vertical dashes? or make the dots longer in height?
– john
Nov 24 '18 at 12:35
2
It's possible with SVG, just as @ksav suggests. Imo a lot more viable and flexible solution than using a static image.
– agrm
Nov 24 '18 at 13:25
add a comment |
1
You can't. Use an image instead.
– Quentin Veron
Nov 24 '18 at 11:46
@QuentinVeron its not possible to do vertical dashes? or make the dots longer in height?
– john
Nov 24 '18 at 12:35
2
It's possible with SVG, just as @ksav suggests. Imo a lot more viable and flexible solution than using a static image.
– agrm
Nov 24 '18 at 13:25
1
1
You can't. Use an image instead.
– Quentin Veron
Nov 24 '18 at 11:46
You can't. Use an image instead.
– Quentin Veron
Nov 24 '18 at 11:46
@QuentinVeron its not possible to do vertical dashes? or make the dots longer in height?
– john
Nov 24 '18 at 12:35
@QuentinVeron its not possible to do vertical dashes? or make the dots longer in height?
– john
Nov 24 '18 at 12:35
2
2
It's possible with SVG, just as @ksav suggests. Imo a lot more viable and flexible solution than using a static image.
– agrm
Nov 24 '18 at 13:25
It's possible with SVG, just as @ksav suggests. Imo a lot more viable and flexible solution than using a static image.
– agrm
Nov 24 '18 at 13:25
add a comment |
1 Answer
1
active
oldest
votes
You might be able to achieve something close to what you want with CSS alone, but as you can't control the length of (nor the space between) the dashes in the border style, you will most likely get an unsatisfactory result at the start/end of the circle where the borders meet.
body {
background: #ccc;
}
.outer {
background-color: rgba(0,0,0,0.5);
width: 300px;
height: 300px;
border-radius: 50%;
box-sizing: border-box;
border: 5px solid white;
}
.inner {
width: 100%;
height: 100%;
border: 5px dashed white;
border-radius: 50%;
box-sizing: border-box;
}
<div class="outer">
<div class="inner"></div>
</div>
But if you can use SVG you have control over stroke-dasharray
.img-bg {
background-image: url(https://picsum.photos/900/500);
background-size: cover;
}
.outer-circle {
position: relative;
background: transparent;
width: 20em;
height: 20em;
border-radius: 50%;
box-sizing: border-box;
border: 1em solid white;
overflow: hidden;
}
.custom-circle {
stroke-width: 10;
stroke: white;
stroke-linecap: butt;
fill: rgba(0, 0, 0, 0.5);
stroke-dasharray: 1 2.14; /* See below for an explanation */
}
.text {
margin: 0 auto;
padding: 0 1.5em;
color: white;
text-align: center;
position: absolute;
top: 50%;
font-size: 2em;
transform: translateY(-50%);
}
hr {
width: 60%
}
<section class="img-bg">
<div class="outer-circle">
<svg viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle class="custom-circle" cx="50" cy="50" r="50" />
</svg>
<div class="text">Vestibulum pellentesque ac arcu eget.<hr/></div>
</div>
</section>
Calculating the stroke-dasharray
values:
Why the magic number 2.14? According to Robert's answer on another question:
The circumference of the circle / sum of the
stroke-dasharray
values needs to be an integer if you want evenly spaced lines...
We know that our circle has a radius of 50 (<circle ... r="50" />
). So with a little maths (you can use google for this):
C=2πr=2·π·50≈314.15927
we calculate that our circumference is 314.15927
Say we want 100 dashes, from there C/100 ≈ 3.14
. This gives us the dash-array: 1 2.14
.
1
I second the idea of using SVG for this. On a side note; most of the attributes are valid CSS properties. So you can style the SVG using CSS instead of inline SVG/HTML attributes:.outer { stroke: white; stroke-width: 10; stroke-dasharray: 1 4; stroke-linecap: butt; fill: transparent; }
– agrm
Nov 24 '18 at 13:21
1
thanks. I've added those properties to CSS as per your recommendation.
– ksav
Nov 24 '18 at 13:25
1
thank you, it worked perfectly!
– john
Nov 24 '18 at 14:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457647%2fborder-styling-of-a-circle-to-be-ticks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You might be able to achieve something close to what you want with CSS alone, but as you can't control the length of (nor the space between) the dashes in the border style, you will most likely get an unsatisfactory result at the start/end of the circle where the borders meet.
body {
background: #ccc;
}
.outer {
background-color: rgba(0,0,0,0.5);
width: 300px;
height: 300px;
border-radius: 50%;
box-sizing: border-box;
border: 5px solid white;
}
.inner {
width: 100%;
height: 100%;
border: 5px dashed white;
border-radius: 50%;
box-sizing: border-box;
}
<div class="outer">
<div class="inner"></div>
</div>
But if you can use SVG you have control over stroke-dasharray
.img-bg {
background-image: url(https://picsum.photos/900/500);
background-size: cover;
}
.outer-circle {
position: relative;
background: transparent;
width: 20em;
height: 20em;
border-radius: 50%;
box-sizing: border-box;
border: 1em solid white;
overflow: hidden;
}
.custom-circle {
stroke-width: 10;
stroke: white;
stroke-linecap: butt;
fill: rgba(0, 0, 0, 0.5);
stroke-dasharray: 1 2.14; /* See below for an explanation */
}
.text {
margin: 0 auto;
padding: 0 1.5em;
color: white;
text-align: center;
position: absolute;
top: 50%;
font-size: 2em;
transform: translateY(-50%);
}
hr {
width: 60%
}
<section class="img-bg">
<div class="outer-circle">
<svg viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle class="custom-circle" cx="50" cy="50" r="50" />
</svg>
<div class="text">Vestibulum pellentesque ac arcu eget.<hr/></div>
</div>
</section>
Calculating the stroke-dasharray
values:
Why the magic number 2.14? According to Robert's answer on another question:
The circumference of the circle / sum of the
stroke-dasharray
values needs to be an integer if you want evenly spaced lines...
We know that our circle has a radius of 50 (<circle ... r="50" />
). So with a little maths (you can use google for this):
C=2πr=2·π·50≈314.15927
we calculate that our circumference is 314.15927
Say we want 100 dashes, from there C/100 ≈ 3.14
. This gives us the dash-array: 1 2.14
.
1
I second the idea of using SVG for this. On a side note; most of the attributes are valid CSS properties. So you can style the SVG using CSS instead of inline SVG/HTML attributes:.outer { stroke: white; stroke-width: 10; stroke-dasharray: 1 4; stroke-linecap: butt; fill: transparent; }
– agrm
Nov 24 '18 at 13:21
1
thanks. I've added those properties to CSS as per your recommendation.
– ksav
Nov 24 '18 at 13:25
1
thank you, it worked perfectly!
– john
Nov 24 '18 at 14:08
add a comment |
You might be able to achieve something close to what you want with CSS alone, but as you can't control the length of (nor the space between) the dashes in the border style, you will most likely get an unsatisfactory result at the start/end of the circle where the borders meet.
body {
background: #ccc;
}
.outer {
background-color: rgba(0,0,0,0.5);
width: 300px;
height: 300px;
border-radius: 50%;
box-sizing: border-box;
border: 5px solid white;
}
.inner {
width: 100%;
height: 100%;
border: 5px dashed white;
border-radius: 50%;
box-sizing: border-box;
}
<div class="outer">
<div class="inner"></div>
</div>
But if you can use SVG you have control over stroke-dasharray
.img-bg {
background-image: url(https://picsum.photos/900/500);
background-size: cover;
}
.outer-circle {
position: relative;
background: transparent;
width: 20em;
height: 20em;
border-radius: 50%;
box-sizing: border-box;
border: 1em solid white;
overflow: hidden;
}
.custom-circle {
stroke-width: 10;
stroke: white;
stroke-linecap: butt;
fill: rgba(0, 0, 0, 0.5);
stroke-dasharray: 1 2.14; /* See below for an explanation */
}
.text {
margin: 0 auto;
padding: 0 1.5em;
color: white;
text-align: center;
position: absolute;
top: 50%;
font-size: 2em;
transform: translateY(-50%);
}
hr {
width: 60%
}
<section class="img-bg">
<div class="outer-circle">
<svg viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle class="custom-circle" cx="50" cy="50" r="50" />
</svg>
<div class="text">Vestibulum pellentesque ac arcu eget.<hr/></div>
</div>
</section>
Calculating the stroke-dasharray
values:
Why the magic number 2.14? According to Robert's answer on another question:
The circumference of the circle / sum of the
stroke-dasharray
values needs to be an integer if you want evenly spaced lines...
We know that our circle has a radius of 50 (<circle ... r="50" />
). So with a little maths (you can use google for this):
C=2πr=2·π·50≈314.15927
we calculate that our circumference is 314.15927
Say we want 100 dashes, from there C/100 ≈ 3.14
. This gives us the dash-array: 1 2.14
.
1
I second the idea of using SVG for this. On a side note; most of the attributes are valid CSS properties. So you can style the SVG using CSS instead of inline SVG/HTML attributes:.outer { stroke: white; stroke-width: 10; stroke-dasharray: 1 4; stroke-linecap: butt; fill: transparent; }
– agrm
Nov 24 '18 at 13:21
1
thanks. I've added those properties to CSS as per your recommendation.
– ksav
Nov 24 '18 at 13:25
1
thank you, it worked perfectly!
– john
Nov 24 '18 at 14:08
add a comment |
You might be able to achieve something close to what you want with CSS alone, but as you can't control the length of (nor the space between) the dashes in the border style, you will most likely get an unsatisfactory result at the start/end of the circle where the borders meet.
body {
background: #ccc;
}
.outer {
background-color: rgba(0,0,0,0.5);
width: 300px;
height: 300px;
border-radius: 50%;
box-sizing: border-box;
border: 5px solid white;
}
.inner {
width: 100%;
height: 100%;
border: 5px dashed white;
border-radius: 50%;
box-sizing: border-box;
}
<div class="outer">
<div class="inner"></div>
</div>
But if you can use SVG you have control over stroke-dasharray
.img-bg {
background-image: url(https://picsum.photos/900/500);
background-size: cover;
}
.outer-circle {
position: relative;
background: transparent;
width: 20em;
height: 20em;
border-radius: 50%;
box-sizing: border-box;
border: 1em solid white;
overflow: hidden;
}
.custom-circle {
stroke-width: 10;
stroke: white;
stroke-linecap: butt;
fill: rgba(0, 0, 0, 0.5);
stroke-dasharray: 1 2.14; /* See below for an explanation */
}
.text {
margin: 0 auto;
padding: 0 1.5em;
color: white;
text-align: center;
position: absolute;
top: 50%;
font-size: 2em;
transform: translateY(-50%);
}
hr {
width: 60%
}
<section class="img-bg">
<div class="outer-circle">
<svg viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle class="custom-circle" cx="50" cy="50" r="50" />
</svg>
<div class="text">Vestibulum pellentesque ac arcu eget.<hr/></div>
</div>
</section>
Calculating the stroke-dasharray
values:
Why the magic number 2.14? According to Robert's answer on another question:
The circumference of the circle / sum of the
stroke-dasharray
values needs to be an integer if you want evenly spaced lines...
We know that our circle has a radius of 50 (<circle ... r="50" />
). So with a little maths (you can use google for this):
C=2πr=2·π·50≈314.15927
we calculate that our circumference is 314.15927
Say we want 100 dashes, from there C/100 ≈ 3.14
. This gives us the dash-array: 1 2.14
.
You might be able to achieve something close to what you want with CSS alone, but as you can't control the length of (nor the space between) the dashes in the border style, you will most likely get an unsatisfactory result at the start/end of the circle where the borders meet.
body {
background: #ccc;
}
.outer {
background-color: rgba(0,0,0,0.5);
width: 300px;
height: 300px;
border-radius: 50%;
box-sizing: border-box;
border: 5px solid white;
}
.inner {
width: 100%;
height: 100%;
border: 5px dashed white;
border-radius: 50%;
box-sizing: border-box;
}
<div class="outer">
<div class="inner"></div>
</div>
But if you can use SVG you have control over stroke-dasharray
.img-bg {
background-image: url(https://picsum.photos/900/500);
background-size: cover;
}
.outer-circle {
position: relative;
background: transparent;
width: 20em;
height: 20em;
border-radius: 50%;
box-sizing: border-box;
border: 1em solid white;
overflow: hidden;
}
.custom-circle {
stroke-width: 10;
stroke: white;
stroke-linecap: butt;
fill: rgba(0, 0, 0, 0.5);
stroke-dasharray: 1 2.14; /* See below for an explanation */
}
.text {
margin: 0 auto;
padding: 0 1.5em;
color: white;
text-align: center;
position: absolute;
top: 50%;
font-size: 2em;
transform: translateY(-50%);
}
hr {
width: 60%
}
<section class="img-bg">
<div class="outer-circle">
<svg viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle class="custom-circle" cx="50" cy="50" r="50" />
</svg>
<div class="text">Vestibulum pellentesque ac arcu eget.<hr/></div>
</div>
</section>
Calculating the stroke-dasharray
values:
Why the magic number 2.14? According to Robert's answer on another question:
The circumference of the circle / sum of the
stroke-dasharray
values needs to be an integer if you want evenly spaced lines...
We know that our circle has a radius of 50 (<circle ... r="50" />
). So with a little maths (you can use google for this):
C=2πr=2·π·50≈314.15927
we calculate that our circumference is 314.15927
Say we want 100 dashes, from there C/100 ≈ 3.14
. This gives us the dash-array: 1 2.14
.
body {
background: #ccc;
}
.outer {
background-color: rgba(0,0,0,0.5);
width: 300px;
height: 300px;
border-radius: 50%;
box-sizing: border-box;
border: 5px solid white;
}
.inner {
width: 100%;
height: 100%;
border: 5px dashed white;
border-radius: 50%;
box-sizing: border-box;
}
<div class="outer">
<div class="inner"></div>
</div>
body {
background: #ccc;
}
.outer {
background-color: rgba(0,0,0,0.5);
width: 300px;
height: 300px;
border-radius: 50%;
box-sizing: border-box;
border: 5px solid white;
}
.inner {
width: 100%;
height: 100%;
border: 5px dashed white;
border-radius: 50%;
box-sizing: border-box;
}
<div class="outer">
<div class="inner"></div>
</div>
.img-bg {
background-image: url(https://picsum.photos/900/500);
background-size: cover;
}
.outer-circle {
position: relative;
background: transparent;
width: 20em;
height: 20em;
border-radius: 50%;
box-sizing: border-box;
border: 1em solid white;
overflow: hidden;
}
.custom-circle {
stroke-width: 10;
stroke: white;
stroke-linecap: butt;
fill: rgba(0, 0, 0, 0.5);
stroke-dasharray: 1 2.14; /* See below for an explanation */
}
.text {
margin: 0 auto;
padding: 0 1.5em;
color: white;
text-align: center;
position: absolute;
top: 50%;
font-size: 2em;
transform: translateY(-50%);
}
hr {
width: 60%
}
<section class="img-bg">
<div class="outer-circle">
<svg viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle class="custom-circle" cx="50" cy="50" r="50" />
</svg>
<div class="text">Vestibulum pellentesque ac arcu eget.<hr/></div>
</div>
</section>
.img-bg {
background-image: url(https://picsum.photos/900/500);
background-size: cover;
}
.outer-circle {
position: relative;
background: transparent;
width: 20em;
height: 20em;
border-radius: 50%;
box-sizing: border-box;
border: 1em solid white;
overflow: hidden;
}
.custom-circle {
stroke-width: 10;
stroke: white;
stroke-linecap: butt;
fill: rgba(0, 0, 0, 0.5);
stroke-dasharray: 1 2.14; /* See below for an explanation */
}
.text {
margin: 0 auto;
padding: 0 1.5em;
color: white;
text-align: center;
position: absolute;
top: 50%;
font-size: 2em;
transform: translateY(-50%);
}
hr {
width: 60%
}
<section class="img-bg">
<div class="outer-circle">
<svg viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle class="custom-circle" cx="50" cy="50" r="50" />
</svg>
<div class="text">Vestibulum pellentesque ac arcu eget.<hr/></div>
</div>
</section>
edited Nov 26 '18 at 13:29
answered Nov 24 '18 at 12:49
ksavksav
5,35821331
5,35821331
1
I second the idea of using SVG for this. On a side note; most of the attributes are valid CSS properties. So you can style the SVG using CSS instead of inline SVG/HTML attributes:.outer { stroke: white; stroke-width: 10; stroke-dasharray: 1 4; stroke-linecap: butt; fill: transparent; }
– agrm
Nov 24 '18 at 13:21
1
thanks. I've added those properties to CSS as per your recommendation.
– ksav
Nov 24 '18 at 13:25
1
thank you, it worked perfectly!
– john
Nov 24 '18 at 14:08
add a comment |
1
I second the idea of using SVG for this. On a side note; most of the attributes are valid CSS properties. So you can style the SVG using CSS instead of inline SVG/HTML attributes:.outer { stroke: white; stroke-width: 10; stroke-dasharray: 1 4; stroke-linecap: butt; fill: transparent; }
– agrm
Nov 24 '18 at 13:21
1
thanks. I've added those properties to CSS as per your recommendation.
– ksav
Nov 24 '18 at 13:25
1
thank you, it worked perfectly!
– john
Nov 24 '18 at 14:08
1
1
I second the idea of using SVG for this. On a side note; most of the attributes are valid CSS properties. So you can style the SVG using CSS instead of inline SVG/HTML attributes:
.outer { stroke: white; stroke-width: 10; stroke-dasharray: 1 4; stroke-linecap: butt; fill: transparent; }
– agrm
Nov 24 '18 at 13:21
I second the idea of using SVG for this. On a side note; most of the attributes are valid CSS properties. So you can style the SVG using CSS instead of inline SVG/HTML attributes:
.outer { stroke: white; stroke-width: 10; stroke-dasharray: 1 4; stroke-linecap: butt; fill: transparent; }
– agrm
Nov 24 '18 at 13:21
1
1
thanks. I've added those properties to CSS as per your recommendation.
– ksav
Nov 24 '18 at 13:25
thanks. I've added those properties to CSS as per your recommendation.
– ksav
Nov 24 '18 at 13:25
1
1
thank you, it worked perfectly!
– john
Nov 24 '18 at 14:08
thank you, it worked perfectly!
– john
Nov 24 '18 at 14:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457647%2fborder-styling-of-a-circle-to-be-ticks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You can't. Use an image instead.
– Quentin Veron
Nov 24 '18 at 11:46
@QuentinVeron its not possible to do vertical dashes? or make the dots longer in height?
– john
Nov 24 '18 at 12:35
2
It's possible with SVG, just as @ksav suggests. Imo a lot more viable and flexible solution than using a static image.
– agrm
Nov 24 '18 at 13:25