Bootstrap 3 - Vertically Algn Row Content [duplicate] - css

This question already has answers here:
Twitter Bootstrap 3, vertically center content [duplicate]
(2 answers)
Closed 5 years ago.
I have a row in Bootstrap. Within this row, I have three columns. The first column has an input field. The second column has some text. The third column has another input field. You can see this layout in this Bootply, which includes this code:
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="row">
<div class="col-xs-5">
<div class="form-group">
<label for="Minimum">Minimum</label>
<div class="input-group">
<input class="form-control" data-val="true" id="Minimum" name="Minimum" type="text" value="0">
</div>
</div>
</div>
<div class="col-xs-2 text-center"><p>Up To</p></div>
<div class="col-xs-5">
<div class="form-group">
<label for="Maximum">Maximum</label>
<div class="input-group">
<input class="form-control" data-val="true" id="Maximum" name="Maximum" type="text" value="100">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I'm am trying to figure out how to vertically align the "Up To" text in the middle column. I want to vertically align the text against the bottom of the row. How can I do that?

The line height for the table rows is 34px, so setting your line height for that element to 68px would vertically align it.

You can add a class on your row and set display: table;
Then you add another class on your 3 divs and set display: table-cell;and float: inherit; and a last class on your element you want to align vertically and set vertical-align: middle;
Updated Bootply

Related

Kendo dialog not expanding to width of bootstrap 4 form group

I have a bootstrap 4 form group with a simple text input. I am using it within a kendo dialog, however the dialog isn't automatically expanding so that the label's text and the input are all on a single line. I have played around with the CSS but can't figure out what is causing the issue. See the below dojo link.
https://dojo.telerik.com/EQuwayex
You can change your "test" div to following. I set a fixed with for the label and then reduced the textbox div to col-md-6.
<div id="test">
<div class="container">
<div class="form-group row">
<label style="width:100px" class="col-form-label">Display Text</label>
<div class="col-md-6">
<input type="text" class="displayText form-control" />
</div>
</div>
</div>
</div>
If you want to control the width of the dialog you can add a width to the Dev element and then change the width of the textbox div element.
<div id="test" style="width:700px">
<div class="container">
<div class="form-group row">
<label style="width:100px" class="col-form-label">Display Text</label>
<div class="col-md-9">
<input type="text" class="displayText form-control" />
</div>
</div>
</div>
</div>

Bootstrap 4 - Align horizontally and vertically [duplicate]

This question already has answers here:
Vertical Align Center in Bootstrap 4 [duplicate]
(20 answers)
How to vertically align in Bootstrap 4?
(1 answer)
Bootstrap Center Vertical and Horizontal Alignment
(17 answers)
Closed 5 years ago.
I can't align the following content both horizontally and vertically.
Can someone tell me the best approach for this ?
<div class="container">
<div class="row">
<div class="col-md-4">
<img width="300" src="../assets/medlogo.png">
<h1 class="text-center login-title">Acessar o programa</h1>
<div class="account-wall">
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120"
alt="">
<form class="form-signin">
<input type="text" class="form-control" placeholder="Email" required autofocus>
<input type="password" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">
Sign in</button>
</form>
</div>
</div>
</div>
</div>
Thank you
Bootstrap4 is now using css Flexbox so you can use the same. Flexbox has vertical and horizontal alignment support out of the box.
Basically, a flexbox container can have flex-direction as row (the default value) or column. With the former, property align-items can be used to vertical align its children and justify-content for horizontal alignment. While with the latter, align-items is used for horizontal align and justify-content for vertical alignment.
You can read more about Flexbox here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Try this
<div class=" d-flex justify-content-center align-content-center">
<img width="300" src="../assets/medlogo.png">
<h1 class="text-center login-title">Acessar o programa</h1>
<div class="account-wall">
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120"
alt="">
<form class="form-signin">
<input type="text" class="form-control" placeholder="Email" required autofocus>
<input type="password" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">
Sign in</button>
</form>
</div>
</div>
I removed the col-md-4 and replaced it with d-flex justify-content-center align-content-center. This is bootstrap 4 beta utilities for flexbox. Though you can also do in-line style
More info
http://getbootstrap.com/docs/4.0/utilities/flex/

Materializecss how to get label on left side of input

I have a project with materializecss, and I would like to put the label when class="active" (which is always) to the left of the input field. How do I move the label to the left, while shrinking the input field relatively so it all fits nicely in the column?
Here is my jsfiddle of the scenario
You can also use the inline class http://materializecss.com/forms.html
<div class="row">
<form class="col s12">
<div class="row">
<div class="col s12">
First Name:
<div class="input-field inline">
<input id="last_name" type="text" class="validate square-box align-right">
</div>
</div>
</div>
</form>
</div>
As #Alastair said in the comments under the question, I simply removed the labels altogether, and just used a <p></p> in its own div, and placed that div in a col to the left of the input

Bootstrap - Vertical Align Input Field

I am working on an app that uses Bootstrap 3. In this app, I have a row defined like this:
<div class="row" style="background-color:navy; color:white;">
<div class="col-lg-3">
<h2>Welcome</h2>
</div>
<div class="col-lg-8">
<form class="form-horizontal">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
find:
</div>
<input type="search" class="form-control" id="queryField" />
</div>
</div>
</form>
</div>
<div class="col-lg-1">
<button type="button" class="btn btn-primary">Go</button>
</div>
</div>
I want to make the search field and the Go button vertically aligned with the Welcome text. The Welcome text is kind of vertically aligned. I tried adding vertical-align: middle. That did not work. I was trying to avoid using padding. But if its required, its required. I appreciate any help you can provide.
There is default margin, padding in all tags, so put a class of
h2{ margin: 0; padding: 0; }
and it is automatically come in same line

How to centralize a panel in the middle? [duplicate]

This question already has answers here:
How to align a <div> to the middle (horizontally/width) of the page [duplicate]
(27 answers)
Closed 8 years ago.
I am learning bootstrap for the first time. I am having difficulty to centralize a panel in the middle of the page for a login.
Example:
<div class="container">
<div style='width:500px' class="panel panel-default">
<div class="panel-heading">Login</div>
<div class="panel-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="col-sm-2 control-label">Login</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-lg btn-primary">Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
How can it be done?
See Your Modified Code >> Middle Panel
<div style='width:500px;margin:0 auto;' class="panel panel-default">
Assign
.container {
width:100%;
}
.panel-default{
margin: 0 auto;
}
with margin: 0 auto it's possible to set margin to the div: 0 is refered to top and bottom, while auto is refered to left and right. With 0, will be added a margin of 0px (no margin at all). With auto you ask the browser to set an automatic calculated amount of pixel given the possibility to center the div into a div parent (.container). To apply auto, the div parent should have a width at least greater than its child. In this case, to center the child div to center of page, we should set parent's width to 100% (that means the same width of its container (in this case container of ".container" should be body!).
This is generally achieved by giving the div a specific width (percentage or fixed) as well as margin:0 auto;.

Resources