Alignment issue while creating vertical stepper html css - html

I am creating a simple vertical stepper component with html & css. And trying to design like this. I strucked in the css part some alignment issues are coming.
CSS
.steps-container .step::before {
display: inline-block;
content: "";
font-size: 10px;
color: #fff;
text-align: center;
background-color: #e1e1e1;
width: 20px;
height: 20px;
border-radius: 50%;
position: relative;
right: 4px;
top: 2px;
}
.steps-container .step.active::before {
background-color: green;
}
.step-vertical {
border-left: 1px solid #e1e1e1;
margin-bottom: 5px;
margin-left: 5px;
}
HTML
<div>
<div class="steps-container">
<span class="step inactive">1</span>
<div class="step-vertical">
<div>
<h5 class="text-grey">label text 1</h5>
<button>Continue</button>
</div>
</div>
</div>
<div class="steps-container">
<span class="step active">2</span>
<div class="step-vertical">
<div>
<h5 class="text-grey">label text 2</h5>
<button>Continue</button>
</div>
</div>
</div>
</div>
.
From the output i want the numbers 1 and 2 inside the circle and label text should align next to the circle. I don't know how to achieve this. Ur suggestions are helpful.

Is this how you want it? added the :before css to span added display: inline-block; to .step-vertical to bring it next to the span.
.steps-container .step {
display: inline-block;
content: "";
font-size: 10px;
color: #fff;
text-align: center;
background-color: #e1e1e1;
/* width: 20px; */
/* height: 20px; */
border-radius: 50%;
position: relative;
right: 4px;
top: 2px;
padding: 5px 10px;
color: black;
vertical-align: top;
}
.steps-container .step.active::before {
background-color: green;
}
.step-vertical {
border-left: 1px solid #e1e1e1;
margin-bottom: 5px;
margin-left: 5px;
height:200px
}
h5{margin-top: 5px;
display: inline-block;}
button{
display:block
}
.ml-2{
margin-left:10px
}
<div>
<div class="steps-container">
<span class="step inactive">1</span>
<h5 class="text-grey">label text 1</h5>
<div class="step-vertical">
<div>
<textarea class="ml-2" name="" id="" cols="30" rows="10">
</textarea>
<button class="ml-2">Continue</button>
</div>
</div>
</div>
<div class="steps-container">
<span class="step inactive">2</span>
<h5 class="text-grey">label text 2</h5>
<div class="step-vertical">
<div>
<textarea class="ml-2" name="" id="" cols="30" rows="10"> </textarea>
<button class="ml-2">Continue</button>
</div>
</div>
</div>
</div>

Related

How to centralize icon inside small bordered element?

Is there a way to centralize text inside a bordered element?
When I do border at the element, maybe because its content size is reduced, it gets decentralized.
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
}
.button-styling {
color: #00b0ff;
font-size: x-large;
}
.outline-h {
outline: thin;
outline-color: blue;
outline-style: solid;
}
<div style="max-width: 15px;">
<h3> With border </h1>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
<div style="max-width: 15px;">
<h3> Without border </h1>
<div class="outline-h">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
You can use flexbox to center the text element:
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
/*Add*/
display: flex;
justify-content: center;
align-items: center;
}
<div style="max-width: 15px;">
<h3>With border</h3>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
You could try this:
.circle {
text-align: center;
line-height: 20px;
}
I was able to center it using display: flex.
Check it's browser support though: https://caniuse.com/#feat=flexbox
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
display: flex;
justify-content: center;
align-items: center;
}
.button-styling {
color: #00b0ff;
font-size: x-large;
}
.outline-h {
outline: thin;
outline-color: blue;
outline-style: solid;
}
<div style="max-width: 15px;">
<h3> With border </h1>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
<div style="max-width: 15px;">
<h3> Without border </h1>
<div class="outline-h">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>

Positioning elements with CSS

I know it is dumb question, but i am struggling with following problem
It is one of my menu buttons. I want div the represents icon (marked red with circle) be on the left side of the button and the text on the right (name (blue) above description (purple)). By the way, i am going to have plenty of those buttons and i want them appear in column (block).
My current problem is that icon div (red) and text div (green dashed) wont place inline.
My HTML is:
<style>
.HomeMenuNavbarButton {
text-decoration: none;
color : black;
border-style:outset;
border-width:4px;
border-radius:15px;
display:block;
padding:4px;
}
.circle {
width: 50px;
height: 50px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
border-color: black;
border-style: dashed;
display: inline-block;
vertical-align: top;
}
</style>
<div class="container">
<div class="row">
#foreach (var node in Model.Nodes)
{
if (!(node.IsRootNode) && node.Children.Any())
{
<div class="col-md-4">
<button type="button" style="display:inline;" class="btn btn-info" data-toggle="collapse" data-target="#("#relatedNavList" + node.Title) ">#node.Title</button>
<div id="#("relatedNavList" + node.Title)" class="collapse">
#foreach (var child in node.Children)
{
<div class="HomeMenuNavbarButton" style="display:block;">
<div style="background-color:red;display:inline">
<div class="circle">
</div>
</div>
<div style="border-color: green; border-style: dashed; display:inline-block">
<div style="background-color:blue">#(child.Title)</div>
<div style="background-color:purple">#(child.Description)</div>
</div>
</div>
}
</div>
</div>
}
}
</div>
</div>
When you want to display stuff side by side in CSS, the easiest way is to use flexbox. Try to add display : flex; to your HomeMenuNavBar class.
Here is a complete document about flexbox from the Mozilla team.
Using a wrapper defined as a flexbox
.wrapper {
display: flex;
align-items: center;
justify-content: space-between;
width: 150px;
}
.circle {
height: 25px;
width: 25px;
border: medium dashed darkgray;
border-radius: 50%;
}
button {
background: dodgerblue;
color: white;
border-radius: 3px;
border: thin solid lightblue;
padding: 0.5em;
}
<div class="wrapper">
<button>Button</button>
<div class="circle"></div>
<span>Text</span>
</div>
You can do that just with display:inline-block on your button's elements
.elementButton
{
display:inline-block;
}
.circle {
width: 50px;
height: 50px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
border-color: black;
border-style: dashed;
display: inline-block;
vertical-align: top;
}
.HomeMenuNavbarButton
{
display:block;
margin:5px;
}
<div class="HomeMenuNavbarButton">
<div class="circle elementButton">
</div>
<div class="elementButton">
<div>Title one</div>
<div>Content</div>
</div>
</div>
<div class="HomeMenuNavbarButton">
<div class="circle elementButton">
</div>
<div class="elementButton">
<div >Title two</div>
<div>Content</div>
</div>
</div>

How to display letters on new line in css

I have four divs which shows a number, I want to display the words below those numbers. I have tried using the p tag with white-space: pre; in css, but still it does not work:
#c {
padding-top: 30px;
padding-bottom: 30px;
}
.cnum {
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin: 5px;
font-size: 20px;
}
p {
white-space: pre;
}
<div id="c">
<span class='cnum'>27 Text1</span><span class='cnum'>10 Text2</span><span class='cnum'>40 Text 3</span><span class='cnum'>5 Text 4</span>
</div>
HTML
<div id="c">
<div class='cnum'>27 <br/>Text1</div>
<div class='cnum'>10 <br/>Text2</div>
<div class='cnum'>40 <br/>Text 3</div>
<div class='cnum'>5 <br/>Text 4</div>
</div>
CSS
#c{
padding-top:30px;
padding-bottom:30px;
}
.cnum{
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin:5px;
font-size:20px;
max-Width :100px;
float :left
}
Heres a CodePen
If you can't edit the HTML, here's a workaround using word-spacing. Obviously this method is very limited...
#c {
padding-top: 30px;
padding-bottom: 30px;
}
.cnum {
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin: 5px;
font-size: 20px;
display: inline-block;
width: 100px;
word-spacing: 100px;
}
<div id="c">
<span class='cnum'>27 Text1</span><span class='cnum'>10 Text2</span><span class='cnum'>40 Text3</span><span class='cnum'>5 Text4</span>
</div>
I just separated the elements according to the hierarchy so that I could then apply the style. If you observe keep the span tags, but you could replace them with a block element.
I recommend you to learn about inline and block HTML elements and how to convert them in each other.
I hope I have contributed.
#c {
padding-top: 30px;
padding-bottom: 30px;
}
.cnum {
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin: 5px;
font-size: 20px;
display: inline-block;
text-align: center;
}
.cnum span{
display: block;
}
p {
white-space: pre;
}
<div id="c">
<div class="cnum">
<span>27</span>
<span>Text 1</span>
</div>
<div class="cnum">
<span>10</span>
<span>Text 2</span>
</div>
<div class="cnum">
<span>40</span>
<span>Text 3</span>
</div>
<div class="cnum">
<span>5</span>
<span>Text 4</span>
</div>
</div>
If you can edit the html you can do the following, additionally using the pseudo selector ::first-line style the numbers differently
#c {
padding-top: 30px;
padding-bottom: 30px;
}
.cnum {
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin: 5px;
font-size: 20px;
}
.cnum::first-line {
font-size: 30px;
color: yellow;
}
<div id="c">
<div class='cnum'>27 <br/>Text1</div>
<div class='cnum'>10 <br/>Text2</div>
<div class='cnum'>40 <br/>Text 3</div>
<div class='cnum'>5 <br/>Text 4</div>
</div>

How to set text in center between parent left and right tag

I have this layout of my web page, here last div tag <div>{this.props.status}</div> is in left end. I want to set it in center between rock and scissors button.
Expected
<div className="AppTitle">
<b>Score: {this.props.score}</b>
<div>
<RoundedButton text="Rock" clickitem={this.clickitem} />
<RoundedButton text="Paper" clickitem={this.clickitem} />
<RoundedButton text="Scissors" clickitem={this.clickitem} />
</div>
<div>{this.props.status}</div>
</div>
App.css
.AppTitle {
margin: 50px;
}
.Button {
padding: 20px;
margin: 20px;
border: 1px solid blue;
border-radius: 10px;
}
What is the way to do it in HTML ?
Try this for css.
.AppTitle {
margin: 50px;
display:inline-block;
}
.button {
padding: 20px;
margin: 20px;
border: 1px solid blue;
border-radius: 10px;
}
.status{text-align:center;}
<div class="AppTitle">
<b>Score: -1</b>
<div>
<Button class="button">Rock</Button>
<Button class="button">Paper</Button>
<Button class="button">Scissors</Button>
</div>
<div class="status">Computer Won</div>
</div>
EDITED
Here added four button & background this one clear.
.AppTitle {
margin: 50px;
display:inline-block;
background:#b5b5b5;
}
.button {
padding: 20px;
margin: 20px;
border: 1px solid blue;
border-radius: 10px;
}
.status{text-align:center;background:#ccc;}
<div class="AppTitle">
<b>Score: -1</b>
<div>
<Button class="button">Rock</Button>
<Button class="button">Paper</Button>
<Button class="button">Scissors</Button>
<Button class="button">Rock</Button>
</div>
<div class="status">Computer Won</div>
UPDATED
Make parent div to center.
.wrapper{text-align:center;}
.AppTitle {
margin:50px;
display:inline-block;
background:#b5b5b5;
text-align:left;
}
.button {
padding: 20px;
margin: 20px;
border: 1px solid blue;
border-radius: 10px;
}
.status{text-align:center;background:#ccc;}
<div class="wrapper">
<div class="AppTitle">
<b>Score: -1</b>
<div>
<Button class="button">Rock</Button>
<Button class="button">Paper</Button>
<Button class="button">Scissors</Button>
</div>
<div class="status">Computer Won</div>
</div>
</div>
If you have a look at .status, you'll find that it is the same width as the previous <div>. To center the text, you'll need to give it the CSS:
.status {
text-align: center;
}
Also, <RoundedButton> is not a HTML tag. Use <button> instead.
.AppTitle {
margin: 50px;
display: inline-block;
}
.button {
padding: 20px;
margin: 20px;
border: 1px solid blue;
border-radius: 10px;
}
.status {
text-align: center;
}
<div class="AppTitle">
<b>Score: -1</b>
<div>
<button class="button">Rock</button>
<button class="button">Paper</button>
<button class="button">Scissors</button>
</div>
<div class="status">Computer Won</div>
</div>
This could also work #Williams
.mainContainer {
width: 500px;
height: 200px;
border: 2px solid black;
background-color: lightgray;
}
.top {
width: 100%;
height: 50px;
background-color: lightgray;
display: table-cell;
vertical-align: middle;
padding-left: 100%;
}
.outputContainer {
width: 100%;
background-color: lightgray;
height: 20px;
}
#score {
margin-top: 50px;
display: inline;
}
.third {
width: 30%;
height: 70px;
background-color: lightgray;
display: inline-block;
}
button {
padding: 20px;
border: 2px solid blue;
border-radius: 10px;
width: 100px;
}
<div class="mainContainer">
<div class="top">
<span id="score"><b> Score: </b></span>
</div>
<center>
<div class="third">
<button type="button"> Rock </button>
</div>
<div class="third">
<button type="button"> Paper </button>
</div>
<div class="third">
<button type="button"> Scissors </button>
</div>
<div class="outputContainer">
<h2> Computer won! </h2>
</div>
</center>
</div>
In order to keep them aligned in most cases and not just as a fix on a certain display, try putting them in one and using display: block, like so
<div className="AppTitle">
<b>Score: {this.props.score}</b>
<div>
<RoundedButton text="Rock" clickitem={this.clickitem} />
<div style="display:block">
<RoundedButton text="Paper" clickitem={this.clickitem} />
<span>{this.props.status}</span>
</div>
<RoundedButton text="Scissors" clickitem={this.clickitem} />
</div>

Wizard reponsiveness issue

I am creating following wizard.
I have tried following; but its not working as it should be. Its layout disturbs while resizing window. It should be responsive. What can be best way to implement it so that it should remain Responsive despite whatever resolution is.
Fiddle with issue
HTML:
<div class="col-md-10">
<div class="wizard-wrapper">
<div class="node-wrapper text-center wactive">
<div class="node"><span>1</span>
</div>
<label class="lbl-wizard">Singn Up</label>
</div>
<div class="node-wrapper text-center">
<div class="node"><span>2</span>
</div>
<label class="lbl-wizard">Order Info</label>
</div>
<div class="node-wrapper text-center">
<div class="node"><span>3</span>
</div>
<label class="lbl-wizard">Preview Info</label>
</div>
<div class="node-wrapper text-center">
<div class="node"><span>4</span>
</div>
<label class="lbl-wizard">Payment Method</label>
</div>
<div class="node-wrapper text-center">
<div class="node"><span>5</span>
</div>
<label class="lbl-wizard">Complete Order Info</label>
</div>
<div class="connection"></div>
</div>
</div>
CSS
/* wizard */
.wizard h2 {
margin-top: 5px;
}
.node {
background: #2d2f32;
border-radius: 30px;
color: #fff;
display: inline-block;
height: 37px;
text-align: center;
width: 37px;
border: 4px solid #C2C6C9;
}
.wactive .node {
background: #AA0405;
}
.node > span {
display: inline-block;
font-size: 14px;
padding-top: 4px;
font-family: open_sansbold;
}
.lbl-wizard {
display: block;
font-family: open_sansregular;
font-size: 14px;
color: #2d2f32;
padding-top: 5px;
}
.node-wrapper.text-center {
float: left;
padding: 0 5%;
position: relative;
z-index: 1;
}
.connection {
background: #c2c6c9;
display: inline-block;
height: 5px;
margin-top: -113px;
padding-top: 7px;
position: relative;
vertical-align: middle;
width: 100%;
z-index: 0;
}
FYI: I am using bootstrap.
You can set the width of a node.wrapper element to one fifth of the resolution width.
width: calc(100% / 5);
Also, you should change .connection so it stays at one position:
.connection {
background: #c2c6c9;
display: block; (new)
height: 5px;
margin-top: 38px; (new)
padding-top: 7px;
position: absolute; (new)
vertical-align: middle;
width: 100%;
z-index: 0;
}
Fiddle