Bootstrap Alert in Jumbotron wrong margins - html

I am creating a part of my website which includes a Jumbotron and a collapsable alert message, both from the Bootstrap Framework. I am having problems with the margins from the alert box. I use the standard CSS for the Jumbotron with adjusted paddings, which do not interfere with my problem though.
This is how it looks like unmodified:
I want the alert box to fit with the alignment of the selection boxes. I tried override the properties of the alert class with this:
.alert-custom-style {
margin-left: 15px;
margin-right: 15px;
width: 100%;
}
The result of it is here:
This does work fine for the left side, but the margin-right property somehow does not get considered. I tested this by putting margin-left back to 0px but then it just looked like in the first picture. I am really scratching my head around why the left margin property works, but not the right one. Any suggestions or help is very appreciated.
Here is the HTML-Code:
<div class="jumbotron jumbotron-custom">
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 top-buffer">
<!-- Dropdown List for the first country -->
<select id="country1" name="Country Selection 1" class="selectpicker" data-width="100%" data-style="btn-default" data-live-search="true" title="Choose..."></select>
</div>
<div class="col-lg-2 col-md-2 col-sm-12 col-xs-12 top-buffer">
<!-- Compare Button -->
<button id="btnSubmit" type="Submit" class="btn btn-success btn-block">Compare</button>
</div>
<div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 top-buffer">
<!-- Dropdown List for the second country -->
<select id="country2" name="Country Selection 2" class="selectpicker" data-width="100%" data-style="btn-default" data-live-search="true" title="Choose..."></select>
</div>
<!-- JavaScript file to handle the data management -->
<script src="js/compare.js"></script>
<!-- JavaScript file to handle the selection lists -->
<script src="js/lists.js"></script>
</div>
<div class="row top-buffer">
<div id="alert" class="collapse alert alert-custom-style col-lg-12 col-md-12 col-sm-12 col-xs-12" role="alert"> <!-- Collapsed by default -->
<strong>Warning: </strong><span id="alert-span">Please select at least two different countries</span>
</div>
</div>
</div>

For row that holds the alert with the class top-buffer try adding:
margin-left: 15px;
margin-right: 15px;
I don't have all your css, but here is a rough version that I think approximates what you want.
Use the "full page" button at the bottom of the snippet to see the result in a wider view.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="jumbotron">
<div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 top-buffer">
<!-- Dropdown List for the first country -->
<select id="country1" name="Country Selection 1" class="selectpicker" style="width:100%;" data-width="100%" data-style="btn-default" data-live-search="true" title="Choose...">
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-12 col-xs-12 top-buffer">
<!-- Compare Button -->
<button id="btnSubmit" type="Submit" class="btn btn-success btn-block" style="width:100%;">
Compare
</button>
</div>
<div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 top-buffer">
<!-- Dropdown List for the second country -->
<select id="country2" name="Country Selection 2" class="selectpicker" style="width:100%;" data-width="100%" data-style="btn-default" data-live-search="true" title="Choose...">
</select>
</div>
<div class="row top-buffer" style="margin-left: 15px; margin-right: 15px;">
<div id="alert" class="collapse in alert alert-custom-style col-lg-12 col-md-12 col-sm-12 col-xs-12" role="alert" style="background-color: red;"> <!-- Collapsed by default -->
<strong>Warning: </strong><span id="alert-span">Please select at least two different countries</span>
</div>
</div>
</div>
</div>

Related

how to make col-md-3 at the right side align in html bootstrap 4

i want to make one div right align , but not able keep it in right side in row. how to make the value 172.21 at right side in the row.
screenshot
HTML:
<div class="row">
<div class="col-md-6">
<h4>Status</h4>
<input type="checkbox" disabled checked data-toggle="toggle" data-onstyle="outline-success" data-offstyle="outline-danger">
</div>
<div class="col-md-3">
<h4>Max Demand </h4>
</div>
<div class="col-md-3">
<h4>172.21</h4>
</div>
</div>
If there is text, just "align-right"
If there is block, in BS3:
Add "pull-right" to the element container
In BS4:
"float-right"
E.g. in BS4:
<div class="row">
<div class="col-md-6">
<h4>Status</h4>
<input type="checkbox" disabled checked data-toggle="toggle" data-onstyle="outline-success" data-offstyle="outline-danger">
</div>
<div class="col-md-3">
<h4>Max Demand </h4>
</div>
<div class="col-md-3 float-right">
<h4>172.21</h4>
</div>
</div>
You just need add class in last column like: text-left text-md-right.
I hope below snippet will help you.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css">
<div class="container border">
<div class="row">
<div class="col-md-6">
<h4>Status</h4>
<input type="checkbox" disabled checked data-toggle="toggle" data-onstyle="outline-success" data-offstyle="outline-danger">
</div>
<div class="col-md-3">
<h4>Max Demand </h4>
</div>
<div class="col-md-3 text-left text-md-right">
<h4 class="btn btn-warning">545</h4>
</div>
</div>
</div>
Just for the text, add text-right class after col-md-3
and for the entire column, add pull-right class after col-md-3 if you're using bootstrap-3
and for bootstrap-4 add float-right instead of pull-right class.

How to have two pull-right elements one below another in bootstrap grid system?

I have a bootstrap grid system on my page and want two elements pulled to the right, but placed one below the other. This is the code I have right now. I want "Active" and "Primary" button place one below the other, but also pulled right. As of now, it looks like this:
If I were to add this to the button, then it aligns properly, but on mobile, it messes up.
<button type="button" class="btn btn-w-m btn-primary" style="margin-left: 261px;">Primary</button>
This is what I have so far. What can I do to achieve the desired result?
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row border-bottom white-bg dashboard-header">
<div class="col-md-3">
<h4>Dummy Name</h4>
<small>Dummy Street</small><br>
<small>Dummy Apt, Some City, Some State</small><br>
<small>United States</small><br>
</div>
<div class="col-md-3">
<h5>123-456-7890</h5>
</div>
<div class="col-md-3">
<h5>some_name#somecompany.com</h5>
</div>
<div class="col-md-3">
<h2 class="pull-right" style="margin-top: -5px">Active</h2><br>
<button type="button" class="btn btn-w-m btn-primary">Primary</button>
</div>
</div>
</div>
You do not need pull-right at all - all you need to right align the text of the heading and the button is text-align:right in the css or the text-right class on the parent div. Note that you need to open this snippet in "full screen mode due to the small size of the preview window.
I would also suggest that you put the css in its own style sheet rather than inline style rules. If you use text-align: right as a style rule then you can use a media query to apply it or left align on certain screen sizes as required.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row border-bottom white-bg dashboard-header">
<div class="col-xs-3 col-md-3">
<h4>Dummy Name</h4>
<small>Dummy Street</small><br>
<small>Dummy Apt, Some City, Some State</small><br>
<small>United States</small><br>
</div>
<div class="col-xs-3 col-md-3">
<h5>123-456-7890</h5>
</div>
<div class="col-xs-3 col-md-3">
<h5>some_name#somecompany.com</h5>
</div>
<div class="col-xs-3 col-md-3 text-right">
<h2>Active</h2><br>
<button type="button" class="btn btn-w-m btn-primary">Primary</button>
</div>
</div>
</div>
</div>

Bootstrap Button and input box , side by side

Can anybody please advise/correct me how to align or arrange the button and input box side by side without grouping in bootstrap.
I had searched few examples in the internet which are only in grouping of elements.
jsfiddle: https://jsfiddle.net/erama035/p9dagmL3/3/
<div class="container">
<div class="row">
<div class="col-xs-5 col-sm-5 col-md-5">
<button class="btn btn-default col-sm-2 col-md-2">add</button>
<input class="form-control col-md-3 col-sm-2"/>
</div>
<div class="col-xs-7 col-sm-7 col-md-7">
<button class="btn btn-default col-md-2">remove</button>
<input class="form-control col-md-5"/>
</div>
</div>
</div>
The quick way would be, to simply use Flexbox for the parent <div>. This converts the child elements to flex items, which are arranged side by side by default.
.container > .row > div {
display: flex;
}
The proper way would be to use Bootstraps predefined classes for grouping.
.container>.row>div {
display: flex;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-5 col-sm-5 col-md-5">
<button class="btn btn-default">add</button>
<input class="form-control" />
</div>
<div class="col-xs-7 col-sm-7 col-md-7">
<button class="btn btn-default">remove</button>
<input class="form-control" />
</div>
</div>
</div>
for the cross-browser you can simple use inline-block
.btn,.form-control{display: inline-block; width: auto;}

Flexbox in Bootstrap 4 acting weird

I'm trying to use flexbox to align vertically a section.
So this is what I'm trying to align vertically:
HTML:
<!--Top Hero Section -->
<div class="d-flex hm-hero justify-content-center">
<div class="container">
<div class="row align-items-end">
<div class="col-12">
<h1 class="text-center">Fix Your Problem Today!</h1>
<p class="text-center">Start searching for a contractor or company around your area and get your problem fixed in a matter of hours!</p>
</div>
<!--Form Section -->
<div class="col-12">
<div class="form-group row justify-content-center">
<div class="col-12 col-md-6">
<input class="form-control" type="text" value="e.g. plumbing, carpentry" id="example-text-input">
</div>
<div class="col-12 col-md-4">
<input class="form-control" type="text" value="e.g. city name, postcode" id="example-text-input">
</div>
<div class="col-12 col-md-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</div>
</div>
Regarding CSS, I've only applied this:
.hm-hero {
background: url("../img/main_pic.png") no-repeat;
background-size: fill;
min-height: 600px;
}
I can't figure out why flexbox is not working. I've tried two classes, align-content/items-center in whatever div possible and still can't get it to work.
So since I have that full width div with the background image, inside it is a container div, which I'm trying to get it to stay vertically. I really want to avoid putting a 200px margin top to this. Is this is a Bootstrap 4 bug?
I added the align-items-center class to the flex div parent and it worked. As long as you have a height on the .hm-hero the content will be centered. Hope this helps. JSFiddle
.hm-hero {
background: url("https://placehold.it/960x600") no-repeat;
background-size: fill;
min-height: 600px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<!--Top Hero Section -->
<div class="d-flex hm-hero justify-content-center align-items-center">
<div class="container">
<div class="row align-items-end">
<div class="col-12">
<h1 class="text-center">Fix Your Problem Today!</h1>
<p class="text-center">Start searching for a contractor or company around your area and get your problem fixed in a matter of hours!</p>
</div>
<!--Form Section -->
<div class="col-12">
<div class="form-group row justify-content-center">
<div class="col-12 col-md-6">
<input class="form-control" type="text" value="e.g. plumbing, carpentry" id="example-text-input">
</div>
<div class="col-12 col-md-4">
<input class="form-control" type="text" value="e.g. city name, postcode" id="example-text-input">
</div>
<div class="col-12 col-md-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</div>
</div>

How to make nested Div wrap instead of overlap?

I'm using Bootstrap's grid system. I have 3 divs inside a "row", and inside each of those divs are nested controls.
When I horizontally decrease the browser size, the 2nd and 3rd div in the row are overlapping the 1st div. I want them to wrap, not overlap.
How can I achieve this?
Here is my code:
<!-- SEARCH CONTROLS -->
<div class="row">
<!-- Left side search boxes and search button -->
<div class="col-xs-5">
<div class="article" id="SAorPIList">
<select style="min-width: 215px; max-width: 300px;" class="col-xs-4 form-control" data-bind="value: selectedSAPIValue, options: saorpi, optionsText: 'Name', optionsValue: 'CmeTypeId', optionsCaption: 'Select SA or PI'"></select>
</div>
<div class="col-xs-5" style="padding-top: 20px;">
<select style="max-width: 300px;" class="specialties-class form-control" name="Name" id="SpecialtyId"></select>
</div>
<div class="col-xs-5" style="max-width: 150px; padding-top: 20px; padding-left: 175px;">
<button id="btnDropDownsSearch" class="btn btn-search collapsed" type="button">
<i class="icon-search"></i>
</button>
</div>
</div>
<!-- The world "OR" in the center of the page -->
<div class="col-xs-2" style=" padding-left: 75px; padding-top:50px;">
<strong style="display:inline;">OR</strong>
</div>
<!-- Right side search box -->
<div class="col-xs-5 pull-left" style="padding-bottom: 50px; min-width:400px;">
<span><strong style="text-align:left;">Activity Search</strong></span>
<div class="col-xs-4 input-group pull-left input-group-lg" style="padding-top:50px;">
<input id="txtFreeformSearch" class="form-control" type="search" style="min-width:175px;" />
<div class="input-group-btn">
<button id="btnFreeformSearch" class="btn btn-search collapsed" type="button">
<i class="icon-search"></i>
</button>
</div>
</div>
</div>
</div>
When you say, you nesting controls to div; Do you mean somethink like this?
.row > div {
background: lightgrey;
border: 1px solid grey;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">.col-md-4</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">.col-md-4</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">.col-md-4</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">.col-md-4</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">.col-md-4</div>
</div>
I solved this by defining min-width inside a good number of the tags.
This allowed the DIVs to wrap in PC, tablet, and mobile formats.
I would post the resulting HTML, but I think it would affect too few readers to make it worthwhile. I say this because there is a knockout control and select2 control within the HTML, and some of their UI properties are defined in javascript.