Please run the example below. I'm trying to stretch the left line further to the left to compensate the parent's padding as you can see in the second example, while keeping the title centered relative to the parent like in the first example. I can't seem to have both.
(For anyone who's familiar, the divider I'm trying to tweak comes from ant-design)
#container {
height: 100px;
width: 400px;
background: #EFEFEF;
padding: 24px;
}
/* Normal use case */
.divider {
position: relative;
line-height: 23px;
height: 1px;
display: table;
margin: 16px 0;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
font-size: 15px;
white-space: nowrap;
text-align: center;
background: transparent;
}
.divider::before, .divider::after {
position: relative;
top: 50%;
display: table-cell;
width: 50%;
border-top: 1px solid #AAA;
-webkit-transform: translateY(50%);
-ms-transform: translateY(50%);
transform: translateY(50%);
content: '';
}
.divider-text {
display: inline-block;
padding: 0 24px;
}
/* Trying to stretch the left line to further to the left without puting the title off-center */
.divider.stretched-left {
left: -24px;
width: calc(100% + 24px);
min-width: calc(100% + 24px);
}
<div id="container">
<div class="divider">
<span class="divider-text">Title</span>
</div>
<div class="divider stretched-left">
<span class="divider-text">Title</span>
</div>
</div>
First, I would use flexbox instead of table layout then adjust the margin/padding:
Kept only the relevant code for the demo
#container {
width: 400px;
background: #EFEFEF;
padding: 24px;
}
/* Normal use case */
.divider {
display: flex;
margin: 16px 0;
align-items:center;
}
.divider::before, .divider::after {
flex:1;
height: 1px;
background:#AAA;
content: '';
}
.divider::before {
margin-right:24px;
}
.divider::after {
margin-left:24px;
}
.divider.stretched-left:before {
margin-left:-24px;
padding-left: 24px;
}
.divider.stretched-right:after {
margin-right:-24px;
padding-right: 24px;
}
<div id="container">
<div class="divider">
<span class="divider-text">Title</span>
</div>
<div class="divider stretched-left">
<span class="divider-text">another Title</span>
</div>
<div class="divider stretched-right">
<span class="divider-text">Title</span>
</div>
<div class="divider stretched-right">
<span class="divider-text">another Title</span>
</div>
<div class="divider stretched-left stretched-right">
<span class="divider-text">another Title</span>
</div>
</div>
With your original code you can try this:
#container {
height: 100px;
width: 400px;
background: #EFEFEF;
padding: 24px;
}
/* Normal use case */
.divider {
position: relative;
line-height: 23px;
height: 1px;
display: table;
margin: 16px 0;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
font-size: 15px;
white-space: nowrap;
text-align: center;
background: transparent;
}
.divider::before, .divider::after {
position: relative;
top: 50%;
display: table-cell;
width: 50%;
border-top: 1px solid #AAA;
transform: translateY(50%);
content: '';
}
.divider-text {
display: inline-block;
padding: 0 24px;
}
/* Trying to stretch the left line to further to the left without puting the title off-center */
.divider.stretched-left {
left: -24px;
width: calc(100% + 48px); /* Updated */
}
/* Added */
.divider.stretched-left:after {
border-image:linear-gradient(to left,transparent 24px, #aaa 24px) 1;
}
<div id="container">
<div class="divider">
<span class="divider-text">Title</span>
</div>
<div class="divider stretched-left">
<span class="divider-text">Title</span>
</div>
</div>
#container {
height: 100px;
width: 400px;
background: #EFEFEF;
padding: 24px;
}
.divider {
position: relative;
line-height: 23px;
height: 1px;
display: table;
margin: 16px 0;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
font-size: 15px;
white-space: nowrap;
text-align: center;
background: transparent;
width: 100%; /* SOLUTION – this is new */
}
.divider::before, .divider::after {
position: absolute; /* SOLUTION – this has changed */
top: 50%;
display: table-cell;
width: 41%; /* SOLUTION – changed, matches desired layout best */
border-top: 1px solid #AAA;
-webkit-transform: translateY(50%);
-ms-transform: translateY(50%);
transform: translateY(50%);
content: '';
}
.divider::before{
left: -24px; /* SOLUTION – compensate #container padding */
width: calc( 41% + 24px ); /* SOLUTION – add the offset to the width */
}
.divider::after{
right: 0px; /* SOLUTION */
}
.divider-text {
display: inline-block;
padding: 0 24px;
}
<div id="container">
<div class="divider">
<span class="divider-text">Title</span>
</div>
</div>
.divider.stretched-left {
left: -24px;
width: calc(100% + 48px);
min-width: calc(100% + 48px);
}
Just You have to replace last css lines code with above given code.
Solution with minimum CSS, without flex, without transform.
.divider {
position: relative;
text-align:center;
}
.divider:before {
content:'';
position: absolute;
top:50%;
height: 1px;
width: 100%;
background: #000;
left: 0;
z-index: -1;
}
.divider span{
padding: 0 24px;
z-index: 1;
background: #fff;
display: inline-block;
}
<div class="divider">
<span>Title</span>
</div>
Related
How to place a vertical line between two div elements?
.flex-container {
display: -webkit-flex;
margin: 0 auto;
text-align: center;
}
.flex-container .column {
width: 320px;
text-align: center;
}
.vr {
border-left: 2px dotted black;
width: 2px;
margin: 0px 5px 0px 5px;
height: 200px;
}
<div>
<div class="flex-container mt-3 d-flex justify-content-center align-items-center">
<div class="column">Karvat group was established in Mumbai.</div>
<div class="vr "></div>
<div class="column2 bg-alt box arrow-left ml-15 "> 1952</div>
</div>
</div>
Rough way of getting this done.
HTML
<div class="timeline">
<div class="container left">
<div class="content">
<h2>2017</h2>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>2016</h2>
<p>Lorem ipsum..</p>
</div>
</div>
</div>
CSS
* {
box-sizing: border-box;
}
/* Set a background color */
body {
background-color: #474e5d;
font-family: Helvetica, sans-serif;
}
/* The actual timeline (the vertical ruler) */
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
}
/* The actual timeline (the vertical ruler) */
.timeline::after {
content: '';
position: absolute;
width: 6px;
background-color: white;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
/* Container around content */
.container {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
/* The circles on the timeline */
.container::after {
content: '';
position: absolute;
width: 25px;
height: 25px;
right: -17px;
background-color: white;
border: 4px solid #FF9F55;
top: 15px;
border-radius: 50%;
z-index: 1;
}
/* Place the container to the left */
.left {
left: 0;
}
/* Place the container to the right */
.right {
left: 50%;
}
/* Add arrows to the left container (pointing right) */
.left::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
right: 30px;
border: medium solid white;
border-width: 10px 0 10px 10px;
border-color: transparent transparent transparent white;
}
/* Add arrows to the right container (pointing left) */
.right::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
left: 30px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
/* Fix the circle for containers on the right side */
.right::after {
left: -16px;
}
/* The actual content */
.content {
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 6px;
}
/* Media queries - Responsive timeline on screens less than 600px wide */
#media screen and (max-width: 600px) {
/* Place the timelime to the left */
.timeline::after {
left: 31px;
}
/* Full-width containers */
.container {
width: 100%;
padding-left: 70px;
padding-right: 25px;
}
/* Make sure that all arrows are pointing leftwards */
.container::before {
left: 60px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
/* Make sure all circles are at the same spot */
.left::after, .right::after {
left: 15px;
}
/* Make all right containers behave like the left ones */
.right {
left: 0%;
}
}
Output:
Here is the sample code for it, You can also take some help from online codepen's https://codepen.io/havardob/pen/dyKoOjX
.stepper{
height: 400px;
width: 1px;
border-right: 2px dashed black;
position: relative;
}
.stepper:before,
.stepper:after
{
content: "";
position: absolute;
width: 10px;
height: 10px;
right: -7px;
border-radius: 50%;
border: 1px solid black;
background: #fff;
}
.stepper:after{
top: 50px;
}
<div class="stepper">
</div>
I'm trying to draw this output with css (or svg). For me, the tough part is the half-arc at the left and right side of the circle. Should I stick to pure css or is it better using images?
Any help is appreciated...
This is what I managed to make :
Here is the code :
body {
background-color: #002911 !important;
}
h3 {
color: #ffd004;
}
#actions-container {
margin-top: 30px;
}
#actions-container .action-icon {
width: 200px;
height: 200px;
background-color: rgb(255, 208, 4);
border-radius: 50%;
box-shadow: 5px -2px 6px 3px #0000004a;
/* center contents*/
display: flex;
justify-content: center;
align-items: center;
}
.right-arc {
position: relative;
display: inline-block;
font-size: 30px;
color: lightgreen;
margin: 40px;
}
.right-arc::after {
content: '';
position: absolute;
right: -150px;
top: 57px;
height: 300px;
width: 300px;
border-radius: 50% 50% 50% 50%;
border-width: 0px 1px 0px 0px;
border-style: solid;
/*border-top: outset;*/
}
/*svg {
width: 33%;
height: auto;
}*/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="container" id="actions-container">
<div class="d-flex justify-content-between">
<div class="action-icon-box text-center ">
<div class="right-arc">
</div>
<h3 class="text-center">Title</h3>
<div class="p-1 action-icon text-center mt-4">
<img class="center" src="/Content/images/lp-homepage/microphone.png" height="100" />
</div>
</div>
</div>
</div>
You could use a pseudo element with an inset box-shadow to create the fade out border on the bottom like this :
body {
background: #232323;
}
.wrap {
box-sizing: border-box;
position: relative;
width: 50%;
border: 3px solid #ffd004;
border-radius: 50%;
}
.wrap::before {
content:'';
display:block;
padding-bottom:100%;
}
.wrap::after {
content: '';
position: absolute;
bottom: -3px;
left: -3px;
right: -3px;
height: 100%;
z-index: 1;
box-shadow: inset 0px -270px 70px -100px #232323;
}
.title {
color: #ffd004;
margin: 0;
position: absolute;
top: -3px;
left: 0;
width: 100%;
text-align: center;
z-index: 2;
background: #232323;
}
.circle {
position: absolute;
top:15%;
left:15%;
width: 70%;
height: 70%;
border-radius: 50%;
background: #ffd004;
z-index: 2;
}
<div class="wrap">
<h2 class="title">Title</h2>
<div class="circle"></div>
</div>
Be aware that this will only work on plain color background. If you need to display this over a gradient or image, I highly suggest using SVG.
The aspect ratio of the circle is kept using the "padding technique" from this answer : Maintain the aspect ratio of a div with CSS
If you need transparency, you can use a mask-image with a linear-gradient.
/* based on #web-tiki's implementation */
body {
background: #232323;
}
.wrap {
box-sizing: border-box;
position: relative;
width: 50%;
padding: 60px;
}
/* the border */
.wrap::before {
content:"";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #ffd004;
border-radius: 50%;
-webkit-mask-image: linear-gradient(transparent 10%, black 10%, transparent 80% );
mask-image: linear-gradient(transparent 10%, black 10%, transparent 80% );
}
/* the circle */
.wrap::after {
content:"";
display:block;
background: #ffd004;
padding-top: 100%;
border-radius: 50%;
box-shadow: 6px 0px 10px black;
}
.title {
color: #ffd004;
margin: 0;
position: absolute;
top: -3px;
left: 0;
right: 0;
text-align: center;
}
body:hover {
/* CSS checkerboard stolen from https://drafts.csswg.org/css-images-4/#example-2de97f53 */
background: repeating-conic-gradient(rgba(0,0,0,0.1) 0deg 25%, white 0deg 50%);
background-size: 2em 2em;
}
<div class="wrap">
<h2 class="title">Title</h2>
</div>
Try this
body {
background-color: #002911 !important;
}
h3 {
color: #ffd004;
}
#actions-container {
margin-top: 30px;
}
#actions-container .action-icon {
width: 200px;
height: 200px;
background-color: rgb(255, 208, 4);
border-radius: 50%;
box-shadow: 5px -2px 6px 3px #0000004a;
/* center contents*/
display: flex;
justify-content: center;
align-items: center;
}
.action-icon-box{
position: relative;
}
#actions-container .action-icon-box::after,#actions-container .action-icon-box::before{
position: absolute;
content: '';
width: 300px;
height:300px;
border-radius: 50%;
z-index:-1;
top:0px;
border: 2px solid;
border-color:transparent;
}
#actions-container .action-icon-box::before{
border-right-color: green;
right: -60px;
}
#actions-container .action-icon-box::after{
border-left-color: green;
left: -60px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container" id="actions-container">
<div class="d-flex justify-content-between">
<div class="action-icon-box text-center ">
<h3 class="text-center">Title</h3>
<div class="p-1 action-icon text-center mt-4">
<img class="center" src="/Content/images/lp-homepage/microphone.png" height="100" />
</div>
</div>
</div>
</div>
i have a box and i need to put smooth triangle bottom of the div but i couldn't achieve as i want how can i do this like below image ?
.slide-box {
position: relative;
display: inline-block;
background: #e41113;
border: 1px solid #df2b2c;
border-radius: 6px;
}
.slide-box a {
display: block;
color: #fff;
text-decoration: none;
padding: 12px 10px;
}
.slide-box:after {
content: '';
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
width: 0;
height: 0;
border-top: 25px solid #df2b2c;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
}
<div class="slide-box">
<a href="#">
I'm a super <br>box!
</a>
</div>
I'm not sure that you'll be able to complete what you want with ::after.
But probably you can use transition rotate and scale on absolute positioned element in the bottom.
Here's the concept:
.slide-box {
position: relative;
display: inline-block;
background: #e41113;
border: 1px solid #df2b2c;
border-radius: 6px;
width: 145px;
height: 70px;
}
.slide-box a {
display: block;
color: #fff;
background: #e41113;
display: block;
text-decoration: none;
padding: 12px 10px;
z-index:1000;
}
.slide-box .corner {
position: absolute;
top: 70px;
left: 0px;
width: 103px;
height: 103px;
background-color: #e41113;
transform-origin: top left;
transform: scale(1, 0.25) rotate(-45deg);
border-radius: 6px;
}
<div class="slide-box">
<a href="#">
I'm a super <br>box!
</a>
<div class="corner"></div>
</div>
Of course the main task will be positioning.
So there you need 2 prerequisitions:
With "transform-origin: top left;" you need to keep top of the .corner == height of your main container (don't know why, but bottom:0 not works, maybe youll resolve
this)
The .corner should be square (width=height), and to keep it smooth you need to maintain ratio width(.corner) = width(.slide-box)*sqrt(2). Means width of your corner`s diagonal should be equal to width of main container.
Here is a way to do:
.container {
width: 300px;
}
.slide-box {
height: 200px;
width: 100%;
position: relative;
background-color: #df2b2c;
text-align: left;
margin-left: 70px;
margin-bottom: -75px;
border-radius: 0 0 25% 25%;
}
.slide-box a {
display: block;
color: #fff;
text-decoration: none;
padding: 12px 10px;
}
.corner {
position: relative;
background-color: #df2b2c;
text-align: left;
margin-left: 95px;
}
.corner:before,
.corner:after {
content: '';
position: absolute;
background-color: inherit;
}
.corner,
.corner:before,
.corner:after {
width: 165px;
height: 165px;
border-top-right-radius: 30%;
}
.corner {
transform: rotate(-120deg) skewX(-30deg) scale(1,.866);
}
.corner:before {
transform: rotate(-135deg) skewX(-45deg) scale(1.414,.707) translate(0,-50%);
}
.corner:after {
transform: rotate(135deg) skewY(-45deg) scale(.707,1.414) translate(50%);
}
<div class="container">
<div class="slide-box">
<a href="#">
I'm a super <br>box!
</a>
</div>
<div class="corner"></div>
</div>
I have a screenshot as shown below which I have to replicate in HTML/CSS. In the following screenshot I wasn't able to make colored left and right arrows in between the squares.
At this moment, I am able to replicate this in fiddle without colored left and right arrows.
The snippets of CSS code which I have used in order to make series of small squares are:
.squares .square {
width: 200px;
text-align: center;
height: 200px;
background-color: white;
border-radius: 15px;
}
Problem Statement:
I am wondering what CSS codes I should add in the fiddle so that colored left and right arrows in between the squares shows up in the fiddle.
You can do that by HTML special characters like below:
.squares {
display: flex;
justify-content: space-between;
align-items:center;
padding: 1rem;
background-color: rgb(238, 238, 238);
flex-wrap: wrap;
}
.squares .square {
width: 200px;
text-align: center;
height: 200px;
background-color: white;
border-radius: 15px;
}
.squares .square p
{
text-align: center;
vertical-align: bottom;
}
.arrows {
text-align:center;
}
.arrows span {
display:block;
font-size:48px;
line-height:32px;
color:green;
font-weight:bold;
}
.arrows span:first-child {
color:#C90;
}
<div class="squares">
<div class="square"><p>Franchise Hub Hierarchy</p><img src="https://s7.postimg.cc/jvu89zp17/Layer_30.png" alt=""/></div>
<div class="arrows">
<span>→</span>
<span>←</span>
</div>
<div class="square"><p>System wide user permissions</p><img src="https://s7.postimg.cc/6ronxc7a3/Layer_33.png" alt=""/></div>
<div class="arrows">
<span>→</span>
<span>←</span>
</div>
<div class="square"><p>Custom Corporate Branding</p><img src="https://s7.postimg.cc/wn8egkbor/Layer_46.png" alt=""/></div>
<div class="arrows">
<span>→</span>
<span>←</span>
</div>
<div class="square"><p>Configurable Workflow</p><img src="https://s7.postimg.cc/k8lmg8rwb/Layer_47.png" alt=""/></div>
<div class="arrows">
<span>→</span>
<span>←</span>
</div>
<div class="square"><p>Orders, C.R.M. and P.O.S</p><img src="https://s7.postimg.cc/9yj7h0hgb/Shape_33.png" alt=""/></div>
</div>
You can try font awesome arrows
https://fontawesome.com/icons/arrow-left?style=solid
or make arrows using CSS borders
#arrow {
width: 0;
height: 0;
border-top: 20px solid transparent;
border-left: 40px solid red;
border-bottom: 20px solid transparent;
margin-left: 20px;
}
#arrow:before {
content: "";
position: absolute;
width: 30px ;
height: 10px;
background: red;
left: 0;
top: 22px;
}
<div id="arrow"></div>
and if you want your text towards the bottom of your box, You should write <p> after <img>.
<div class="square">
<img src="https://s7.postimg.cc/jvu89zp17/Layer_30.png" alt=""/>
<p>Franchise Hub Hierarchy</p>
</div>
Here is the cure CSS and simplest solution for your problem.
I have done this for you, just add a div between every square div
<div class="arrowWrapper">
<span class="arrow redArrow"></span><br>
<span class="arrow greenArrow"></span>
</div>
and this css to your code:
.arrow {
display:block;
height: 2px;
margin: 3px 0;
width: 35px;
position: relative;
}
.arrow.redArrow {background-color: red;}
.arrow.greenArrow {background-color: green;}
.arrowWrapper { margin-right: -20px; margin-left: -20px;}
.arrow.redArrow:after{
position: absolute;
content: "";
height: 2px;
width: 12px;
background: red;
right: -1px;
transform: rotate(45deg);
top: -4px;
}
.arrow.redArrow:before{
position: absolute;
content: "";
height: 2px;
width: 12px;
background: red;
right: -1px;
transform: rotate(135deg);
top: 4px;
}
.arrow.greenArrow:after{
position: absolute;
content: "";
height: 2px;
width: 12px;
background: green;
left: -1px;
transform: rotate(135deg);
top: -4px;
}
.arrow.greenArrow:before{
position: absolute;
content: "";
height: 2px;
width: 12px;
background: green;
left: -1px;
transform: rotate(45deg);
top: 4px;
}
Complete code is in below snippetenjoy
.squares {
display: flex;
justify-content: space-between;
align-items:center;
padding: 1rem;
background-color: rgb(238, 238, 238);
flex-wrap: wrap;
}
.squares .square {
width: 200px;
text-align: center;
height: 200px;
background-color: white;
border-radius: 15px;
}
.squares .square p
{
text-align: center;
vertical-align: bottom;
}
.arrow {
display:block;
height: 2px;
margin: 3px 0;
width: 35px;
position: relative;
}
.arrow.redArrow {background-color: red;}
.arrow.greenArrow {background-color: green;}
.arrowWrapper { margin-right: -20px; margin-left: -20px;}
.arrow.redArrow:after{
position: absolute;
content: "";
height: 2px;
width: 12px;
background: red;
right: -1px;
transform: rotate(45deg);
top: -4px;
}
.arrow.redArrow:before{
position: absolute;
content: "";
height: 2px;
width: 12px;
background: red;
right: -1px;
transform: rotate(135deg);
top: 4px;
}
.arrow.greenArrow:after{
position: absolute;
content: "";
height: 2px;
width: 12px;
background: green;
left: -1px;
transform: rotate(135deg);
top: -4px;
}
.arrow.greenArrow:before{
position: absolute;
content: "";
height: 2px;
width: 12px;
background: green;
left: -1px;
transform: rotate(45deg);
top: 4px;
}
<div class="squares">
<div class="square"><p>Franchise Hub Hierarchy</p><img src="https://s7.postimg.cc/jvu89zp17/Layer_30.png" alt=""/></div>
<div class="arrowWrapper">
<span class="arrow redArrow"></span><br>
<span class="arrow greenArrow"></span></div>
<div class="square"><p>System wide user permissions</p><img src="https://s7.postimg.cc/6ronxc7a3/Layer_33.png" alt=""/></div>
<div class="square"><p>Custom Corporate Branding</p><img src="https://s7.postimg.cc/wn8egkbor/Layer_46.png" alt=""/></div>
<div class="square"><p>Configurable Workflow</p><img src="https://s7.postimg.cc/k8lmg8rwb/Layer_47.png" alt=""/></div>
<div class="square"><p>Orders, C.R.M. and P.O.S</p><img src="https://s7.postimg.cc/9yj7h0hgb/Shape_33.png" alt=""/></div>
</div>
Despite setting properties, the text inside the circle won't move to the exact centre and the radial graph itself won't move to the centre of the div it is inside. Does anyone what's wrong and how to fix this?
/**
* Card Styles
*/
.card {
background-color: #fff;
/* margin-bottom: 1.6rem; */
}
.card__padding {
padding: 1.2rem;
}
.card__content {
position: relative;
}
/* card article */
.card__article a {
text-decoration: none;
color: black;
}
.card__article p {
text-align: center;
text-decoration: none;
color: black;
}
/*radial progress bar*/
.pie-wrapper {
display: inline-block;
position: relative;
width: 200px;
height: 200px;
margin-left: 50%;
border: 10px solid #ddd;
border-radius: 50%;
margin: 0 auto;
}
.pie-wrapper .pie {
clip: rect(0, 200px, 200px, 0px);
height: 200px;
width: 200px;
margin: -10px 0 0 -10px;
}
.pie-wrapper .pie .half-circle {
border: 10px solid #3498db;
clip: rect(0, 100px, 200px, 0);
height: 200px;
position: absolute;
width: 200px;
border-radius: 50%;
}
.pie-wrapper .label {
position: absolute;
top: 12.5%;
right: 1%;
width: 180px;
height: 180px;
color: black;
cursor: default;
font-size: 2em;
line-height: 2.5em;
border-radius: 50%;
}
.pie-wrapper .shadow {
width: 100%;
height: 100%;
border: 20px solid #bdc3c7;
border-radius: 50%;
}
.pie-wrapper.progress-full .pie {
clip: inherit;
}
.pie-wrapper.progress-full .pie .right-side {
display: block;
-webkit-transform: rotate(220deg);
-moz-transform: rotate(220deg);
transform: rotate(220deg);
}
div,
div:before,
div:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
<div class="card radius shadowDepth1">
<div class="card__content card__padding">
<article class="card__article">
<h2>Hello world</h2>
<div class="pie-wrapper progress-full">
<span class="label">2017</span>
<div class="pie">
<div class="left-side half-circle"></div>
<div class="right-side half-circle"></div>
</div>
</div>
<p>Bounjour, tout le monde</p>
</article>
</div>
</div>
add text-align: center; to card class
/**
* Card Styles
*/
.card {
background-color: #fff;
text-align: center;
/* margin-bottom: 1.6rem; */
}
.card__padding {
padding: 1.2rem;
}
.card__content {
position: relative;
}
/* card article */
.card__article a {
text-decoration: none;
color: black;
}
.card__article p {
text-align: center;
text-decoration: none;
color: black;
}
/*radial progress bar*/
.pie-wrapper {
display: inline-block;
position: relative;
width: 200px;
height: 200px;
margin-left: 50%;
border: 10px solid #ddd;
border-radius: 50%;
margin: 0 auto;
}
.pie-wrapper .pie {
clip: rect(0, 200px, 200px, 0px);
height: 200px;
width: 200px;
margin: -10px 0 0 -10px;
}
.pie-wrapper .pie .half-circle {
border: 10px solid #3498db;
clip: rect(0, 100px, 200px, 0);
height: 200px;
position: absolute;
width: 200px;
border-radius: 50%;
}
.pie-wrapper .label {
position: absolute;
top: 12.5%;
right: 1%;
width: 180px;
height: 180px;
color: black;
cursor: default;
font-size: 2em;
line-height: 2.5em;
border-radius: 50%;
}
.pie-wrapper .shadow {
width: 100%;
height: 100%;
border: 20px solid #bdc3c7;
border-radius: 50%;
}
.pie-wrapper.progress-full .pie {
clip: inherit;
}
.pie-wrapper.progress-full .pie .right-side {
display: block;
-webkit-transform: rotate(220deg);
-moz-transform: rotate(220deg);
transform: rotate(220deg);
}
div,
div:before,
div:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
<div class="card radius shadowDepth1">
<div class="card__content card__padding">
<article class="card__article">
<h2>Hello world</h2>
<div class="pie-wrapper progress-full">
<span class="label">2017</span>
<div class="pie">
<div class="left-side half-circle"></div>
<div class="right-side half-circle"></div>
</div>
</div>
<p>Bounjour, tout le monde</p>
</article>
</div>
</div>
.pie-wrapper .label {
margin: auto;
position: absolute;
top: 30%;
right: auto;
left: 2px;
width: 180px;
height: 180px;
color: black;
cursor: default;
font-size: 2em;
line-height: 2.5em;
border-radius: 50%;
}
.card {
background-color: #fff;
/* margin-bottom: 1.6rem; */
text-align:center;
}
/**
* Card Styles
*/
.card {
background-color: #fff;
/* margin-bottom: 1.6rem; */
text-align:center;
}
.card__padding {
padding: 1.2rem;
}
.card__content {
position: relative;
}
/* card article */
.card__article a {
text-decoration: none;
color: black;
}
.card__article p {
text-align: center;
text-decoration: none;
color: black;
}
/*radial progress bar*/
.pie-wrapper {
display: inline-block;
position: relative;
width: 200px;
height: 200px;
margin-left: 50%;
border: 10px solid #ddd;
border-radius: 50%;
margin: 0 auto;
}
.pie-wrapper .pie {
clip: rect(0, 200px, 200px, 0px);
height: 200px;
width: 200px;
margin: -10px 0 0 -10px;
}
.pie-wrapper .pie .half-circle {
border: 10px solid #3498db;
clip: rect(0, 100px, 200px, 0);
height: 200px;
position: absolute;
width: 200px;
border-radius: 50%;
}
.pie-wrapper .label {
margin: auto;
position: absolute;
top: 30%;
right: auto;
left: 2px;
width: 180px;
height: 180px;
color: black;
cursor: default;
font-size: 2em;
line-height: 2.5em;
border-radius: 50%;
}
.pie-wrapper .shadow {
width: 100%;
height: 100%;
border: 20px solid #bdc3c7;
border-radius: 50%;
}
.pie-wrapper.progress-full .pie {
clip: inherit;
}
.pie-wrapper.progress-full .pie .right-side {
display: block;
-webkit-transform: rotate(220deg);
-moz-transform: rotate(220deg);
transform: rotate(220deg);
}
div,
div:before,
div:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
<div class="card radius shadowDepth1">
<div class="card__content card__padding">
<article class="card__article">
<h2>Hello world</h2>
<div class="pie-wrapper progress-full">
<span class="label">2017</span>
<div class="pie">
<div class="left-side half-circle"></div>
<div class="right-side half-circle"></div>
</div>
</div>
<p>Bounjour, tout le monde</p>
</article>
</div>
</div>
My solution involves the below CSS changes.
.card__article{
text-align:center;
}
.pie-wrapper {
display: inline-block;
position: relative;
width: 200px;
height: 200px;
margin-left: 50%;
border: 10px solid #ddd;
border-radius: 50%;
margin: 0 auto;
text-align:center;
}
.pie-wrapper .label {
position: absolute;
top:0px;
bottom:0px;
left:0px;
right:0px;
color: black;
cursor: default;
font-size: 2em;
line-height: 180px;
border-radius: 50%;
}
First you can just set text-align:center to center the contents. Second I positioned the text inside using position:absolute and made it take the full dimensions of the parent, by setting top,right,bottom,left to 0px, then by setting the CSS property line-height to the inner height of the parent (excluding borders) 180px we can center the contents!
/**
* Card Styles
*/
.card {
background-color: #fff;
/* margin-bottom: 1.6rem; */
}
.card__padding {
padding: 1.2rem;
}
.card__content {
position: relative;
}
/* card article */
.card__article{
text-align:center;
}
.card__article a {
text-decoration: none;
color: black;
}
.card__article p {
text-align: center;
text-decoration: none;
color: black;
}
/*radial progress bar*/
.pie-wrapper {
display: inline-block;
position: relative;
width: 200px;
height: 200px;
margin-left: 50%;
border: 10px solid #ddd;
border-radius: 50%;
margin: 0 auto;
text-align:center;
}
.pie-wrapper .pie {
clip: rect(0, 200px, 200px, 0px);
height: 200px;
width: 200px;
margin: -10px 0 0 -10px;
}
.pie-wrapper .pie .half-circle {
border: 10px solid #3498db;
clip: rect(0, 100px, 200px, 0);
height: 200px;
position: absolute;
width: 200px;
border-radius: 50%;
}
.pie-wrapper .label {
position: absolute;
top:0px;
bottom:0px;
left:0px;
right:0px;
color: black;
cursor: default;
font-size: 2em;
line-height: 180px;
border-radius: 50%;
}
.pie-wrapper .shadow {
width: 100%;
height: 100%;
border: 20px solid #bdc3c7;
border-radius: 50%;
}
.pie-wrapper.progress-full .pie {
clip: inherit;
}
.pie-wrapper.progress-full .pie .right-side {
display: block;
-webkit-transform: rotate(220deg);
-moz-transform: rotate(220deg);
transform: rotate(220deg);
}
div,
div:before,
div:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
<div class="card radius shadowDepth1">
<div class="card__content card__padding">
<article class="card__article">
<h2>Hello world</h2>
<div class="pie-wrapper progress-full">
<span class="label">2017</span>
<div class="pie">
<div class="left-side half-circle"></div>
<div class="right-side half-circle"></div>
</div>
</div>
<p>Bounjour, tout le monde</p>
</article>
</div>
</div>