I don't understand why the three different rows are appearing on the same line. Don't rows usually appear on different lines? I even tried setting a fixed height for the rows and/or columns.
Here is the fiddle: https://jsfiddle.net/qvuo4bqw/
<div class="container-fluid">
<div id="bubble">
<div class="row">
<div class="col-md-12">
<h3 id="question">Question Here</h3>
</div>
</div>
<div class="row">
<div class="col-md-12">
<ul class="list-inline">
<li>Disagree</li>
<label class="disagree" id="disagree-btn" val="0"></label>
<label class="disagree" val="0.5"></label>
<label id="neutral" val="1"></label>
<label class="agree" val="2"></label>
<label class="agree" id="agree-btn" val="3"></label>
<li>Agree</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button class="btn btn-warning" id="back-btn">Back</button>
<button class="btn btn-primary" id="next-btn">Next</button>
</div>
</div>
<br><br>
</div>
.container-fluid {
padding-top: 5%;
display: flex;
justify-content: center;
align-items: center;
}
#bubble {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
border-radius: 100%;
height: 800px;
width: 800px;
border-color: black;
border-style: solid;
border-width: 5px;
background: linear-gradient(0deg, #AA3939 0%, #55AA55 0%);
color: white;
}
.row {
height: 150px;
}
ul>label {
width: 50px;
height: 50px;
border-radius: 100%;
border-style: solid;
cursor: pointer;
text-align: center;
}
.agree {
border-color: #226666;
}
.disagree {
border-color: #AA6C39;
}
#disagree-btn, #agree-btn {
height: 60px;
width: 60px;
}
#next-btn, #back-btn {
height: 50px;
width: 100px;
}
#neutral {
height: 40px;
width: 40px;
border-color: gray;
}
I don't understand why the three different rows are appearing on the same line.
Because your elements are in a flex container (#bubble has display: flex).
And two initial settings of a flex container are flex-direction: row and flex-wrap: nowrap, meaning child elements will align horizontally in a single line and not wrap.
If you want the children of #bubble to appear on different rows, here are a few options you can start with:
Switch to flex-direction: column, or
Enable flex-wrap: wrap, or
Switch to display: block
You are repeating the class = "row"
Try this instead:
<div class="container-fluid">
<div id="bubble">
<div class="row">
<div class="col-md-12">
<h3 id="question">Question Here</h3>
</div>
<div class="col-md-12">
<ul class="list-inline">
<li>Disagree</li>
<label class="disagree" id="disagree-btn" val="0"></label>
<label class="disagree" val="0.5"></label>
<label id="neutral" val="1"></label>
<label class="agree" val="2"></label>
<label class="agree" id="agree-btn" val="3"></label>
<li>Agree</li>
</ul>
</div>
<div class="col-md-12">
<button class="btn btn-warning" id="back-btn">Back</button>
<button class="btn btn-primary" id="next-btn">Next</button>
</div>
</div>
<br><br>
</div>
Well you have a couple issues, A) you have the .list-inline>li set to display: inline-block. So that's why there inline. B) Another issue I saw was that you have only 1 li inside your ul, everything else is labels. Which would probably make it appear inline to. If you want the labels not inside of an li element, then put them inside of a div of another li, either way this is not correct HTML formatting.
Related
This question already has answers here:
How to remove the space between inline/inline-block elements?
(41 answers)
Closed 3 months ago.
I just designed a simple sign-in form to practice CSS and HTML but I can't align 2 divs horizontally to input my name and surname.
Actually, I can't understand why if I apply a width of 50% they are stuck on top of each other and if I apply 49% width they are perfectly horizontally aligned as I want.
MY CSS (child width 50%):
I'm expecting with the child property set to 50% they should take 50% of the parent space.. but actually not, why?
what I'm doing wrong, why have to reduce the width to 49% to align them horizontally
see my image 50% width:
I want them aligned side by side like here:
.title{
padding: 1vh;
text-transform: uppercase;
font-size: 2vh;
}
.wrapper{
margin: 0;
padding: 0;
background-color: yellow;
}
.parent{
background-color: red;
width: 100%;
}
.child{
width: 50%; <--------- HERE THE ISSUE
display: inline-block;
}
<body class="body">
<div class="center">
<h1 class="title">Sign Up New User</h1>
<form class="submit_form">
<div class="wrapper">
<div class="parent">
<div class="child">
<label for="Name">Name:</label><br>
<input type="text" id="Name" name="fname">
</div>
<div class="child">
<label for="Surname">Surname:</label><br>
<input type="text" id="Surname" name="fsurname" >
</div>
</div>
</div>
</form>
</div>
</body>
You can use flex-box to achieve this,
I have added this in parent,
display: flex ;
align-items: center;
justify-content: space-evenly ;
You also have to remove width: 50%; from the .child class and add the following CSS,
display:flex ;
align-items:center;
justify-content:center ;
flex-direction:column;
margin: 4px;
Now you can add further CSS as you want.
.title{
padding: 1vh;
text-transform: uppercase;
font-size: 2vh;
}
.wrapper{
margin: 0;
padding: 0;
background-color: yellow;
}
.parent{
background-color: red;
display:flex ;
align-items:center;
justify-content:space-evenly ;
}
.child{
display:flex ;
align-items:center;
justify-content:center ;
flex-direction:column;
margin:4px ;
}
<body class="body">
<div class="center">
<h1 class="title">Sign Up New User</h1>
<form class="submit_form">
<div class="wrapper">
<div class="parent">
<div class="child">
<label for="Name">Name:</label>
<input type="text" id="Name" name="fname">
</div>
<div class="child">
<label for="Surname">Surname:</label>
<input type="text" id="Surname" name="fsurname" >
</div>
</div>
</div>
</form>
</div>
</body>
If I understand your question correctly this should help. First what you want to do is understand what Flex is in html, this first helped me to understand flex.
So you want to add display: flex; to your container/.parent to tell the script that the container is a flex element. After that you should add text-align: center; to center the text inside the .parent. Finnaly, add justify-content: space-evenly; so this way all of the items inside the .parent are spaced evenly from each other.
Also a lot of the things that you put in .child I removed becasue they where unnecessary to achieve what you are going for. I did add margin: 5px; just to make it look more visually appealing.
Your finished code should look like this
.title{
padding: 1vh;
text-transform: uppercase;
font-size: 2vh;
}
.wrapper{
margin: 0;
padding: 0;
background-color: yellow;
}
.parent{
display: flex;
background-color: red;
width: 100%;
text-align: center;
justify-content: space-evenly;
}
.child{
margin: 5px;
}
<body class="body">
<div class="center">
<h1 class="title">Sign Up New User</h1>
<form class="submit_form">
<div class="wrapper">
<div class="parent">
<div class="child">
<label for="Name">Name:</label><br>
<input type="text" id="Name" name="fname">
</div>
<div class="child">
<label for="Surname">Surname:</label><br>
<input type="text" id="Surname" name="fsurname" >
</div>
</div>
</div>
</form>
</div>
</body>
Hope this will be close to your desired result, I added some CSS to match the posted HTML.
Each input is centered in a box half of the container with flex: 1, so there is no need to set width in the code.
You can add more child field here, and the layout will scale naturally.
Example:
.title {
padding: 1vh;
text-transform: uppercase;
font-size: 2vh;
}
.wrapper {
margin: 0;
padding: 0;
background-color: yellow;
}
.parent {
background-color: red;
flex: 1;
display: flex;
justify-content: center;
}
.child {
color: #fff;
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
<div class="center">
<h1 class="title">Sign Up New User</h1>
<form class="submit_form">
<div class="wrapper">
<div class="parent">
<div class="child">
<label for="Name">Name:</label><br />
<input type="text" id="Name" name="fname" />
</div>
<div class="child">
<label for="Surname">Surname:</label><br />
<input type="text" id="Surname" name="fsurname" />
</div>
</div>
</div>
</form>
</div>
I'm currently displaying two icons and I kept space between them using flex-box property justify-content and value space-between. The problem is that sometimes only one icon is going to be displayed and I need the V-icon to always stay to the left and the urgent-icon to the right.
I tried to use floats(right/left) or some flex-box properties like justify-self: end or flex-end but it did not work. The urgent-icon goes to the left and it should always stay to the right.
Is is possible to achieve it with flex-box? Where did I make mistake?
<div class="d-flex justify-content-between">
<a class="text-underline flex-wrap w-70" (click)="navigateToDetails($event)">{{request.id}}</a>
<div class="d-flex justify-content-between w-30">
<img src="assets/v-icon.svg"
title="Urgent Request" (click)="navigateToDetails($event)"
[tooltip]="'Link redirects to Vendor Req.: ' + request.id"
[options]="{'tooltip-class': 'tooltip-style', 'placement': 'top'}">
<img *ngIf="request?.urgent" height="22" width="22" src="assets/urgent-icon.svg"
class="float-right">
</div>
</div>
Just give the right icon margin-left:auto
div {
width: 150px;
border: 1px solid red;
padding: 1em .25em;
display: flex;
justify-content: space-between;
margin: 1em;
}
span:last-of-type {
margin-left: auto;
}
<div><span>1</span><span>2</span></div>
<div><span>2</span></div>
You can create a spacer between images, with flex: 1 1;
.main{
width: 50%;
height: 50px;
background: rgb(200, 200, 200);
display: flex;
}
.spacer{ /* this will expand into all the space left over */
flex: 1 1;
}
span{
height: 100%;
width: 50px;
background: rgb(150, 100, 255);
}
.red{
background: rgb(255, 100, 100);
}
<div class="main">
<span></span>
<div class="spacer"></div> <!-- Add this between the images -->
<span class="red"></span>
</div>
<br>
<div class="main">
<div class="spacer"></div>
<span class="red"></span>
</div>
<br>
<div class="main">
<span></span>
<div class="spacer"></div>
</div>
I have 3 columns
.bookingTotals.middleRow {
height: 315px;
bottom: 400px;
}
.bookingTotals.row {
height: 400px;
bottom: 0;
margin-left: 920px;
/*margin-right: 55px;*/
}
<div id "myParent">
<div style="float: left; width: 400px;">
//some stuff
<div>
<div style="float: left; width: 400px;">
//some stuff
<div>
<div style="float: left; width: 400px;">
<div style="height:50px;">
//top stuff
</div>
<div class="bookingTotals middleRow">
//middle stiff that fills the gap
</div>
<div class="bookingTotals row">
//bottom stuff that i want fixed to the bottom
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I want to split the last column into 3 layers where the top and bottom div heights are known. So I want the middle div to fill the space between.
What actually happens is that this footer div is displayed outside myParent as if it had no relation to it. What am I doing wrong?
I took some liberty with your height so it would show better.
Use CSS for everything, not put in the markup. Use classes for that.
I make the assumption you want the text in the last one at the bottom so I added a span around it and used align-self: flex-end; at the flex end for the row.
Background color added for clarity of the solution.
#myParent {
width: 100px;
}
.rowthing {
width: 410px;
}
.holder {
display: flex;
flex-direction: column;
min-height: 350px;
border: solid 1px red;
}
.things {
display: flex;
}
.topstuff {
height: 50px;
background-color: #ddeeee;
}
.bookingTotals.middleRow {
flex-grow: 1;
background-color: #dddddd;
justify-content: space-evenly;
}
.bookingTotals.middleRow span {
align-self: center;
}
.bookingTotals.bottom {
height: 100px;
background-color: #eeeedd;
justify-content: center;
}
.bookingTotals.bottom span {
align-self: flex-end;
}
<div id "myParent">
<div class="rowthing">
//some stuff1
</div>
<div class="rowthing">
//some stuff2
</div>
<div class="rowthing holder">
<div class="things topstuff">
//top stuff
</div>
<div class="things bookingTotals middleRow">
<span> //middle stiff that fills the gap<span>
</div>
<div class="things bookingTotals bottom">
<span>bottom stuff that i want fixed to the bottom<span>
</div>
</div>
</div>
If you use the bottom property you also need to specify position.
I used calc to fill the space. In this way, the height of the middle row will depend on the screen size.
.top-row {
height: 50px;
background: red;
}
.bookingTotals.middleRow {
height: calc(100vh - 400px);
background: orange;
}
.bookingTotals.row {
height: 290px;
background: yellow;
}
<div id="myParent">
<div>
some stuff
<div>
<div style="width: 400px;">
some stuff
<div>
<div style="width: 400px;">
<div class="top-row">
top stuff
</div>
<div class="bookingTotals middleRow">
middle stiff that fills the gap
</div>
<div class="bookingTotals row">
bottom stuff that i want fixed to the bottom
<div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I'm trying to aligne an input field with a button at the bottom of a tchat.
Here is the result on normal screen size +15"
and here is the result on -15"
Html :
<div class="col footer">
<div class="divider"></div>
<div class="row footer-input input-container form-group">
<div class="input-field inline col s10 m10">
<input #messageInput type="text">
<label for="message">Tapez votre message</label>
</div>
<div class="col button-col s2 m2">
<a class="waves-effect btn blue"">
<i class="material-icons">send</i></a>
<app-loading-panel [visible]="isSending"></app-loading-panel>
</div>
</div>
</div>
Css :
div.divider {
margin-top: 2px;
}
div.footer {
position: absolute;
bottom: 0;
margin: 0;
width: 100%;
}
div.input-container {
vertical-align: middle;
padding-top: 10px;
}
input[type=text]:focus:not([readonly]) {
border-bottom: 1px solid #2196F3;
box-shadow: 0 1px 0 0 #2196F3;
}
input[type=text]:focus:not([readonly]) + label {
color: #2196F3;
}
div.footer-input {
margin-bottom: 0;
}
div.button-col {
height: 100%;
}
I'm not good with css, how can I have the input take all the place it can, the button be at the right and centered vertically and nothing going out of bound ?
this might help you from a basic perspective:
Have a container that's a flex box
Assign a flex-grow of 1 to the input
This will ensure the input takes up most of the space whilst the button remains on the right.
.container {
width: auto;
background: #ebebeb;
display: flex;
flex-direction: row;
}
.container input {
flex-grow: 1;
}
<div class="container">
<input type="text" placeholder="Some Stuff"/>
<button> Button </button>
</div>
This question already has answers here:
Absolutely positioned flex item is not removed from the normal flow in IE11
(4 answers)
Closed 6 years ago.
This http://jsfiddle.net/7ra5oL77/ should line up the orange dots horizontally with the text underneath.
The relevant items are:
<div class="draggable ui-widget-content"></div>
and
<div class="item">60°C</div>
This works in Chrome and Edge, but Firefox seem to not use the full width and there is a too big white space on the right side.
Can anyone help me?
The issue that I see is that firefox is recognizing your div.lines as items within the flexbox even though the are position absolute. If you pull them outside of the container or delete them altogether (I don't see their purpose), then you should be fine.
The absolute positioned .lines mess up with the space-around alignment:
#graph-containment-wrapper {
justify-content: space-around;
}
This seems a bug, because the spec says
An absolutely-positioned child of a flex container does not
participate in flex layout.
The justify-content property aligns flex items along the
main axis of the current line of the flex container.
As a workaround, you can use auto margins to achieve the same effect without the interference of absolutely positioned elements:
.draggable {
margin: 0 auto;
}
.lines {
padding: 0px;
margin: 0px;
height: 1px;
background-color: orange;
position: absolute;
}
.draggable {
width: 30px;
height: 30px;
background: orange;
border-radius: 30px;
cursor: n-resize;
top: 200px;
z-index: 1;
border: 0px;
display: flex;
justify-content: center;
align-items: center;
color: white;
margin: 0 auto;
}
.x-axis {
display: flex;
justify-content: space-around;
width: 100%
}
#graph-containment-wrapper {
display: flex;
height: 20rem;
background-color: white;
}
.graph {
-webkit-user-select: none;
}
.draw-area{
width: 100%
}
.hlines{
background-color: lightgray;
width:100%;
height: 1px;
display: flex;
}
.hlines-container{
display:flex;
min-height: 100%;
justify-content: space-between;
flex-direction: column;
padding: 15px;
height: 20rem;
margin-top: -20rem
}
<div class="graph">
<div class="draw-area">
<div id="graph-containment-wrapper">
<div class="draggable ui-widget-content"></div>
<div class="draggable ui-widget-content"> </div>
<div class="draggable ui-widget-content"> </div>
<div class="draggable ui-widget-content"> </div>
<div class="draggable ui-widget-content"> </div>
<div class="lines" id="myline0"></div>
<div class="lines" id="myline1"></div>
<div class="lines" id="myline2"></div>
<div class="lines" id="myline3"></div>
</div>
<div class="hlines-container">
<div class="hlines"></div>
<div class="hlines"></div>
<div class="hlines"></div>
<div class="hlines"></div>
<div class="hlines"></div>
<div class="hlines"></div>
</div>
</div>
<div class="x-axis">
<div class="item">20°C</div>
<div class="item">30°C</div>
<div class="item">40°C</div>
<div class="item">50°C</div>
<div class="item">60°C</div>
</div>
</div>