Bootstrap 2 column 3 square layout doesn't fill page - html

I am having some issues with making my bootstrap layout fill the whole page. This is the jsbin for what I currently have: http://jsbin.com/tibusakuci/edit?html,css,output
I'm having trouble making the grid fill the entire page. I want it to look like this (filling the entire screen):
With it looking like this on mobile screens:
Does anyone have any ideas of why my code won't fill the whole screen when I take out the min-heights? Using bootstrap. Using height: 100% doesn't work either.
*Currently the boxes only fill half the screen
Thank you!

UPDATE: The follow code will fix your gutter issues. But it looks like your main issue is with the fluid container not filling the entire page.
CAUSE / SOLUTION: According to this github issue - Fluid Layout with 100% height #1671 - there is no "out of the box" solution. Try implementing one of the few solutions (with jsfiddle code) in that issue thread.
PREVIOUS ANSWER (partially obsolete)
Working jsbin: http://jsbin.com/rilihit/1/edit?html,css,output
STEPS
Remove the margin-bottom declaration from .row > div and from .sidebar-bottom.
Declare this css in your custom css file to remove the default bootstrap column gutter. This code is responsive and will work for all column sizes
.no-gutter > [class*='col-'] {
padding-right:0;
padding-left:0;
}
Finally, in your HTML, add the no-gutter to the rows like so.
Here's the complete HTML and CSS code. I modified your jsbin code and tested it. (I made the sidebar-bottom's min-height = 160px; so that the min-height values for the 2 add up to the min-height value for the content and nicely line up in desktop view. )
.row > div {
background-color: green;
}
.header,
.footer {
background: blue;
}
.content {
background: pink;
min-height: 300px;
}
.sidebar-top {
min-height: 140px;
background: yellow;
}
.sidebar-bottom {
min-height: 160px;
background: lightblue;
}
.no-gutter > [class*='col-'] {
padding-right: 0;
padding-left: 0;
}
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row no-gutter">
<div class="col-sm-7">
<div class="content"></div>
</div>
<div class="col-sm-5">
<div class="row no-gutter">
<div class="col-sm-12">
<div class="sidebar-top"></div>
</div>
</div>
<div class="row no-gutter">
<div class="col-sm-12">
<div class="sidebar-bottom"></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Related Reference / Reading: Bootstrap 3 Tips and Tricks You Still Might Not Know

Remove padding from the container-fluid and col-*. You can use vh for full hieght, and adjust this accordingly for 33% height on smaller screens.
.content {
background: pink;
min-height: 100vh;
}
.sidebar-top{
min-height: 50vh;
background: yellow;
}
.sidebar-bottom{
min-height: 50vh;
background: lightblue;
}
#media (max-width: 768px) {
.content,
.sidebar-top,
.sidebar-bottom {
min-height: 33vh;
}
}
.row.no-gutter {
margin-right:0;
margin-left:0;
}
.row.no-gutter > [class*='col-'],
.container-fluid {
padding-right:0;
padding-left:0;
}
Working demo: http://www.codeply.com/go/r3Rdffxi7A

remove padding and margin of surrounding, and remove the negative left and right shift.

Related

Scroll-chain containing to div without property in CSS on mobile

I'm having an issue, primarily on mobile devices (in my case, an iOS device) where a div is seemingly preventing scroll-chaining; this is problematic because it's the first place you would touch to scroll (as opposed to a smaller div above it). Similarly for scrolling back up. I couldn't find anything online stating that there was a parameter or property default to mobile webkit that would contain a div. It seems though maybe this is behavior on iOS webkit, as notably, a second swipe on the final image after the "bounce" of the scroll of the div returns to normal positioning in the div allows a scroll (sometimes seemingly inconsistently?)
I've managed to recreate the issue with a test with minimum code repeated from my project (view on mobile! overscroll works fine on desktop)
https://codepen.io/hennigarj/pen/ZEjYrpW
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Website</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<style>
#container {
display: block;
width: 100%;
height: 100%;
padding-top: 4vh;
}
.flex-items {
width: 100%;
overflow: auto;
}
.flex-items:nth-child(1) {
display: block;
height: 10vh;
}
.flex-items:nth-child(2) {
display: block;
margin-top: 4vh;
margin-bottom: 4vh;
height: 64vh;
text-align: center;
}
.flex-items img {
max-width: 100%;
}
.flex-items:nth-child(3) {
display: block;
padding-bottom: 6vh;
}
</style>
</head>
<body>
<div id="container">
<div class="flex-items">
Div 1
</div>
<div class="flex-items">
<section id="highlights">
<div class="highlight">
<img src="https://placehold.jp/400x536.png" />
</div>
<div class="highlight">
<img src="https://placehold.jp/400x536.png" />
</div>
<div class="highlight">
<img src="https://placehold.jp/400x536.png" />
</div>
</section>
</div>
<div class="flex-items">
Div 3
</div>
</div>
</body>
</html>
Anyone have any ideas? I've tried all sorts of overflows and overscroll-behaviors on everything but nothing seems to fix this, and there is no value to specifically enable scroll-chaining through overscroll.
This is probably clear as day and I'm completely missing it.
Thank you :)
I've tried various different potential heights, overscroll-behaviors, overflows on divs (to no success). Ideally, hitting the end of the div would continue the scroll-chain past it, just as it does on desktop, but it contains. I've tried -webkit-overflow-scroling: auto as well.

Height not actually changing hieght while floating

Right now I'm coding a menu that has a two column layout. This is the code.
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>replit</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="stockapps">
<img src="icons/eShop.svg">
<img src="icons/sverse.svg">
</div>
<div class="main">
<p>
Hello!
</p>
</div>
</body>
</html>
CSS:
.stockapps {
background-color: #111;
float: left;
width: 5%;
height: 100%;
}
.stockapps :after {
content: "";
display: table;
clear: both;
}
.stockapps img{
width:100%;
display: inline;
vertical-align: top;
}
.main {
float: left;
padding: 2%;
width: 91%;
overflow: hidden;
}
The issue is that the stockapps div tag is not filling the whole screen with height instead opting to only fill the area the children objects take up.
I have tried using the clear-fix and setting overflow to hidden but neither seem to fix the issue. Its likely some beginner mistake as CSS is not my strong suit
This fiddle showcases the issue.
You can wrap stockapps and main divs into a container div
Style this container as below
I used background color for stockapps div to show you its height
.container {
display: flex;
align-items: stretch;
/*Set height as you want, you can use height in px */
height: 100vh;
}
.stockapps {
/* used background-color to show you how much height it takes*/
background-color: #999;
/*You can ignore width if it's not convenient for your desired final output */
width: 50%
}
<div class="container">
<div class="stockapps">
<img src="icons/eShop.svg">
<img src="icons/sverse.svg">
</div>
<div class="main">
<p>
Hello!
</p>
</div>
</div>
If I understand you correctly, you need to create a 2-column layout for your menu.
To achieve this layout, I would wrap the <div class="stockapps"> and <div class="main"> into another <div> with class of manu-wrap and add this CSS styles:
.menu-wrap {
display: flex;
justify-content: space-between;
}
I would then remove the float properties and you should have a working 2-column layout.
You can find more about display: flex here.

100vh Not Tall Enough On Mobile

So, I'm trying to make a mobile version on my desktop site (Have a look here to see what I'm going for www.adamaucock.com).
The issue I'm having is that I can't seem to set the height correctly, in that my content is about half the page and then the rest is just dead space so the height is set too short for the window. Working with the body tag didn't work and I've seen people suggesting wrapper elements also but I can't seem to get that to work. I've tried using vh and %. I've also tried hiding the overflow for x and y separately and together on both elements to no avail.
The only thing that fixed the issue was setting the wrapper to be fixed but then the scrolling didn't work at all.
HTML:
<body>
<div id="wrapper">
<div class="box" id="welcome_box">
<div class="welcome_title">
<h2 id="video_head">Hi, I'm Adam.</h2>
<h1>And here I am testing this website.</h1>
<h3>Scroll to See More</h3>
</div>
</div>
</div>
CSS:
body {
background-color: #04244F;
font-family: raleway;
margin: 0;
padding: 0;}
#wrapper {
width: 500vw;
height: 100vh;
background-color: aqua;}
Any help would be much appreciated.
Thanks in advance.
So, I have just found a solution but I'm not sure how well it'll work across devices. I used the viewport meta tag to set the initial scale to .25 rather than 1 like so.
<meta name="viewport" content="width=device-width, initial-scale=.25">
On the two devices I have to hand (Google Pixel 1 and iPhone 4) it seems to work. Will update if I run into any problems with this approach.
overflow-y: hidden on the body/html should do the trick
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html,
body {
margin: 0;
padding: 0;
overflow-y: hidden;
}
body {
background-color: #04244F;
font-family: raleway;
}
#wrapper {
width: 500vw;
height: 100vh;
background-color: aqua;
}
h2 {
margin: 0;
}
</style>
</head>
<body>
<div id="wrapper">
<div class="box" id="welcome_box">
<div class="welcome_title">
<h2 id="video_head">Hi, I'm Adam.</h2>
<h1>And here I am testing this website.</h1>
<h3>Scroll to See More</h3>
</div>
</div>
</div>
</body>
</html>

Block overflowing parent block

I'm actually learning how to code with bootstrap and something pretty weird is happening to me.
I want to build a basic template with a title row and a middle row.
the middle row has to be grey on the background and white in the center (where the content is).
the middle row has a flex-grow so that the background colors are everywhere, no just depending of the content size.
But when this content is big, it overflows the row, and I can't figure out why.
This is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Potatoe Home</title>
<link rel="stylesheet" href="path/to/file/file.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body class = "container-fluid">
<div class = "row titleRow">
<div class = "col-sm-3">
</div>
<div class = "col-sm-6">
<div id="titleArea">
<h1 id="title">Potatoe</h1>
<p>blablabla</p>
</div>
</div>
<div class = "col-sm-3">
</div>
</div>
<div class = "row scndRow">
<div class = "col-sm-3">
</div>
<div class = "col-sm-6 middleColumn">
<div id="testBlock">
</div>
</div>
<div class = "col-sm-3">
</div>
</body>
</html>
my css:
h1[id=title]
{
font-size: 200%;
}
.titleRow
{
background-color: red;
color: white;
font-size: 200%;
}
.scndRow
{
flex-grow: 1;
display: flex;
background-color: #D0D0D0;
}
.middleColumn
{
background-color: white;
}
#testBlock
{
width: 20%;
height: 900px;
background-color: blue;
}
html, body
{
height: 100%;
}
body
{
display: flex;
flex-direction: column;
}
my display
thanks for your help
Okay problem solved:
I replaced the height: 100% by a min-height: 100% (for html and body)
when i set a height: 100%, chrome consider that i want it to be 100% of the viewport. when my testBlock is bigger, it should make the row bigger and so the body. so the body's height would be bigger than 100%. so it can't, and the testBlock overflow.
Thanks for your help :)
What about removing the flex properties to class scndRow ?
and set height:100% to element that have to be?
You have to specify it to scndRow which is wrapping the two other colunm classes AND to these columns.
.scndRow{
height:100%;
}
.scndRow .col-sm-3
{
/*flex-grow: 1;*/
/*display: flex;*/
min-height:100%;
background-color: #D0D0D0;
}
.middleColumn
{
min-height:100%;
background-color: white;
}
Just for the example, I added a jQuery function to make you see the effect of more content in the testBlock.
See it in updated Fiddle

Stretch Child DIV to Height of Parent (Without hardcoding height)

I have a parent DIV with a child DIV that I'd like to have stretch to the bottom of the parent. At present it does not despite having height:auto!important; A screenshot illustrating the issue can be seen here.
The relevant HTML (as a Jade template) is as follows:
.main.top0
.infoPanel.koneksa_bg_blue
.innerPanel.mtop0.mbottom0
.infoCaption.font8em.koneksa_white 404
.infoCaption.koneksa_white We can't find the page you are looking for
.infoCaption.koneksa_white
| Don't worry. Just try to go back or
a.koneksa_white.underline(href='/') home
.footer.stickyBottom.koneksa_bg_gray.koneksa_fg_light_gray
The main DIV is the parent and the infoPanel is the child (colored in blue in the image above) that I am struggling to stretch.
The corresponding CSS is as follows:
.main {
width:100%;
min-height:700px;
height:auto!important;
overflow: hidden;
z-index: 1;
top:3em;
position: relative;
}
.infoPanel {
width:100%;
height:auto!important;
display: block;
padding:0;
}
.innerPanel {
width:90%;
padding:40px 0;
height:auto!important;
margin:0 5%;
display: block;
}
I'm aware that this is a fairly common question but it seems like the answer is always to include a hard-coded height. I would like to avoid this because while that was a perfectly fine solution for the desktop styling this is intended to be displayed on mobile devices and as such I'd like it to be a bit more responsive than a hard-coded height.
Thanks for any insights that you can provide.
EDIT:
The generated HTML as requested:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html"></html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale = 0.8, user-scalable = yes">
// Imports removed
<link href="/assets/css/mvp.css" type="text/css" rel="stylesheet" media="screen and (max-width: 768px)">
<link href="/assets/css/mvp_wide.css" type="text/css" rel="stylesheet" media="screen and (min-width: 769px)">
</head>
<body class="tk-futura-pt koneksa_gray">
<div class="fullNav koneksa_bg_white boxShadow">
<div class="centerPanel">
<div class="mleft2 left khmoniker"></div>
<div class="menu right">customer login</div>
</div>
</div>
<div class="main top0">
<div class="infoPanel koneksa_bg_blue">
<div class="innerPanel mtop0 mbottom0">
<div class="infoCaption font8em koneksa_white">404</div>
<div class="infoCaption koneksa_white">We can't find the page you are looking for</div>
<div class="infoCaption koneksa_white">Don't worry. Just try to go back or home</div>
</div>
</div>
<div class="footer stickyBottom koneksa_bg_gray koneksa_fg_light_gray">
<div class="innerPanel">
<div class="caption left">
<h5 class="konekea_blue_gray mtop2">© template-filler</h5>
<div class="kh_reverse_logo mtop2"></div>
</div>
<div class="caption right">TermsPrivacyCorporate</div>
</div>
</div>
</div>
</body>
One solution that works in all modern browsers is to do the following:
html, body {
height: 100%
}
.main {
position: absolute;
top: 3em;
bottom: 0;
width: 100%;
}
This seems an unusual solution but modern browsers will actually respect all 4 sides being defined at the same time and stretch the element to match. Here is an example jsFiddle: http://jsfiddle.net/nqt7vqs1/2/
You can do the same with all child elements as well because position: absolute implies position: relative for the purposes of positioning child elements.
If this solution doesn't work, another option is to do the following:
html, body {
height: 100%
}
.main {
position: absolute;
top: 0;
height: 100%;
margin: 3em 0 -3em 0;
overflow: hidden;
}
This is a "hidden margin" trick that also works in all modern browsers. Same Fiddle with these settings: http://jsfiddle.net/nqt7vqs1/3/