I have an issue with my bootstrap layout.
Basically, everything looks OK on larger screens but on smaller screens my footer overlaps the content or the content overlaps the footer!
This is the code I have: https://jsfiddle.net/xpvt214o/639029/
If you make the HTML part larger and smaller and look at the footer, you will see the issue.
This is my full code:
html,body,.col-md-12,.row {
height:100%;
}
.row > div {
height:100%;
}
.YOsidemenu{
padding:0;
font-weight:bold;
background-color: #ffc90e;
padding-top:10px;
max-width:200px;
}
#media only screen and (max-width:768px) {
.YOsidemenu{
display:none;
}
}
/* to make columns visible */
.row .col-sm-2 {
background-color:red;
}
.row .col-sm-10 {
background-color:green;
}
<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.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div style="height:100%; background:#fff;width:100%;padding:0;" class="container">
<div class="col-md-12">
<div class="row">
<div class="col-sm-2">
Sidebar content
</div>
<div class="col-sm-10">
Body content
</div>
</div>
</div>
</div>
<!-- Footer -->
<section id="footer" style="text-align:left; !important">
<div class="container">
<div class="row text-center text-xs-center text-sm-left text-md-left" style="text-align:left; !important">
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Quick links</h5>
<ul class="list-unstyled quick-links">
<li>Home</li>
<li>Help</li>
<li>Sign-in</li>
<li>affiliate</li>
<li>Promote</li>
</ul>
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Support</h5>
<ul class="list-unstyled quick-links">
<li><i class="fa fa-envelope"></i>support#email.com</li>
<li><i class="fa fa-phone-square"></i>+44 7842227819</li>
<li><i class="fa fa-globe"></i>www.website.com</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 mt-2 mt-sm-2 text-center text-white">
<p>this site a registered company. </p>
<p class="h6">© All right Reversed.<a class="text-green ml-2" href="https://www.website.com" target="_blank">website</a></p>
</div>
</hr>
</div>
</div>
</section>
<!-- ./Footer -->
Could someone please be kind enough and help me with this issue?
Thanks in advance.
Try removing height: 100% from the div. On mobile the container is 100% high, but because the columns get stacked and each column inherits the height, you have a parent with 100% height and two columns with each 100%, making it 200% of height.
Is this what you are looking for?
html,
body,
.col-md-12,
.row {
height: 100%;
}
.row>div {
height: 100%;
}
.YOsidemenu {
padding: 0;
font-weight: bold;
background-color: #ffc90e;
padding-top: 10px;
max-width: 200px;
}
#media only screen and (max-width:768px) {
.YOsidemenu {
display: none;
}
}
/* to make columns visible */
.row .col-sm-2 {
background-color: red;
}
.row .col-sm-10 {
background-color: green;
}
<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.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div style="height:100%; background:#fff;width:100%;padding:0;" class="container">
<div class="col-md-12">
<div class="row">
<div class="col-sm-2 col-xs-2">
Sidebar content
</div>
<div class="col-sm-10 col-xs-10">
Body content
</div>
</div>
</div>
</div>
<!-- Footer -->
<section id="footer" style="text-align:left; !important">
<div class="container">
<div class="row text-center text-xs-center text-sm-left text-md-left" style="text-align:left; !important">
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Quick links</h5>
<ul class="list-unstyled quick-links">
<li>Home</li>
<li>Help</li>
<li>Sign-in</li>
<li>affiliate</li>
<li>Promote</li>
</ul>
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<h5>Support</h5>
<ul class="list-unstyled quick-links">
<li><i class="fa fa-envelope"></i>support#email.com</li>
<li><i class="fa fa-phone-square"></i>+44 7842227819</li>
<li><i class="fa fa-globe"></i>www.website.com</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 mt-2 mt-sm-2 text-center text-white">
<p>this site a registered company. </p>
<p class="h6">© All right Reversed.<a class="text-green ml-2" href="https://www.website.com" target="_blank">website</a></p>
</div>
</hr>
</div>
</div>
</section>
<!-- ./Footer -->
Related
Need to align four different height (beetween 160-180px) svg images with text under them.
Images should be placed in line at sight and I don't know how to make strict align short text under them in one line like on screenshot.
Thanks!
UPD: Sorry for inconvinient information, thought that this question is quite typical for those who know css good.
Here is my html and css. Also I'm using bootstrap rows.
<div class="did-you-know">
<div class="row items">
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-wa.svg"/>
</div>
<div class="title text-poppins">
<p>We’re from WA</p>
<p>{like you!}</p>
</div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-packaging.svg"/>
</div>
<div class="title text-poppins">
<p>We use minimal packaging</p>
<p>{great for the planet}</p></div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-quality.svg"/>
</div>
<div class="title text-poppins">
<p>We only choose quality</p>
<p>{better for your health}</p></div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-community.svg"/>
</div>
<div class="title text-poppins">
<p>We love giving back</p>
<p>{great for our community}</p></div>
</div>
</div>
</div>
.did-you-know {
padding: 20px;
text-align: center;
}
.did-you-know .items .icon {
padding: 50px;
}
.did-you-know .items .title {
font-size: 20px;
}
here is a solution:
Replace images by your images.
<!DOCTYPE html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}
.column {
float: left;
width: 25%;
padding: 5px;
}
/* Clearfix (clear floats) */
.row::after {
content: "";
clear: both;
display: table;
}
</style>
</head>
<body>
<div class="row">
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Snow" style="width:100%">
<p style='text-align: center;'>test1</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Forest" style="width:100%">
<p style='text-align: center;'>test2</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Mountains" style="width:100%">
<p style='text-align: center;'>test3</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Mountains" style="width:100%">
<p style='text-align: center;'>test3</p>
</div>
</div>
</body>
</html>
I want to automatically resize the container based on <div>. If there are 4 <div> inside container then it looks fine but if there is only 1 <div> then there will be plenty of space in right side. So wanted to adjust container size according to <div>. How can I achieve this? Please help me.
main page looks like this
When there are 4 panels it fits perfectly fine like this
When there are 2 panels then there is plenty of space in the right side which which is marked by color. I want to adjust the container width here automatically.
<div class="container">
<div class="row">
<div>
<ul class="nav nav-tabs" id="ATab">
<li class="active"><a data-toggle="tab" href="#Select">Select</a></li>
<li><a data-toggle="tab" href="#Criteria">Criteria</a></li>
</ul>
<div class="tab-content">
<div id="Select" class=" tab-pane fade in active"></div>
<div id="Criteria" class="tab-pane fade"></div>
<div class="container active col-md-3 col-sm-6 ">
<div class="panel panel-default">
<div class="panel-heading">First Name</div>
</div>
</div>
<div class="container active col-md-3 col-sm-6">
<div class="panel panel-default">
<div class="panel-heading">Last Name</div>
</div>
</div>
</div>
</div>
</div>
</div>
You can use flexbox for this behavior. Check this codepen for demo.
HTML:
<div class="parent">
<ul class="nav">
<li>Item 1</li>
<li>Item 1</li>
<li>Item 1</li>
<li>Item 1</li>
</ul>
</div>
CSS:
.parent {
background-color: orange;
}
.parent ul.nav {
list-style: none;
padding: 0px;
margin: auto;
display: flex;
}
.parent ul.nav li {
background-color: grey;
padding: 10px 15px;
border-right: 1px solid black;
width: 100%;
text-align: center;
}
.parent ul.nav li:last-child {
border: 0px;
}
Hope this would help!
EDIT 1:
Check this other codepen for demo.
body {
padding: 0px;
margin: 0;
}
.parent {
background-color: orange;
padding: 20px;
}
.parent .tabFrame .itemContainer {
display: inline-block;
margin-bottom: 50px;
padding: 5px;
border: 1px solid;
overflow: hidden;
}
.parent .tabFrame .myItem {
background-color: grey;
display: inline-block;
width: 100px; /* can be any fixed width */
padding: 10px;
color: white;
border: 1px solid black;
}
<div class="parent">
<div class="tabFrame">
<div>Tab area</div>
<div class="itemContainer">
<div class="myItem">Item 1</div>
<div class="myItem">Item 2</div>
<div class="myItem">Item 3</div>
<div class="myItem">Item 4</div>
</div>
</div>
<div class="tabFrame">
<div>Tab area</div>
<div class="itemContainer">
<div class="myItem">Item 1</div>
<div class="myItem">Item 2</div>
<div class="myItem">Item 3</div>
</div>
</div>
<div class="tabFrame">
<div>Tab area</div>
<div class="itemContainer">
<div class="myItem">Item 1</div>
<div class="myItem">Item 2</div>
</div>
</div>
<div class="tabFrame">
<div>Tab area</div>
<div class="itemContainer">
<div class="myItem">Item 1</div>
</div>
</div>
</div>
EDIT: 2
See this codepen
.myTab {
border: 1px solid #dddddd;
display: inline-block;
margin-top: -1px;
}
.myTab .tab-pane .myPanel {
display: inline-block;
margin: 10px;
}
.myPanel {
min-width: 200px;
}
#ATab {
border-bottom: 0px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<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="row">
<div>
<ul class="nav nav-tabs" id="ATab">
<li class="active">
<a data-toggle="tab" href="#Select">Select</a>
</li>
<li>
<a data-toggle="tab" href="#Criteria">Criteria</a>
</li>
</ul>
<div class="tab-content clearfix myTab">
<br>
<div id="Select" class=" tab-pane fade in active clearfix">
<div class="panel panel-default myPanel">
<div class="panel-heading">First Name</div>
</div>
<div class="panel panel-default myPanel">
<div class="panel-heading">Last Name</div>
</div>
</div>
<div id="Criteria" class="tab-pane fade">
<div class="panel panel-default myPanel">
<div class="panel-heading">First Name</div>
</div>
<div class="panel panel-default myPanel">
<div class="panel-heading">Last Name</div>
</div>
<div class="panel panel-default myPanel">
<div class="panel-heading">First Name</div>
</div>
<div class="panel panel-default myPanel">
<div class="panel-heading">Last Name</div>
</div>
</div>
</div>
</div>
</div>
</div>
Try using css flexbox to get rid of unwanted spaces.
.nav {
display:flex;
}
a {
text-decoration: none;
color:white;
}
li {
background-color:#232323;
list-style-type: none;
padding: 20px;
flex: 1 1 auto;
}
li.active{
background-color:gray;
}
<div class="container">
<div class="row">
<div>
<ul class="nav nav-tabs" id="ATab">
<li class="active"><a data-toggle="tab" href="#Select">Select</a></li>
<li><a data-toggle="tab" href="#Criteria">Criteria</a></li>
</ul>
<div class="tab-content">
<div id="Select" class=" tab-pane fade in active"></div>
<div id="Criteria" class="tab-pane fade"></div>
</div>
</div>
</div>
</div>
The flex: 1 1 auto on the li makes the li fill up any remaining space on the main flex axis (horizontal line because the default flex direction is row)
You can read up on flex box :
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
https://css-tricks.com/almanac/properties/f/flex/
I am trying to create a screen layout with bootstrap CSS but being a beginner, I am struggling too much. I have a row containing two columns. I need both the columns to extend to the bottom of the available screen and should be responsive. In the second column, I need a div which is always placed at its bottom. Please see the attached image. Any help is highly appreciated.
Here is what I did:
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-6 bg-danger">
left
<ul>
<li ng-repeat="x in [1, 2, 3, 4, 5, 6, 7]">{{x}}</li>
</ul>
</div>
<div class="col-md-6 col-sm-6 bg-info">
right
<div>
<ul>
<li ng-repeat="x in [1, 2, 3, 4, 5, 6, 7]"> content {{x}}</li>
</ul>
</div>
<div class="nav bg-warning">nav</div>
</div>
</div>
</div>
check this out.
.constant{
position:absolute;
bottom:0;
right:0;
width:100%;
border: 2px solid #f60;
height: 40px;
}
.cover-viewport {
height: 100vh;
border: 2px solid green;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-xs-6 cover-viewport">
<!-- your content goes here-->
</div>
<div class="col-xs-6 cover-viewport">
<!-- your content goes here-->
<div class="constant"></div>
</div>
</div>
To make it stretch full viewport you give them all a height of 100%
Another option is to use viewport units vh on the columns
html, body, .container, .row, .row > div {
height: 100%;
}
.bg-info {
position: relative;
}
.bg-info .nav {
position: absolute;
bottom: 0;
width: calc(100% - 30px); /* 2 * 15px padding */
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-6 bg-danger">
left
</div>
<div class="col-xs-6 bg-info">
right
<div class="nav bg-warning">nav</div>
</div>
</div>
</div>
Hope the code below helps:
.constant{
position:absolute;
bottom:0;
right:0;
}
<div class="row">
<div class="col-md-6 col-sm-6">
<!-- your content goes here-->
</div>
<div class="col-md-6 col-sm-6">
<!-- your content goes here-->
<div class="constant"></div>
</div>
</div>
My problem with this is that I can't get it right with background coloring. Left column always 'bleeds' into the top of the right column.
Help guys, I'm trying to fix this for three days now.
Here's my html code:
<div class="container-fluid">
<div class="row blue-background">
<div class="col-lg-6 col-xs-12 col-lg-offset-1">
<h1>Text here</h1>
</div>
<div class="col-lg-5 col-xs-12 gray-background">
<h2>Another text here</h2>
</div>
</div><!-- .row -->
</div><!-- .container-fluid -->
And in my custom CSS file this classes have only background: /value_of_color/
My CSS code:
.blue-background {
background-color: blue;
}
.gray-background {
background-color: #eaeaea;
}
You can try like this-
.blue-background {
background-color: blue;
}
.blue-background:after{
content:'';
display:block;
clear:both;
}
.gray-background {
background-color: #eaeaea;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="blue-background">
<div class="col-lg-6 col-xs-12 col-lg-offset-1">
<h1>Text here</h1>
</div>
<div class="col-lg-5 col-xs-12 gray-background">
<h2>Another text here</h2>
</div>
</div>
</div><!-- .row -->
</div><!-- .container-fluid -->
I hope it will helps you.
<div class="container-fluid">
<div class="row ">
<div class="col-lg-6 col-xs-12 col-lg-offset-1 blue-background">
<h1>Text here</h1>
</div>
<div class="col-lg-5 col-xs-12 gray-background">
<h2>Another text here</h2>
</div>
</div><!-- .row -->
</div><!-- .container-fluid -->
I have a bootstrap panel where the height is automatically generated from a jquery script.
So, I would like to have the footer with a background for the entire section.
How can I achieve this goal ?
I don't want to fix the height for this section, is it possible to make something like :"height for the rest of your space in the panel".
Here the fiddle:
http://www.bootply.com/XBCffrO0My
Table layout approach
Idea is to have the element behave like a table and the child item as its row which would occupy the entire space.
Updated Bootply
#crud1 {
display: table;
width: 100%;
}
.panel-footer {
display: table-row;
height: 100%;
}
.panel-footer .row {
display: table-cell;
padding-top: 5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-md-4">
<div id="crud1" class="panel panel-primary" style="height: 248px;">
<div class="panel-heading clearfix">
<div class="pull-left">
ChartLine 1
</div>
<div class="pull-right">
<span class="label label-success">priusa2</span>
</div>
<div class="pull-right" style="padding-right: 7px;">
<span class="label label-success status"></span>
</div>
<p></p>
</div>
<!-- panel-heading closed -->
<div class="panel-body">
<div class="container-fluidrm">
No-picture
</div>
</div>
<!-- panel-body closed -->
<div class="panel-footer">
<div class="row" style="height: 100%;">
<div class="col-md-9">
<p>Description:</p>
</div>
<div class="col-md-1">
<a class="show-popup" href="#" id="poplink" data-showpopup="ChartLine 1"><span id="logos" class="material-icons"></span></a>
</div>
<div class="col-md-1" style="margin-left:7px;">
<span id="logos" class="glyphicon glyphicon-star"></span>
</div>
</div>
</div>
<!-- panel-footer closed -->
</div>
</div>
Flexible box approach
Give the child item flex: 1 to expand with the parent element.
Updated Bootply
#crud1 {
display: flex; /* Activate flexbox module layout */
flex-direction: column; /* Align items horizontally */
}
.panel-footer {
flex: 1; /* Expand with the parent */
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-md-4">
<div id="crud1" class="panel panel-primary" style="height: 248px;">
<div class="panel-heading clearfix">
<div class="pull-left">
ChartLine 1
</div>
<div class="pull-right">
<span class="label label-success">priusa2</span>
</div>
<div class="pull-right" style="padding-right: 7px;">
<span class="label label-success status"></span>
</div>
<p></p>
</div>
<!-- panel-heading closed -->
<div class="panel-body">
<div class="container-fluidrm">
No-picture
</div>
</div>
<!-- panel-body closed -->
<div class="panel-footer">
<div class="row" style="height: 100%;">
<div class="col-md-9">
<p>Description:</p>
</div>
<div class="col-md-1">
<a class="show-popup" href="#" id="poplink" data-showpopup="ChartLine 1"><span id="logos" class="material-icons"></span></a>
</div>
<div class="col-md-1" style="margin-left:7px;">
<span id="logos" class="glyphicon glyphicon-star"></span>
</div>
</div>
</div>
<!-- panel-footer closed -->
</div>
</div>