I have seen there are some examples of using push/pull with bootstrap 3 but I haven't had much like trying it out. Is it possible in this example to get col-sm-4 content to show before col-sm-5 col-lg-12 on mobile as col-sm-4is currently showing last on mobile.
<section id="inner-page" class="container">
<div class="row">
<div class="col-lg-8 col-sm-7">
<div class="post-media">
<div id="slider" class="flexslider">
<ul class="slides">
<li></li>
</ul>
</div>
<div id="carousel" class="flexslider">
<ul class="slides">
<li></li>
</ul>
</div>
</div>
<div class="row mTop-20">
<div class="col-sm-5 col-lg-12">
content
</div>
</div>
</div>
<div class="col-sm-4">
content
</div>
</div>
</section>
With Bootstrap 3
You can use push and pull classes
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div style="border: 1px solid red" class="col-sm-4 col-lg-push-8 col-sm-push-7">
content
</div>
<div style="border: 1px solid green" class="col-lg-8 col-sm-7 col-sm-pull-4">
<div class="post-media">
<div id="slider" class="flexslider">
<ul class="slides">
<li></li>
</ul>
</div>
<div id="carousel" class="flexslider">
<ul class="slides">
<li></li>
</ul>
</div>
</div>
<div class="row mTop-20">
<div class="col-sm-5 col-lg-12">
content
</div>
</div>
</div>
</div>
With Bootstrap 5
You can use the order property
add the class order-0 order-sm-2 for col-sm-4 and the classe order-1 for col-sm-7
or the flex-direction property
add the classes flex-column-reverse flex-sm-row for the row
Related
Thanks in advance for your help!
I work in bootstrap 4 building websites, I'm trying to build the following design:
I can't get my head round how it will work! At the moment I have the whole box set to container-fluid so there isn't any padding/margins applied but I don't understand how I can structure the columns to get it to work.
Here's my HTML for what I have tried so far:
<div class="container-fluid">
<div class="row">
<div class="col-12">
<h3 class="mega-menu-heading">About</h3>
</div>
<div class="col-sm-3 g-pa-0">
<ul class="list-unstyled style-list">
<li class="serviceAbout">[insert] </li>
<li class="serviceAbout">[insert]</li>
</ul>
</div>
<div class="col-sm-3 g-pa-0">
<ul class="list-unstyled style-list">
<li class="serviceAbout">[insert] </li>
<li class="serviceAbout">[insert] </li>
</ul>
</div>
<div class="col-sm-3 g-pa-0">
<ul class="list-unstyled style-list">
<li class="serviceAbout">[insert] </li>
<li class="serviceAbout">[insert] </li>
</ul>
</div>
<div class="col-sm-3 g-pa-0">
<img class="img-responsive g-pa-0 g-ma-0" src="/assets/images/misc/nav-image.jpg">
</div>
<!--/end row-->
</div>
</div>
I understand that the col-12 is taking up all the available space in the container so I cannot have an image full height of the container but I'm not sure what other way I can do it.
Any help would be appreciated, this must be possible I'm probably just missing something!
Thanks,
You could create a first row having 2 columns : col-sm-9 and col-sm-3.
Then create another row in the col-sm-9 to list your services and use the col-sm-3 to display your image.
div {
text-align: center;
background-color: rgba(86,61,124,.15);
border: 1px solid rgba(86,61,124,.2);
}
.bgimg {
background-image: url('https://mdn.mozillademos.org/files/7693/catfront.png');
background-size: contain;
background-repeat: no-repeat;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-sm-9">
<div class="row">
<div class="col-sm-12">Our services</div>
<div class="col-sm-4">Service 1</div>
<div class="col-sm-4">Service 2</div>
<div class="col-sm-4">Service 3</div>
<div class="col-sm-4">Service 4</div>
<div class="col-sm-4">Service 5</div>
<div class="col-sm-4">Service 6</div>
</div>
</div>
<div class="col-sm-3 bgimg">
Image full-height
</div>
</div>
</div>
You can use bootstrap grid systems. Use container, row and col pattern.
To understand it better go to this link.
Try this code structure:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css">
<div class="container text-center">
<div class="row">
<div class="col-9">
<div class="row">Our Services</div>
<div class="row">
<div class="col-4">Service 1</div>
<div class="col-4">Service 2</div>
<div class="col-4">Service 3</div>
</div>
<div class="row">
<div class="col-4">Service 4</div>
<div class="col-4">Service 5</div>
<div class="col-4">Service 6</div>
</div>
</div>
<div class="col-3">
<img src="https://source.unsplash.com/100x100/?documents" class="img" alt="img">
</div>
</div>
</div>
I have following:
<div class="container-fluid" id="contact">
<div class="row justify-content-center" align="center">
<div class="col-lg-6 d-flex justify-content-center">
<div>
<img src="icon-mail.png" style="padding-right:20px;">
</div>
<div>
<h4>E-mail</h4>
<p>gmail#gmail.sk</p>
</div>
</div>
<div class="col-lg-6 d-flex justify-content-center">
<div>
<img src="icon-tel.png" style="padding-right:20px;">
</div>
<div>
<h4>Call us</h4>
<p>+00000000000</p>
</div>
</div>
</div>
</div>
This is view with screen size >992:
This is view with screen <992:
How can I display elements below each other as is viewed in image2 ? I do not know why, but "display:block" is not working.
You can use
<div class="row">
to create separate rows of content satisfying your needs.
I recommend to read about grid system in this article:
https://getbootstrap.com/docs/4.0/layout/grid/
<div class="container-fluid" id="contact">
<div class="row justify-content-center" align="center">
<div class="col-lg-6 d-flex justify-content-center">
<div>
<img src="icon-mail.png" style="padding-right:20px;">
</div>
<div>
<h4>E-mail</h4>
<p>gmail#gmail.sk</p>
</div>
</div>
</div>
<div class="row justify-content-center" align="center">
<div class="col-lg-6 d-flex justify-content-center">
<div>
<img src="icon-tel.png" style="padding-right:20px;">
</div>
<div>
<h4>Call us</h4>
<p>+00000000000</p>
</div>
</div>
</div>
</div>
In bootstrap 5 there is an option named order. So in your question, You can add a class named order-md-2 to things that you want to shift down and order-md-1 to things that you want to shift up.
<div class="container-fluid" id="contact">
<div class="row justify-content-center" align="center">
<div class="col-lg-6 d-flex justify-content-center">
<div class="order-md-1">
<img src="icon-mail.png" style="padding-right:20px;">
</div>
<div>
<h4>E-mail</h4>
<p>gmail#gmail.sk</p>
</div>
</div>
<div class="col-lg-6 d-flex justify-content-center">
<div class="order-md-2">
<img src="icon-tel.png" style="padding-right:20px;">
</div>
<div>
<h4>Call us</h4>
<p>+00000000000</p>
</div>
</div>
</div>
</div>
Hope my answer helps you
you could simply use the flex-direction of the flexbox.
<div class="container-fluid" id="contact">
<div class="row justify-content-center" align="center">
<div class="col-lg-6 d-flex justify-content-center">
<div class="order-md-1">
<img src="icon-mail.png" style="padding-right:20px;">
</div>
<div class='contacts'>
<div class='mail'>
<h4>E-mail</h4>
<p>gmail#gmail.sk</p>
</div>
</div>
<div class="col-lg-6 d-flex justify-content-center">
<div class="order-md-2">
<img src="icon-tel.png" style="padding-right:20px;">
</div>
<div class='phone'>
<h4>Call us</h4>
<p>+00000000000</p>
</div>
</div>
</div>
</div>
</div>
Inside CSS:
.contacts {
display: flex;
flex-direction: column;
}
This should allow you to orient both of your div-containers to be underneath each other.
I have a little problem with my code. The tabs load but when I click on another inactive tab doesn't hide the content of the first tab and displays the content of both tabs. Is there anything I can do? Thank you very much!
<ul style="list-style:none"class="available-tabs nav nav-tabs" id="tabs" data-tabs="tabs">
<li class="active"> <a data-toggle="tab" href="#featured-tab-body">FEATURED PROJECTS</a></li>
<li> <a data-toggle="tab" href="#available-latest-tab">LATEST PROJECTS </a> </li>
</ul>
<div class="available-content tab-content container">
<div id="available-featured-tab">
<div class="featured-list-wrapper">
<div class="row">
<div class="col-md-12">
<div class="featured-list-content">
<div class="row featured-tab-head" style="color:black;height:40px">
<div class="col-md-5 col-sm-5 col-xs-8">
<h5> YAE</h5>
</div>
<div class="col-md-2 col-sm-2 hidden-xs">
<h5>NAH</h5>
</div>
<div class="col-md-2 hidden-sm hidden-xs">
<h5>HEY</h5>
</div>
<div class="col-md-1 col-sm-2 hidden-xs">
<h5>YOU</h5>
</div>
</div>
<div class="featured-tab-body tab-pane fade in active">
sup
</div>
</div>
</div>
</div>
</div>
<div id="available-latest-tab" class="tab-pane fade">
hi
</div>
</div>
You need to put all the div contents under the same root div.
So istead of:
<div class="available-content tab-content container">
<div id="available-featured-tab">
<div class="featured-list-wrapper">
<div class="row">
<div class="col-md-12">
<div class="featured-list-content">
<div class="featured-tab-body tab-pane fade in active">
sup
</div>
</div>
</div>
</div>
</div>
</div>
<div id="available-latest-tab" class="tab-pane fade">
hi
</div>
</div>
You need:
<div class="available-content tab-content container">
<div id="available-featured-tab">
<div class="featured-list-wrapper">
<div class="row">
<div class="col-md-12">
<div class="featured-list-content">
<div class="featured-tab-body tab-pane fade in active">
sup
</div>
<div id="available-latest-tab" class="tab-pane fade">
hi
</div>
</div>
</div>
</div>
</div>
</div>
</div>
No need for the Jquery, since bootstrap do the work for you.
Corrected fiddle:
http://jsfiddle.net/xFW8t/1777/
I'm trying to break two ul lists of jobs under the two headers, "Job Categories" and "Job Function,"into multiple columns, columns not necessarily the same height, and responsive. Otherwise, the single column lists are too long. These two headers and lists should be inline (horizontal). This obviously needs to be responsive for mobile as well.
What's the best way to do this? Visual example below:
Using the grid system, one could "break-up the cells" of the bootstrap grid system:
<div class="container">
<!-- Content Area-->
<div class="row">
<div class="col-md-5 col-sm-6">
<div class="row">
<h2 class="">Job Functions</h2>
</div>
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="row content">
<ul class="list-unstyled">
<li>,</li>
<li>,</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="row content">
<ul class="list-unstyled">
<li>,</li>
<li>,</li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-md-6 col-sm-5">
<div class="row">
<h2 class="">Job Categories</h2>
</div>
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="row content">
<ul class="list-unstyled">
<li>,</li>
<li>,</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="row content">
<ul class="list-unstyled">
<li>,</li>
<li>,</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="row content">
<ul class="list-unstyled">
<li>,</li>
<li>,</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
It worked. Enjoy!
<div class="col-md-6">
Bootstrap breaks a page/div down into 12 "columns" inside the class .container. This way you're giving half of that space to one of your headers and it'll be mobile-friendly.
I hope this isn't a gross oversimplification but given the information available it seems right.
Try this
<ul class="col-md-6 col-sm-6 col-xs-12">
<li class="col-xs-12"><h2>Job Function</h2></li>
<li class="col-md-6 col-sm-6 col-xs-12">List 1</li>
<li class="col-md-6 col-sm-6 col-xs-12">List 2</li>
<ul>
<ul class="col-md-6 col-sm-6 col-xs-12">
<li class="col-xs-12"><h2>Job Categories</h2></li>
<li class="col-md-6 col-sm-6 col-xs-12">List 1</li>
<li class="col-md-6 col-sm-6 col-xs-12">List 2</li>
<ul>
I used to have a working layout of a header, side navigation column, main large content column , and a footer. Now the navigation column is sitting on top of the content column even though the numbers should add up. I just need my navigation column to line up next to my content. You can see my WIP HERE. What am I doing wrong?
Here is basically what my code for my layout is:
<div class="container">
<div class="row">
<div class="page-header">
<p>HEADER</p>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-2 col-md-2 hidden-sm hidden-xs">
<p>NAVIGATION</p>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-12 col-lg-offset-2 col-md-offset-2 col-sm-offset-0 col-xs-offset-0">
<p>CONTENT</p>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="page-footer">
<p>FOOTER</p>
</div>
</div>
</div>
Your help is greatly appreciated. Thank you! :)
The column divs only line up beside each other for the divs actually are "siblings" to each other, apart from adding up numberwise.
Try putting the navigation and content columns in the same container -> row tag, like so:
<div class="container">
<div class="row">
<div class="col-lg-2 col-md-2 hidden-sm hidden-xs">
<p>NAVIGATION</p>
</div>
<div class="col-lg-10 col-md-10 col-sm-12 col-md-12 col-lg-offset-2 col-md-offset-2 col-sm-offset-0 col-xs-offset-0">
<p>CONTENT</p>
</div>
</div>
</div>
From the look of your code, it looks like you want your columns next to each other. This should work
<div class="container">
<div class="row">
<div class="page-header">
<p>HEADER</p>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-2 col-md-2 hidden-sm hidden-xs">
<p>NAVIGATION</p>
</div>
<div class="col-lg-10 col-md-10 col-sm-12 col-md-12 col-lg-offset-2 col-md-offset-2 col-sm-offset-0 col-xs-offset-0">
<p>CONTENT</p>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="page-footer">
<p>FOOTER</p>
</div>
</div>
</div>