Reputation: 171
How can I make the below horizontal lines to vertical lines like below image
Below is the code for vertical lines with connecting dots which I have tried:
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Open Sans";
}
/* Form Progress */
.progress {
margin: 20px auto;
text-align: center;
padding-bottom: 80px;
}
.progress .circle,
.progress .bar {
display: inline-block;
background: #fff;
width: 40px;
height: 40px;
border-radius: 40px;
border: 1px solid #d5d5da;
vertical-align:top;
}
.progress .bar {
position: relative;
width: 80px;
height: 6px;
margin: 0 -5px 17px -5px;
border-left: none;
border-right: none;
border-radius: 0;
top:16px;
vertical-align:top
}
.progress .circle .label {
display: inline-block;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 32px;
margin-top: 3px;
color: #b5b5ba;
font-size: 17px;
}
.progress .circle .title {
color: #b5b5ba;
font-size: 13px;
line-height: 18px;
margin-left: -30px;
display: block;
width: 100px;
margin-top: 5px;
}
/* Done / Active */
.progress .bar.done,
.progress .circle.done {
background: #eee;
}
.progress .bar.active {
background: linear-gradient(to right, #EEE 40%, #FFF 60%);
}
.progress .circle.done .label {
color: #FFF;
background: #8bc435;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.done .title {
color: #444;
}
.progress .circle.active .label {
color: #FFF;
background: #0c95be;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.active .title {
color: #0c95be;
}
<div class="progress">
<div class="circle done"> <span class="label">1</span>
<span class="title">Order</span>
</div> <span class="bar done"></span>
<div class="circle done"> <span class="label">2</span>
<span class="title">Address</span>
</div> <span class="bar active"></span>
<div class="circle active"> <span class="label">3</span>
<span class="title">Payment</span>
</div>
</div>
Upvotes: 4
Views: 2768
Reputation: 4659
Use display:inline-block
instead of display:block
.progress .circle,
.progress .bar {
display: block;
}
And interchanged width
and height
of progress bar
.progress .bar {
position: relative;
width: 6px; // already given 80px in question
height: 80px; // already given 6px in question
}
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Open Sans";
}
/* Form Progress */
.progress {
margin: 20px auto;
text-align: center;
padding-left: 80px;
}
.progress .circle,
.progress .bar {
display: block;
background: #fff;
width: 40px;
height: 40px;
border-radius: 40px;
border: 1px solid #d5d5da;
vertical-align:top;
}
.progress .bar {
position: relative;
width: 6px;
height: 80px;
margin: 0 0px 0px 16px;
border-radius: 0;
top:0;
vertical-align:top;
left:0;
}
.progress .circle .label {
display: inline-block;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 32px;
margin-top: 3px;
color: #b5b5ba;
font-size: 17px;
}
.progress .circle .title {
color: #b5b5ba;
font-size: 13px;
line-height: 18px;
padding-left: 55px;
display: block;
width: calc(100vw - 130px);
margin-top: -25px;
text-align:left;
}
/* Done / Active */
.progress .bar.done,
.progress .circle.done {
background: #eee;
}
.progress .bar.active {
background: linear-gradient(to right, #EEE 40%, #FFF 60%);
}
.progress .circle.done .label {
color: #FFF;
background: #8bc435;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.done .title {
color: #444;
}
.progress .circle.active .label {
color: #FFF;
background: #0c95be;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.active .title {
color: #0c95be;
}
<div class="progress">
<div class="circle done"> <span class="label">1</span>
<span class="title">When the text characters are more the alignment changes and not overlaps with circle and bar </span>
</div> <span class="bar done"></span>
<div class="circle done"> <span class="label">2</span>
<span class="title">Address</span>
</div> <span class="bar active"></span>
<div class="circle active"> <span class="label">3</span>
<span class="title">Payment</span>
</div>
</div>
Upvotes: 2
Reputation: 819
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Open Sans";
}
/* Form Progress */
body{
display: flex;
justify-content: center;
}
.progress {
display: flex;
flex-direction: column;
justify-content: center;
margin: 20px auto;
text-align: center;
padding-bottom: 80px;
}
.progress .circle{
position: relative;
z-index: 2;
}
.progress .circle,
.progress .bar {
display: inline-block;
background: #fff;
width: 40px;
height: 40px;
border-radius: 40px;
border: 1px solid #d5d5da;
vertical-align:top;
}
.progress .bar {
transform: rotate(90deg);
position: relative;
width: 80px;
height: 6px;
margin: 0 -5px 17px -20px;
border-left: none;
border-right: none;
border-radius: 0;
top:16px;
vertical-align:top
}
.progress .circle .label {
display: inline-block;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 32px;
margin-top: 3px;
color: #b5b5ba;
font-size: 17px;
}
.progress .circle .title {
color: #b5b5ba;
font-size: 13px;
line-height: 18px;
margin-left: -30px;
display: block;
width: 100px;
margin-top: 5px;
position: absolute;
top: 0;
right: -80px;
}
/* Done / Active */
.progress .bar.done,
.progress .circle.done {
background: #eee;
}
.progress .bar.active {
background: linear-gradient(to right, #EEE 40%, #FFF 60%);
}
.progress .circle.done .label {
color: #FFF;
background: #8bc435;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.done .title {
color: #444;
}
.progress .circle.active .label {
color: #FFF;
background: #0c95be;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.active .title {
color: #0c95be;
}
<div class="progress">
<div class="circle done"> <span class="label">1</span>
<span class="title">Order</span>
</div> <span class="bar done"></span>
<div class="circle done"> <span class="label">2</span>
<span class="title">Address</span>
</div> <span class="bar active"></span>
<div class="circle active"> <span class="label">3</span>
<span class="title">Payment</span>
</div>
</div>
Upvotes: 1
Reputation: 15213
Was it necessary? In css, I marked my changes.
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Open Sans";
}
/* Form Progress */
/*add*/
.label_box {
display: inline-flex;
align-items: center;
}
/*--------------*/
.progress {
margin: 20px auto;
text-align: center;
padding-bottom: 80px;
display: flex; /*add*/
flex-direction: column; /*add*/
align-items: center; /*add*/
justify-content: space-between; /*add*/
height: 355px;
}
.progress .circle,
.progress .bar {
display: inline-block;
background: #fff;
width: 40px;
height: 40px;
border-radius: 40px;
border: 1px solid #d5d5da;
vertical-align:top;
}
.progress .bar {
position: relative;
width: 80px;
height: 6px;
/*margin: 0 -5px 17px -5px;*/ /*remove*/
border-left: none;
border-right: none;
border-radius: 0;
/*top:16px;*/ /*remove*/
vertical-align:top; /*add*/
transform: rotate(90deg); /*add*/
}
.progress .circle .label {
display: inline-block;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 32px;
margin-top: 3px;
margin-left: 3px; /*add*/
color: #b5b5ba;
font-size: 17px;
}
.progress .circle .title {
color: #b5b5ba;
font-size: 13px;
line-height: 18px;
/*margin-left: -30px;*/ /*remove*/
display: block;
width: 100px;
/*margin-top: 5px;*/ /*remove*/
margin-left: 10px; /*add*/
text-align: start; /*add*/
}
/* Done / Active */
.progress .bar.done,
.progress .circle.done {
background: #eee;
}
.progress .bar.active {
background: linear-gradient(to right, #EEE 40%, #FFF 60%);
}
.progress .circle.done .label {
color: #FFF;
background: #8bc435;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.done .title {
color: #444;
}
.progress .circle.active .label {
color: #FFF;
background: #0c95be;
box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
}
.progress .circle.active .title {
color: #0c95be;
}
<div class="progress">
<div class="circle done">
<div class="label_box">
<span class="label">1</span>
<span class="title">Order</span>
</div>
</div> <span class="bar done"></span>
<div class="circle done">
<div class="label_box">
<span class="label">2</span>
<span class="title">Address</span>
</div>
</div> <span class="bar active"></span>
<div class="circle active">
<div class="label_box">
<span class="label">3</span>
<span class="title">Payment</span>
</div>
</div>
</div>
Upvotes: 2
Reputation: 1848
you can use pseudo class to make the stick and use position to center it
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
<style>
.dots::before {
content: "";
position: absolute;
height: 2rem;
border-left: 1px solid #000;
top: 100%;
left: 50%;
transform: translateX(-50%);
}
</style>
<link
href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
rel="stylesheet"
/>
</head>
<body>
<div class="flex flex-col">
<div class="flex items-center my-3">
<span class="dots relative w-5 h-5 rounded-full bg-gray-500"></span>
<p class="ml-2">Hello world</p>
</div>
<div class="flex items-center my-3">
<span class="dots relative w-5 h-5 rounded-full bg-gray-500"></span>
<p class="ml-2">Hello world</p>
</div>
<div class="flex items-center my-3">
<span class="dots relative w-5 h-5 rounded-full bg-gray-500"></span>
<p class="ml-2">Hello world</p>
</div>
<div class="flex items-center my-3">
<span class="dots relative w-5 h-5 rounded-full bg-gray-500"></span>
<p class="ml-2">Hello world</p>
</div>
<div class="flex items-center my-3">
<span class="dots relative w-5 h-5 rounded-full bg-gray-500"></span>
<p class="ml-2">Hello world</p>
</div>
<div class="flex items-center my-3">
<span class="dots relative w-5 h-5 rounded-full bg-gray-500"></span>
<p class="ml-2">Hello world</p>
</div>
</div>
</body>
</html>
Upvotes: 0