Bootstrap 3 stacking issue - 1st col drops on medium - css

I have the code below in Bootstrap 3. It all works perfectly except if you are on the tablet the logo drops down and doesn't stay top left. It works great on phone and works great on desktop.... What am I missing?
http://www.bootply.com/K3G0VtD0OS
<!-- always Stay top right and maintain the same size-->
<div class="col-xs-6 col-sm-2 pull-right">
<div class="row">
<div class="pull-right"> sharing icons </div>
<div class=""> account login </div>
</div>
<!-- LOGO Always stay top left no matter what size-->
<div class="col-xs-2 col-sm-12 col-md-2 logo pull-left"> logo image </div>
<!-- Always stay to the right of logo but at tablet, drop below the 1st and second column -->
<div class="col-xs-12 col-md-8 pull-left">
<div class="row">
<div class="col-xs-12 col-md-1"> </div>
<div class="col-xs-12 col-md-11"> Search bar goes here </div>
</div>

I believe that this is occurring because you only allow 2 bootstrap columns for BOTH "sharing icons" and "account login". So when you get to tablet size, 2 columns is not enough room and it wraps the "account login" (it does not wrap "sharing icons" because that element has the pull-right class on it).
You can fix this by reducing the unnecessary 8 columns for the search bar to 7 when in col-sm (tablet size), so that the wrapper for "sharing icons" and "account login" can have 3 columns instead of 2, while allowing it to still be 8 in col-md and higher.
Updated bootply
Change One:
<div class="col-xs-6 col-sm-3 col-md-2 pull-right"> <!-- Change col-sm-2 to col-sm-3 and add col-md-2 -->
<div class="row">
<div class="pull-right"> sharing icons </div>
<div class=""> account login </div>
</div>
</div>
Change Two:
<div class="col-xs-12 col-sm-7 col-md-8 pull-left"> <!-- Add col-sm-7 -->
<div class="row">
<div class="col-xs-12 col-md-1"> </div>
<div class="col-xs-12 col-md-11"> Search bar goes here </div>
</div>
</div>

Related

Bootstrap Responsive Columns Height

I'm using bootstrap 4 and trying to create a layout. The problem I'm having is with the responsive.
When the page size gets smaller I want the right-nav to go under the left-nav. The problem I run into is when the main body runs longer than the left nav. The right nave always goes under the main body, is there a way to force it under the left-nav without the space in between?
<div class="container-fluid">
<div class="row pt-5 pl-3 pr-3">
<div id="left-nav" class="d-none d-sm-none d-md-block col-md-4 col-lg-3 col-xl-2">
...
</div>
<div id="main-body" class="col-12 col-sm-12 col-md-8 col-lg-9 col-xl-8">
...
</div>
<div id="right-nav" class="d-none d-sm-none d-md-block col-md-3 col-lg-3 col-xl-2">
...
</div>
</div>
<section id="footer" class="footer">
<div class="container">
<div class="row">
</div>
</div>
</div>
</div>
Since Bootstrap 4 uses flexbox, cols across a row are always going to be the equal height (set by the height of the tallest).
You can workaround this by "disabling" flexbox at certain breakpoints using d-(breakpoint)-block on the row. By making the row display:block instead display:flex, floats can now be used to float cols to the right or left.
<div class="container-fluid">
<div class="row pt-5 d-md-block d-xl-flex">
<div id="left-nav" class="d-sm-none d-md-block col-md-4 col-lg-3 col-xl-2 border float-left">
left
</div>
<div id="main-body" class="col-md-8 col-lg-9 col-xl-8 border taller float-right">
main
</div>
<div id="right-nav" class="d-sm-none d-md-block col-md-4 col-lg-3 col-xl-2 border">
right
</div>
</div>
</div>
Demo: https://www.codeply.com/go/A0oYUlPOud
Related:
How to fix unexpected column order in bootstrap 4?
How to make this column ignore the vertical space

Aligning 2 buttons. 1 left and 1 right

I currently have a VIEW button to the right of this layout but want to add another ADD button to the right.
You can see an example of this on https://www.fireworkscrazy.co.uk/store_v8/shopdisplayproducts.asp?id=5&cat=Barrages+%2F+Cakes+-+Single and then select the GRID VIEW icon
<div class="desktop_view product-view grid-list-row-view hide" style="">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-6">
<div class="featured-prod-widget">
<div class="nailthumb">
[formatimage sub]
[CC_ADD_NEW_FLAG]
</div>
<div class="row product-details">
<div class="col-sm-12">
<h6 class="widget-product-title">[translate cname]</h6>
</div>
<div class="row"></div>
<div class="col-sm-12">
$ <span class="widget-prod-price">[FORMATCUSTOMERPRICE cprice]</span>
</div>
<div class="col-sm-12">
</div>
</div>
**<a href="[formatshopexdlink][add_websesslink]" class="submitbtn pull-left">
VIEW
</a>**
</div>
</div>
</div>
the style .grid-list-row-view .featured-prod-widget .submitbtn affecting your button. it has absolute position. so with same style if you create button with pull-left or pull-right , it will display on same position instead of left or right. you will need to implement some workaround to overcome or remove absolute style.

Keep bootstrap columns in same row when changing size

I have a div that has two columns - one holds a glyphicon, the other holds text. At larger sizes, this works correctly:
But when the browser is at a smaller width (or mobile), the columns split, and it ends up looking like this:
Is there any way to force the columns to stay together in a single row? There's plenty of room for both columns, even at the narrowest size.
Here's my HTML for a single row:
<div class="row">
<div class="col-md-2"><i class="fa fa-check fa-2x fa-fw"></i></div>
<div class="col-md-10">
<p>Zero Day Protection</p>
</div>
</div>
The CSS is standard bootstrap (the i class is a FontAwesome glyphicon).
Use the col-xs-* Grid classes.
<div class="row">
<div class="col-xs-2"><i class="fa fa-check fa-2x fa-fw"></i></div>
<div class="col-xs-10">
<p>Zero Day Protection</p>
</div>
</div>
In a bootstrap grid, your columns are all 100% wide by default. Use the col-<size>-<number> classes to override that. The <size> can be either xs, sm, md, or lg, and refers to the minimum screen width for that class to apply. The <number> is a number from 1 to 12 and refers to the number of columns wide your content should be.
So, maybe you have really wide content, and it should only be displayed side by side on desktop browsers. You could give your content class="col-md-6" and it would display side by side as long as the browser window is at least 992 pixels wide.
But, for you, since your content is really small, you want it always to display side by side, so you should use col-xs-<number> classes.
You could make it so that on mobile, you have one pair per line, but on tablets you have two per line, and on desktops you have 3 per line:
#import "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css";
<div class="container-fluid">
<div class="row">
<div class="col-xs-3 col-sm-2 col-md-1"><i class="glyphicon glyphicon-ok"></i></div>
<div class="col-xs-9 col-sm-4 col-md-3">
<p>Adaptive Updates</p>
</div>
<div class="col-xs-3 col-sm-2 col-md-1"><i class="glyphicon glyphicon-ok"></i></div>
<div class="col-xs-9 col-sm-4 col-md-3">
<p>Online Support and Knowledge Base</p>
</div>
<div class="col-xs-3 col-sm-2 col-md-1"><i class="glyphicon glyphicon-ok"></i></div>
<div class="col-xs-9 col-sm-4 col-md-3">
<p>Direct Support</p>
</div>
<div class="col-xs-3 col-sm-2 col-md-1"><i class="glyphicon glyphicon-ok"></i></div>
<div class="col-xs-9 col-sm-4 col-md-3">
<p>Enterprise Management Console</p>
</div>
<div class="col-xs-3 col-sm-2 col-md-1"><i class="glyphicon glyphicon-ok"></i></div>
<div class="col-xs-9 col-sm-4 col-md-3">
<p>Zero Day Protection</p>
</div>
</div>
</div>
See the bootstrap Grid System documentation for more detail.
class="col-md-2 col-xs-2" and class="col-md-10 col-xs-10"
You can combine classes for the element to make it behave certain way based on screen size. You can do something like class="col-md-2 col-xs-6" and class="col-md-10 col-xs-6" etc...

Bootstrap 3 second column collapse.. third column float right

In the code below for Bootstrap 3, I am attempting to get the 3rd column to not stack. I want it to always stay top right just as the left most column stays top left. Is there a simple way? I thought about just excluding that section from bootstrap and just apply css to float right, but surely in Bootstrap, I can do this.
<header id="t3-header" class="container t3-header">
<div class="row">
<!-- LOGO -->
<div class="col-xs-12 col-md-2 logo"> I stay always top left</div>
<div class="col-xs-12 col-md-8"> I should stackunder 1st column as browser resizes </div>
<!-- I want this column to not stack below column 2 as the browser resizes. -->
<div class="col-xs-12 col-md-2">
I should always stay top right
<div class="row">
<div class="col-lg-6"> </div>
<div class="col-lg-6"> </div>
</div>
</div>
</div>
If I've understood you correctly, you've got to make the "top right" div, appear first in the cascade. To do this, first it as the first column, then you can use pull-left and pull-right helper classes to trick the first two columns:
Secondly, you could remove the col-xs-12 alike in the example:
<header id="t3-header" class="container t3-header">
<div class="row">
<div class="col-md-2 pull-right">
I should always stay top right
<div class="row">
<div class="col-lg-6"></div>
<div class="col-lg-6"></div>
</div>
</div>
<!-- LOGO -->
<div class="col-sm-12 col-md-2 logo pull-left">
I stay always top left
</div>
<div class="col-sm-12 col-md-8 pull-left">
I should stackunder 1st column as browser resizes
</div>
</div>
</div>
Example: http://www.bootply.com/ee3E67pujY

Bootstrap 3 Grid Layout Issue on Tablet

I have problem with the Bootstrap grid system on my new website /services-page (kenpils.se.
I would prefer 3 rows with 2 columns instead to make the text in the columns better readable on tablet. Right now the columns are to narrow due to the icon on the left side of each column.
As far as I understand, each row is one div which makes it difficult to slide up the "commercial-column" next to the "editorial-column". There is also a divide30-class between the two rows.
Would appreciate some advice.
The solution to this I have found works best is to duplicate your content in a tablet layout. then use visible-* (documented here) class attributes to hide and make visible specific content to specific screen resolutions. You will need to add visible-* class attributes to your <div class="row"> and change your col-sm-4 to col-md-4 see below:
<div class="row visible-lg visible-md">
<div class="col-md-4">
<!-- Your Content 1-->
</div>
<div class="col-md-4">
<!-- Your Content 2-->
</div>
<div class="col-md-4">
<!-- Your Content 3-->
</div>
</div>
<div class="row visible-lg visible-md">
<div class="col-md-4">
<!-- Your Content 4-->
</div>
<div class="col-md-4">
<!-- Your Content 5-->
</div>
<div class="col-md-4">
<!-- Your Content 6-->
</div>
</div>
Then add a section under that in your code duplicating the information and hiding it on larger screen resolutions. see below:
<div class="row visible-sm visible-xs">
<div class="col-sm-6">
<!-- Your Content 1-->
</div>
<div class="col-sm-6">
<!-- Your Content 2-->
</div>
</div>
<div class="row visible-sm visible-xs">
<div class="col-sm-6">
<!-- Your Content 3-->
</div>
<div class="col-sm-6">
<!-- Your Content 4-->
</div>
</div>
<div class="row visible-sm visible-xs">
<div class="col-sm-6">
<!-- Your Content 5-->
</div>
<div class="col-sm-6">
<!-- Your Content 6-->
</div>
</div>
This will provide the formatting you desire. Hope this helps.
NOTE: THE BELOW SOLUTION DOESNT ALTER THE LAYOUT AT ALL as you require. It provides an alternative solution !
<div class="col-services">
<div class="row">
<div class="col-sm-4></div>
<div class="col-sm-4></div>
<div class="col-sm-4></div>
</div>
</div>
This means that the break wont occur until the width reduces below tablet-zone !
col-sm-4 -> break after tablet-zone width
col-md-4 -> break after normal desktop width
Replace it with
<div class="col-services">
<div class="row">
<div class="col-md-4></div>
<div class="col-md-4></div>
<div class="col-md-4></div>
</div>
</div>
This makes sure that the break occurs at the tablet level itself!

Resources