As you can see the steps in image are not centered well. May be someone has some suggestions how to center it properly ?
CSS:
.stepwizard-step p {
margin-top: 10px;
}
.stepwizard-row {
display: table-row;
}
.stepwizard {
display: table;
width: 100%;
position: relative;
}
.stepwizard-step button[disabled] {
opacity: 1 !important;
filter: alpha(opacity=100) !important;
}
.stepwizard-row:before {
top: 14px;
bottom: 0;
position: absolute;
content: " ";
width: 100%;
height: 1px;
background-color: #ccc;
z-order: 0;
}
.stepwizard-step {
display: table-cell;
text-align: center;
position: relative;
/*width: 70px*/
}
HTML:
<div class="stepwizard">
<div class="stepwizard-row">
<div class="stepwizard-step">
<button type="button" class="btn btn-default">1</button>
<p>Uploading</p>
</div>
<div class="stepwizard-step">
<button type="button" class="btn btn-default">2</button>
<p>Parsing</p>
</div>
<div class="stepwizard-step">
<button type="button" class="btn btn-default">3</button>
<p>Downloading</p>
</div>
<div class="stepwizard-step">
<button type="button" class="btn btn-default">4</button>
<p>Showing</p>
</div>
</div>
</div>
FIDDLE
I'm assuming you're talking about the horizontal distance between the steps not being of equal size. This is due to the text of the step, e.g. Uploading, being part of the table cell. The width of the table is distributed to the table cells based on the width of their contents, a cell with more text will therefore become wider than one with less text.
The easiest way to solve this might be to take the text of the step outside of the document flow by giving it a position: absolute, width: 100% and text-align: center.
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css');
.stepwizard-step p {
margin-top: 10px;
}
.stepwizard-row {
display: table-row;
}
.stepwizard {
display: table;
width: 100%;
position: relative;
}
.stepwizard-step button[disabled] {
opacity: 1 !important;
filter: alpha(opacity=100) !important;
}
.stepwizard-row:before {
top: 14px;
bottom: 0;
position: absolute;
content: " ";
width: 100%;
height: 1px;
background-color: #ccc;
z-order: 0;
}
.stepwizard-step {
display: table-cell;
text-align: center;
position: relative;
/*width: 70px*/
}
.stepwizard-step p {
position: absolute;
width: 100%;
text-align: center;
}
<div class="stepwizard">
<div class="stepwizard-row">
<div class="stepwizard-step">
<button type="button" class="btn btn-default">1</button>
<p>Uploading</p>
</div>
<div class="stepwizard-step">
<button type="button" class="btn btn-default">2</button>
<p>Parsing</p>
</div>
<div class="stepwizard-step">
<button type="button" class="btn btn-default">3</button>
<p>Downloading</p>
</div>
<div class="stepwizard-step">
<button type="button" class="btn btn-default">4</button>
<p>Showing</p>
</div>
</div>
</div>
go by this code it may work out
html
<div class="stepwizard">
<div class="stepwizard-row row">
<div class="stepwizard-step col-md-3">
<button type="button" class="btn btn-default">1</button>
<p>Uploading</p>
</div>
<div class="stepwizard-step col-md-3">
<button type="button" class="btn btn-default">2</button>
<p>Parsing</p>
</div>
<div class="stepwizard-step col-md-3">
<button type="button" class="btn btn-default">3</button>
<p>Downloading</p>
</div>
<div class="stepwizard-step col-md-3">
<button type="button" class="btn btn-default">4</button>
<p>Showing</p>
</div>
</div>
</div>
css code
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css');
.stepwizard-step p {
margin-top: 10px;
}
.stepwizard {
width: 100%;
position: relative;
}
.stepwizard-step button[disabled] {
opacity: 1 !important;
filter: alpha(opacity=100) !important;
}
.stepwizard-row:before {
top: 14px;
bottom: 0;
position: absolute;
content: " ";
width: 100%;
height: 1px;
background-color: #ccc;
z-order: 0;
}
.stepwizard-step {
text-align: center;
position: relative;
/*width: 70px*/
}
jsfiddle
change only stepwizard-row:before top 14px to 18px it's center vertically.
Related
I'm trying to align several div containers with several other divs, but am having a problem.
I can't get the red (checkbox-container) divs to align next to the grey (button-container) divs.
Here's what it looks like now (I think the button being cut off at the bottom is just an issue with setting the developer options to view as mobile when I took a screenshot, because it looks alright in codepen).
And this is how I'm trying to make it look.
Could anyone help me out? I was thinking that I could have each checkbox as a child element of the button container, and then position it relative to that. The problem with that method is I want to ensure that when the screen is resized, the red checkbox-container divs don't overlap with anything in the green character-container div. So I figured having a separate div would be the best way to keep everything where it needs to be when the screen is resized, unless I'm mistaken?
Here's a codepen with the full code:
https://codepen.io/TheNomadicAspie/pen/NWjKwxE
And here's the relevant css:
.bottom-container {
position: absolute;
height: 31.8%;
width: 100vw;
background-color: green;
bottom: 0%;
}
.checkbox-grid {
float: right;
background-color: blue;
width: 7.45vh;
height: 100%;
}
.checkbox-container {
background-color: red;
width: 88%;
height: 22.5%;
top: -0.5vh;
margin-top: 0.5vh;
}
.buttons-grid {
float: right;
background-color: pink;
width: 38.2%;
right: 0%;
}
.button-container {
background-color: purple;
width: 88%;
height: 90%;
right: 0%;
margin-top: 0.5vh;
}
.buttons-grid button {
position: relative;
display: block;
background: grey;
height: 7.45vh;
width: 100%;
top: -0.5vh;
right: 0;
text-align: center;
}
And the HTML:
<div id="menu_bar" , class="menu-bar">
<div id="logo", class="logo">
</div>
<div id="title", class="title">Title</div>
<div id="menu", class="menu">
</div>
</div>
<div id="display" , class="display">
<div id="speech_bubble" , class="speech-bubble">
<div id="email_container" class="email-container">
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email">
<button id="submit_email_btn" class="buttons">Submit</button>
</div>
<div id="question_text" class="question-text">Question</div>
</div>
</div>
</div>
<div id="bottom_container" , class="bottom-container">
<div id="buttons_grid" , class="buttons-grid">
<div id="button_1_container" , class="button-container">
<button>Button 1</button>
</div>
<div id="button_2_container" , class="button-container">
<button>Button 2</button>
</div>
<div id="button_3_container" , class="button-container">
<button>Button 3</button>
</div>
<div id="button_4_container" , class="button-container">
<button>Button 4</button>
</div>
</div>
<div id="checkbox_grid" , class="checkbox-grid">
<div id="checkbox_1_container" , class="checkbox-container">
</div>
<div id="checkbox_2_container" , class="checkbox-container">
</div>
<div id="checkbox_3_container" , class="checkbox-container">
</div>
<div id="checkbox_4_container" , class="checkbox-container">
</div>
</div>
<div id="character_container" , class="character-container"></div>
</div>
</div>
I was able to get it working. I aligned checkbox-grid to the top of bottom-container, then added a margin-bottom to each checkbox-container until the spacing was correct, and added a margin-right to checkbox-grid to add spacing. Looks perfect now.
.bottom-container {
position: absolute;
height: 31.8%;
width: 100vw;
background-color: green;
bottom: 0%;
}
.checkbox-grid {
display: absolute;
float: right;
background-color: blue;
width: 7.45vh;
height: 100%;
margin-right: 1vh;
}
.checkbox-container {
background-color: red;
width: 100%;
height: 22.5%;
margin-bottom: 0.8vh;
}
.buttons-grid {
float: right;
background-color: pink;
width: 38.2%;
right: 0%;
}
.button-container {
background-color: purple;
width: 88%;
height: 90%;
right: 0%;
margin-top: 0.5vh;
}
.buttons-grid button {
position: relative;
display: block;
background: grey;
height: 7.45vh;
width: 100%;
top: -0.5vh;
right: 0;
text-align: center;
}
<div class="input-fields">
<div class="new">
<div class="first-container">
<form id="new-form" method="POST">
<div class="label">
<span class="fas fa-envelope icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div class="label">
<span class="far fa-id-card icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div class="label">
<span class="fas fa-user-tag icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div>
</div>
</div>
</div>
<div>
<span class="divide">or</span>
</div>
<div class="login-field">
<div class="second-container">
<div class="label">
<span class="far fa-id-card icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div class="label">
<span class="fas fa-key icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div>
</div>
</div>
.fa-arrows-alt-h {
font-size: 30px;
color: #bbb;
}
.input-fields {
display: flex;
background: #F7F9F6;
}
.new {
width: 50%;
float: right;
border-right: 1px dashed #e9e9e9;
}
.form-input {
padding-left: 3.575rem;
height: calc(2.25rem + 2px);
font-size: 1.5rem;
}
.first-container {
display: inline-block;
float: right;
padding-right: 30px;
}
.second-container {
display: inline-block;
padding-left: 30px;
}
.divide {
position: absolute;
left: 0;
right: 0;
margin-left:auto;
margin-right:auto;
top: 20%;
}
I would like to align text, "or" in the middle of the vertical line.
I used left: 50% or 49%, however, it's broken when I shrink the window size for response test.
I couldn't use 'left:0; right: 0; because I did not know the width of text("or")
How can I align the word "or" in the middle of the vertical line?
Can anyone help, please?
Many thanks! :)
To your absolutely positioned span add these styles:
.divide{
left: 50%;
transform: translate(-50%);
}
It works see the codepen here: https://codepen.io/arnavozil/pen/mdVyWGr
The problem you had is that u're using flexbox and at the same time you're giving the containers specific width , instead you can use justify-content : center
.fa-arrows-alt-h {
font-size: 30px;
color: #bbb;
}
.input-fields {
justify-content: center;
display: flex;
display: flex;
background: #F7F9F6;
}
.new {
/* width: 50%; */
/* float: right; */
border-right: 1px dashed #e9e9e9;
}
.form-input {
padding-left: 3.575rem;
height: calc(2.25rem + 2px);
font-size: 1.5rem;
}
.first-container {
/* display: inline-block; */
/* float: right; */
padding-right: 30px;
}
.second-container {
/* display: inline-block; */
padding-left: 30px;
}
.divide {
/* position: absolute; */
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
/* top: 20%; */
} ```
The screenshot below includes a Power BI report (the entire box) and some buttons that will be used to navigate it. The Power BI report has to have an exact height/width (1600X800), but I want the buttons to align just beneath it, regardless of screen resolution.
Full markup: https://plnkr.co/edit/B6iDWud66SKx15ctYL3o?p=info
<div style="width:100%; float: left; height:96%;">
<div id="reportContainer" style="height: 800px; width: 1600px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"> </div>
<div style="position: absolute; top: 85%; left: 50%;">
<button class="button-secondary" onclick="pageChange()">Test button</button>
<button class="button-secondary" onclick="pageChange()">Test button 2</button>
</div>
</div>
You can wrap the report and buttons into a container, e.g. main-container. Then apply flexbox to achieve your goal.
<div style="width:100%; float: left; height:96%;">
<div class="main-container" style="
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;">
<div id="reportContainer" style="height: 400px;width: 800px; background: red;">Hi, I'm 400x800. I'm always centered and the buttons are right below me!</div>
<div style="margin-top: 20px;">
<button class="button-secondary" onclick="pageChange()">Test button</button>
<button class="button-secondary" onclick="pageChange()">Test button 2</button>
</div>
</div>
</div>
Note: I modified the dimension to 400x800 (intead of 800x1600) for render purposes.
If you must use position: absolute for the reportContainer, then do it on a shared parent container and place the buttons below the container with bottom: -20px.
#mainContainer {
width: 100%;
float: left;
height: 96%;
}
#subContainer {
height: 800px;
width: 1600px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: red;
}
#buttonContainer {
position: absolute;
bottom: -20px;
left: 50%;
}
<div id="mainContainer">
<div id="subContainer">
<div id="reportContainer"></div>
<div id="buttonContainer">
<button class="button-secondary" onclick="pageChange()">Test button</button>
<button class="button-secondary" onclick="pageChange()">Test button 2</button>
</div>
</div>
</div>
You can achieve this most simply, by applying to the <body>
display: flex
flex-wrap: wrap
justify-content: center
If you then add to #reportContainer
flex: 0 0 1600px
you will ensure that #reportContainer maintains an inflexible width of 1600px, with zero capacity to either grow or shrink.
Working Example:
body {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
#reportContainer {
flex: 0 0 1600px;
height: 800px;
background-color: orange;
}
.button-secondary {
margin: 12px;
}
<div id="reportContainer"></div>
<button class="button-secondary">Test button</button>
<button class="button-secondary">Test button 2</button>
To align your buttons always in center, you can use something like this.
.buttons {
text-align: center;
}
<div class="buttons">
<button class="button-secondary">Test button</button>
<button class="button-secondary">Test button 2</button>
</div>
What I am trying to do is when the max width of a screen is 750px I want the buttons inside of my side-bar to be centered both vertically and horizontally using flexbox. Here is what I have tried:
.side-bar {
height: calc(100vh - 55px);
width: 18.5%;
background-color: #F5F5F5;
overflow: auto;
}
.side-bar .content {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
padding-top: 30px;
box-sizing: border-box;
}
.side-bar .button {
margin-bottom: 5px;
}
.side-bar .button:hover i {
color: dodgerblue;
}
.side-bar .button div {
text-align: left;
}
.side-bar .button form {
display: flex;
}
.side-bar .button a {
align-self: center;
margin-left: 12%;
margin-right: 5%;
}
.side-bar .button a i {
color: black;
font-size: 18px;
transition: 0.3s;
}
.side-bar .button input {
border: none;
font-size: 15px;
background-color: Transparent;
}
.side-bar .button input:active {
color: black;
}
.side-bar .sub-title {
margin-left: 12%;
}
.side-bar .sub-title p {
color: #6C6C6D;
font-weight: bold;
font-size: 14px;
}
#media (max-width: 750px) {
.side-bar .content {
justify-content: center;
}
.side-bar .button input {
display: none;
}
.side-bar .sub-title {
display: none;
}
}
<div class="side-bar">
<div class="content">
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-tachometer-alt"></i>
<input type="submit" value="Dashboard">
</form>
</div>
</div>
<div class="sub-title">
<p>TOOLS</p>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-minus-circle"></i>
<input type="submit" value="Ban Panel">
</form>
</div>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-exclamation-circle"></i>
<input type="submit" value="Warn Panel">
</form>
</div>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-gift"></i>
<input type="submit" value="Gift Panel">
</form>
</div>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-user"></i>
<input type="submit" value="User Info">
</form>
</div>
</div>
<div class="sub-title">
<p>NEWS</p>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-newspaper"></i>
<input type="submit" value="News Panel">
</form>
</div>
</div>
</div>
</div>
When when I use justify-content on my content div the children of the content div aren't centered. I would like the buttons centered both vertically and horizontally.
Note on potential duplicates
Before anyone marks this a duplicate, it's not. I looked at the solutions to my last post about it being a duplicate for the same reason and it's not.
How my post is different from my previous post: My previous post I was trying to center a div inside a div, that didn't work out so I tried a different approach and got my result that I wanted. Now, I am trying to center my div inside three other divs but do not understand what it is not centering after using flexbox to center it.
I believe below solution fixes your issue. Content was a little off to the bottom, because .content had only padding-top: 30px, which I changed to padding: 30px 0. I also removed display: none rules, because then, well, nothing was inside this sidebar.
Key part
.side-bar .content {
...
padding: 30px 0;
...
}
Snippet
.side-bar {
height: calc(100vh - 55px);
width: 18.5%;
background-color: #F5F5F5;
overflow: auto;
}
.side-bar .content {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
padding: 30px 0;
box-sizing: border-box;
}
.side-bar .button {
margin-bottom: 5px;
}
.side-bar .button:hover i {
color: dodgerblue;
}
.side-bar .button div {
text-align: left;
}
.side-bar .button form {
display: flex;
}
.side-bar .button a {
align-self: center;
margin-left: 12%;
margin-right: 5%;
}
.side-bar .button a i {
color: black;
font-size: 18px;
transition: 0.3s;
}
.side-bar .button input {
border: none;
font-size: 15px;
background-color: Transparent;
}
.side-bar .button input:active {
color: black;
}
.side-bar .sub-title {
margin-left: 12%;
}
.side-bar .sub-title p {
color: #6C6C6D;
font-weight: bold;
font-size: 14px;
}
#media (max-width: 750px) {
.side-bar .content {
justify-content: center;
}
.side-bar .button input
}
.side-bar .sub-title {
}
}
<div class="side-bar">
<div class="content">
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-tachometer-alt"></i>
<input type="submit" value="Dashboard">
</form>
</div>
</div>
<div class="sub-title">
<p>TOOLS</p>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-minus-circle"></i>
<input type="submit" value="Ban Panel">
</form>
</div>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-exclamation-circle"></i>
<input type="submit" value="Warn Panel">
</form>
</div>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-gift"></i>
<input type="submit" value="Gift Panel">
</form>
</div>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-user"></i>
<input type="submit" value="User Info">
</form>
</div>
</div>
<div class="sub-title">
<p>NEWS</p>
</div>
<div class="button">
<div>
<form action="http://google.com">
<i class="fas fa-newspaper"></i>
<input type="submit" value="News Panel">
</form>
</div>
</div>
</div>
</div>
I have it where the blue element row overlaps. But for some reason, the bottom div text foo is being pushed still be the flow. Why is this? I expect foo to be on the left and not effected by the flow because of z-index.
.goal-container {
width: 900px;
}
.progress-column {
display: inline-block;
float: left;
margin-top: 10px;
}
.goal-upper-well {
display: inline-block;
float: left;
background-color: #purple-blue;
width: 500px;
position: relative;
z-index: 2;
}
.goal-lower-well {
height: 300px;
width: 700px;
margin-top: -42px;
position: relative;
z-index: 0;
}
.goal-upper {
height: 43px;
position: relative;
z-index: 2;
}
<div class="goal-container">
<div class="goal-upper">
<div class="well well-sm goal-upper-well">
<button type="button" class="btn-small expand-button"
ng-click="isNavCollapsed = !isNavCollapsed"
aria-label="Left Align">
<span class="glyphicon glyphicon-plus"></span>
</button>
Goal: {{goal.desc}}
</div>
<div class="progress-column">
BARRRRRRRRRRR
</div>
</div>
<div class="goal-lower-well">
<div class="well well-lg goal-lower-well">foo</div>
</div>
</div>
This is because you have a negative top margin on your foo text. Just remove it and the foo text will go to the next line on the left.
.goal-lower-well {
height: 300px;
width: 700px;
/* margin-top: -42px; */ Remove it
position: relative;
z-index: 0;
}
You ned to clear the next 2 divs from floating
.goal-container {
width: 900px;
}
.progress-column {
display: inline-block;
clear: left;
float: left;
margin-top: 10px;
}
.goal-upper-well {
display: inline-block;
float: left;
background-color: #purple-blue;
width: 500px;
position: relative;
z-index: 2;
}
.goal-lower-well {
clear: left;
height: 300px;
width: 700px;
margin-top: -42px;
position: relative;
z-index: 0;
}
.goal-upper {
height: 43px;
position: relative;
z-index: 2;
}
<div class="goal-container">
<div class="goal-upper">
<div class="well well-sm goal-upper-well">
<button type="button" class="btn-small expand-button"
ng-click="isNavCollapsed = !isNavCollapsed"
aria-label="Left Align">
<span class="glyphicon glyphicon-plus"></span>
</button>
Goal: {{goal.desc}}
</div>
<div class="progress-column">
BARRRRRRRRRRR
</div>
</div>
<div class="goal-lower-well">
<div class="well well-lg goal-lower-well">foo</div>
</div>
</div>