nested columns bootstrap 4 align bottom - css

I'm trying to make a form with bootstrap 4, and I have a problem with align one column to the bottom:
And this is my code:
<div class="col-md-3 m-2">
<div class="row">
<div class="col-12 d-flex flex-column border border-primary bg-light rounded form-group h-100">
<h3>text</h3>
<div class="form-group">
<label for="i1">i1</label>
<input type="text" class="form-control" name="i1" id="i1" placeholder="i1" value="223108853">
</div>
<div class="form-group">
<label for="i1">i1</label>
<input type="text" class="form-control" name="i1" id="i1" placeholder="i1" value="223108853">
</div>
</div>
<div class="col-12 border border-primary bg-light rounded form-group h-100 col align-self-end">
<h3>bottom box</h3>
<div class="form-group">
<label for="i1">i1</label>
<input type="text" class="form-control" name="i1" id="i1" placeholder="i1" value="223108853">
</div>
<div class="form-group">
<label for="i1">i1</label>
<input type="text" class="form-control" name="i1" id="i1" placeholder="i1" value="223108853">
</div>
<div class="form-group">
<label for="i1">i1</label>
<input type="text" class="form-control" name="i1" id="i1" placeholder="i1" value="223108853">
</div>
<div class="form-group">
<label for="i1">i1</label>
<input type="text" class="form-control" name="i1" id="i1" placeholder="i1" value="223108853">
</div>
</div>
</div>
</div>
https://jsfiddle.net/rotor82/c7ugmsw8/3/
I'm not sure how to fix it, I tried align-self-end but it doesn't work.

If you set the following element to margin-bottom: 0 (it's currently set to 15px), you'll solve your problem.
.col-md-3.m-2:nth-of-type(2) .col-12:last-of-type {
margin-bottom: 0;
}
jsFiddle

Related

how to increase the height of "container"

I have an below code.I would like to know how to increase the height of "container" class.I have check in google but unable to find any solution.Please check my below code and advise how to do this
<main class="d-flex align-items-center min-vh-100 py-3 py-md-0">
<div class="container">
<div class="card login-card">
<div class="row no-gutters">
<div class="col-md-5">
<img src="assets/images/login2.jpg" alt="login" class="login-card-img" >
</div>
<div class="col-md-7">
<div class="card-body">
<div class="brand-wrapper">
<img src="assets/images/logo.jpg" alt="logo" class="logo" style="width:130px;height:130px">
</div>
<p class="login-card-description">Sign In</p>
<form action="#!">
<div class="form-group">
<label for="email" class="sr-only">Email</label>
<input type="email" name="email" id="email" class="form-control" placeholder="Email address">
</div>
<div class="form-group mb-4">
<label for="password" class="sr-only">Password</label>
<input type="password" name="password" id="password" class="form-control" placeholder="***********">
</div>
<input name="login" id="login" class="btn btn-block login-btn mb-4 text-align: center;" type="button" value="Login">
</form>
<div class="form-group">
<label for="password" class="sr-only">Password</label>
<input type="password" name="password" id="password" class="form-control" placeholder="Password">
</div>
</div>
</main>
In css file:
.container{
height: 1000px
}
OR
<div class="container" style= "height:1000px;">
Keep in mind that div and main are both block elements so it can be an idea to inspect that the main element does not block the height increase of the div.
You can add class to your container, just like in your <main:
<div class="container min-vh-100">
Try any one of the ways:
External CSS
.container {
height: 1000px
}
Inline CSS
<div class="container" style="height: 1000px;">
Maybe you want only pass the image down, just like this?
<img src="assets/images/login2.jpg" alt="login" class="login-card-img" style="margin-top: 150px" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<main class="d-flex align-items-center min-vh-100 py-3 py-md-0">
<div class="container">
<div class="card login-card">
<div class="row no-gutters">
<div class="col-md-5">
<img src="assets/images/login2.jpg" alt="login" class="login-card-img" style="margin-top: 150px" />
</div>
<div class="col-md-7">
<div class="card-body">
<div class="brand-wrapper">
<img src="assets/images/logo.jpg" alt="logo" class="logo" style="width:130px;height:130px">
</div>
<p class="login-card-description">Sign In</p>
<form action="#!">
<div class="form-group">
<label for="email" class="sr-only">Email</label>
<input type="email" name="email" id="email" class="form-control" placeholder="Email address">
</div>
<div class="form-group mb-4">
<label for="password" class="sr-only">Password</label>
<input type="password" name="password" id="password" class="form-control" placeholder="***********">
</div>
<input name="login" id="login" class="btn btn-block login-btn mb-4 text-align: center;" type="button" value="Login">
</form>
<div class="form-group">
<label for="password" class="sr-only">Password</label>
<input type="password" name="password" id="password" class="form-control" placeholder="Password">
</div>
</div>
</main>

How to set "label 3" with the same percentage that "label 1" in this form?

I'm using Bootstrap 4.
I would like set "label 3" with the same width that "label 1". The input width, the rest of the page (see code)
It's possible?
Thanks.
<div class="form-row">
<div class="col-6">
<div class="form-group row">
<label for="name" class="col-6">LABEL 1:</label>
<div class="input-group col-6">
<input type="text" class="form-control" placeholder="Enter text">
</div>
</div>
</div>
<div class="col-6">
<div class="form-group row">
<label for="name" class="col-6">LABEL 2:</label>
<div class="col-6">
<input class="form-control" placeholder="Enter text" type="text">
</div>
</div>
</div>
</div>
<div class="form-row">
<div class="col-12">
<div class="form-group row">
<label for="name" class="col-3">LABEL 3:</label>
<div class="input-group col-9">
<input type="text" class="form-control" placeholder="Enter text">
</div>
</div>
</div>
Instead of putting a row beside form-group, add another div that have a form-row, something like this:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="form-row">
<div class="col-6">
<div class="form-group">
<div class="form-row">
<label for="name" class="col-6">LABEL 1:</label>
<div class="input-group col-6">
<input type="text" class="form-control" placeholder="Enter text">
</div>
</div>
</div>
</div>
<div class="col-6">
<div class="form-group">
<div class="form-row">
<label for="name" class="col-6">LABEL 2:</label>
<div class="col-6">
<input class="form-control" placeholder="Enter text" type="text">
</div>
</div>
</div>
</div>
</div>
<div class="form-row">
<div class="col-12">
<div class="form-group">
<div class="form-row">
<label for="name" class="col-3">LABEL 3:</label>
<div class="input-group col-9">
<input type="text" class="form-control" placeholder="Enter text">
</div>
</div>
</div>
</div>
</div>
I think the issue is mostly the padding of row, but not sure. I just rearranged it properly, by separating row/form-row

grid system Boostrap 4 - inline

I want that the input fiels are in the same line. But I don't know what am I doing wrong. Can somebody help me? I am using Bootstrap 4.
This is how I wanted it:
enter image description here
html code
<body>
<div class="container h-100">
<div class="row">
<div class="col-12">
<div id="content">
<h1>Contact Page</h1>
<h3>Contact Us</h3>
<hr>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-6 offset-md-3">
<form class="form-group">
<div class="form-inline">
<input class="form-control transparent-input" type="text" name="name" placeholder="Name" required>
</div>
</form>
</div>
<div class="col-md-6 offset-md-3">
<form class="form-group">
<div class="form-inline">
<input class="form-control transparent-input" type="text" name="surname" placeholder="Vorname" required>
</div>
</form>
<button type="submit" class="btn btn-default">Send invitation</button>
</div>
</div>
</div>
Add "form-row" or "row" in your code.
<form>
<div class="container">
<div class="form-row">
<div class="form-group mx-sm-3 mb-2">
<input class="form-control transparent-input" type="text" name="name" placeholder="Name" required>
</div>
<div class="form-group mx-sm-3 mb-2">
<input class="form-control transparent-input" type="text" name="surname" placeholder="Vorname" required>
</div>
</div>
<div class="form-row">
<div class="form-group mx-sm-3 mb-2">
<button type="submit" class="btn btn-default">Send invitation</button>
</div>
</div>
</div>
</form>
OR
<form>
<div class="container">
<div class="row">
<div class="form-group mx-sm-3 mb-2">
<input class="form-control transparent-input" type="text" name="name" placeholder="Name" required>
</div>
<div class="form-group mx-sm-3 mb-2">
<input class="form-control transparent-input" type="text" name="surname" placeholder="Vorname" required>
</div>
</div>
<div class="row">
<div class="form-group mx-sm-3 mb-2">
<button type="submit" class="btn btn-default">Send invitation</button>
</div>
</div>
</div>
</form>
Restructure you form.
- Use one tag for this form. Do Not use for every input a form tag.
- delete the div with class form-inline.
- Add class form-inline to div with class="col-md-6 offset-md-3".
<div class="container">
<form>
<div class="form-inline">
<div class="form-group mx-sm-3 mb-2">
<input class="form-control transparent-input" type="text" name="name" placeholder="Name" required>
</div>
<div class="form-group mx-sm-3 mb-2">
<input class="form-control transparent-input" type="text" name="surname" placeholder="Vorname" required>
</div>
</div>
<div class="form-group mx-sm-3 mb-2">
<button type="submit" class="btn btn-default">Send invitation</button>
</div>
</form>
</div>
Row or form-row doesn't really matter. Form-row changes the gutter. It's to your own preference.

Bootstrap 3 - spacing issues

I am building a simple form using Bootstrap in which I am facing some layout issues related to spacing. This is how the form looks like
There is lots of space between the label and fields. For instance, in the above image empty space between label and name field is highlighted. I would like to increase the width of input field so that the space reduces.
I would like to get rid of the vertical space between 2 fields. For instance, there is a space between author and IP fields. I would like them to be closed together. Again, not able to make out the reason.
This is the fiddle I have created to reproduce the problem.
.border {
border: 1px solid;
}
.input-field {
height: 20px
}
.custom-label {
line-height: 3.3em !important;
}
.label-size {
font-size: 10px;
line-height: 2.1em;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<form class="form-horizontal">
<div class="col-md-8">
<div class="form-group">
<label for="name" class="col-md-4 label-size">Name</label>
<div class="col-md-8">
<input type="text" id="name" class="form-control input-sm input-field">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="gender" class="col-md-4 label-size">Gender</label>
<div class="col-md-8">
<select id="gender" class="form-control input-sm input-field label-size">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<label class="col-md-4 label-size custom-label">Functions</label>
<div class="checkbox col-md-8 label-size checkbox-primary" >
<label class="col-md-3">
<input type="checkbox" id="Func1"> Func1</label>
<label class="col-md-3">
<input type="checkbox" id="Func2">Func2</label>
<label class="col-md-3">
<input type="checkbox" id="Func2">Func3</label>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="country" class="col-md-4 label-size">country</label>
<div class="col-md-8">
<select id="country" class="form-control input-sm input-field label-size">
<option>Select</option>
<option>1</option>
<option>1</option>
</select>
</div>
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<div class="col-md-3">
<label class="label-size">Options</label>
</div>
<div class="col-md-9">
<div class="checkbox checkbox-primary label-size col-md-3">
<!-- there is a for loop here-->
<!-- For every run of loop, one div [with col-xs-4] below will be created. Since loop is not there, I am creating multiple divs manually -->
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
<div class="checkbox checkbox-primary label-size col-md-3">
<input id="check1" type="checkbox"> check1
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="addr" class="col-md-4 label-size">ADDR</label>
<div class="col-md-8">
<input type="text" id="addr" class="form-control input-sm input-field">
</div>
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<label for="authro" class="col-md-4 label-size">authro</label>
<div class="col-md-8">
<input type="text" id="authro" class="form-control input-sm input-field">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="range" class="col-md-4 label-size">Range</label>
<div class="col-md-3">
<input type="text" id="range" class="form-control input-sm input-field">
</div>
<div class="col-md-2">
to
</div>
<div class="col-md-3">
<input type="text" id="range2" class="form-control input-sm input-field">
</div>
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<label for="ip" class="col-md-4 label-size">IP</label>
<div class="col-md-8">
<input type="text" id="ip" class="form-control input-sm input-field">
</div>
</div>
</div>
<div class="col-xs-10 ">
<div class="form-group ">
<div class="col-xs-4">
<button class="btn btn-xs" type="button">Start</button>
</div>
<label class="col-xs-2 label-size">Order</label>
<div class="radio" class="col-xs-4 label-size">
<label>
<input type="radio" name="order3">order3</label>
<label>
<input type="radio" name="order4">order4</label>
</div>
</div>
</div>
</form>
</div>
Any help is much appreciated.
I made some format changes to your code see if this fix your need.
http://jsfiddle.net/ayang10/sbcobqz9/66/
.form-horizontal .control-label {
text-align: right;
margin-bottom: 0;
padding-top: 7px;
}
should fix your format/alignments

How can you make a wrap responsive?

I have researched this to the max and haven't been able to find ANY information. I started thinking, maybe it had to do with media queries, but I really couldn't get anything to work for me.
My question is, how can I make a wrap responsive? I utilize Twitter Bootstrap and am running into a unique issue.
I have a simple wrap that looks like this:
.wrap {
width: 800px;
margin: 0 auto;
}
Then, I have a form, that looks like this:
<div class="wrap">
<div class="col-sm-12">
<form class="form-inline" name="contactform">
<div class="col-sm-6 form-group form-sty">
<label class="sr-only" for="first" required>First Name</label>
<input type="text" class="form-control-sty" name="first" placeholder="First Name">
</div>
<div class="col-sm-6 form-group form-sty">
<label class="sr-only" for="last" required>Last Name</label>
<input type="text" class="form-control-sty" name="last" placeholder="Last Name">
</div>
<div class="col-sm-6 form-group form-sty">
<label class="sr-only" for="phone" required>Phone</label>
<input type="text" class="form-control-sty" name="phone" placeholder="Phone">
</div>
<div class="col-sm-6 form-group form-sty">
<label class="sr-only" for="email" required>Email</label>
<input type="email" class="form-control-sty" name="mailfrom" placeholder="Email">
</div>
<div class="col-sm-12 form-sty">
<label class="sr-only" for="comment">Comment</label>
<textarea class="form-control-sty" name="message" id="message" rows="7" placeholder="What's on your mind?" required></textarea>
</div>
<div class="col-sm-12 form-sty form-sty-btn">
<button type="submit" value="Submit" class="btn btn-default col-sm-12">Send</button>
</div>
</form>
</div>
</div>
The issue I'm having is, since this sits inside of a wrap, when the site scales down the form fails to scale as well since it is filling the entirety of the 800px wrap.
I'm not looking for an answer as much as I'm looking for suggestions?
THanks for any help you can offer.
You can also view the actual website for a better idea, here: www.bestillcreative.com
.wrapper{
width:100%:
max-width:800px;
}
.wrap {
width:100%;
max-width:800px;
margin: 0 auto;
}
.form-sty{
margin:10px 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="wrap">
<div class="col-sm-12">
<form class="form-inline" name="contactform">
<div class="col-sm-6 form-group form-sty">
<div class="col-sm-3 col-md-4"> <label for="first" required>First Name</label></div>
<div class="col-sm-3 col-md-2"> <input type="text" class="form-control-sty" name="first" placeholder="First Name"></div>
</div>
<div class="col-sm-6 form-group form-sty">
<div class="col-sm-3 col-md-4"> <label for="last" required>Last Name</label></div>
<div class="col-sm-3 col-md-2"><input type="text" class="form-control-sty" name="last" placeholder="Last Name"></div>
</div>
<div class="col-sm-6 form-group form-sty">
<div class="col-sm-3 col-md-4"> <label for="phone" required>Phone</label></div>
<div class="col-sm-3 col-md-2"><input type="text" class="form-control-sty" name="phone" placeholder="Phone"></div>
</div>
<div class="col-sm-6 form-group form-sty">
<div class="col-sm-3 col-md-4"><label for="email" required>Email</label></div>
<div class="col-sm-3 col-md-2"><input type="email" class="form-control-sty" name="mailfrom" placeholder="Email"></div>
</div>
<div class="col-sm-6 form-sty">
<div class="col-sm-3 col-md-4"><label for="comment">Comment</label></div>
<div class="col-sm-9 col-md-8"><textarea class="form-control-sty" name="message" id="message" rows="7" placeholder="What's on your mind?" required></textarea></div>
</div>
<div class="col-sm-12 form-sty form-sty-btn">
<button type="submit" value="Submit" class="btn btn-default col-sm-12">Send</button>
</div>
</form>
</div>
</div>
Try this structure

Resources