Is it possible to specify 16 colums to bootstrap 3 - grid

I'm a bit confused. I'm tying to adapt the boostrap 3 grid to 16 column.
I'm changing these vars in my variable.less:
#grid-columns: 16;
#gridColumnWidth: 32px;
#gridGutterWidth: 30px
But still when I inspect my col-lg-12 class, it has a 100% width.

The number of columns is hard coded into the .less file. #grid-columns is only used to calculate the widths.
Bootstrap source code:
https://github.com/twbs/bootstrap/blob/master/less/grid.less#L74
Apparently changing the number of columns will possibly be added to version 3.1.
https://github.com/twbs/bootstrap/issues/9436#issuecomment-22849238

Add this grid generator as *.less file
/**
GRID GENERATOR
.grid-generator(16,20px,'mycol','myrow');
generate 16-column grid with 20px-gutter
ROW
.myrow{...}
COLUMNS
.mycol-1{...} ... .mycol-16{...}
OFFSETS
.mycol-offset-1{...} ... .mycol-offset-15{...}
PULLS
.mycol-pull-0{...} ... .mycol-pull-15{...}
PUSHS
.mycol-push-0{...} ... .mycol-push-15{...}
or for Bootstrap 3
standard bootstrap-3 grid
.grid-generator-responsive();
16-column bootstrap-3 grid with 20px gutter
.grid-generator-responsive(16, 20px);
#author: arthur.creek#gmail.com
*/
.grid-generator(#cols: 12, #gutter: 30px, #col-name: 'col', #row-name: 'row', #offsets: true, #ordering: true){
// row container
.init-row() when (#row-name > '') {
#name: ~".#{row-name}";
#{name}{
margin-left: (#gutter / -2);
margin-right: (#gutter / -2);
&:before,&:after{
content: " ";
display: table;
}
&:after{
clear: both;
}
}
}
.init-row();
// common properties
.properties(#index) when (#index = #cols)
{
#name: ~".#{col-name}-#{index}";
.properties(#index - 1, #name);
}
.properties(#index, #names) when (#index > 0)
{
#name: ~".#{col-name}-#{index}";
.properties(#index - 1, ~"#{names}, #{name}");
}
.properties(#index, #names) when (#index = 0)
{
#{names}
{
position: relative;
min-height: 1px;
padding-left: (#gutter / 2);
padding-right: (#gutter / 2);
float: left;
}
}
.properties(#cols);
// unfloat for full width
#lname: ~".#{col-name}-#{cols}";
#{lname} {
float: none;
}
// WIDTH of columns
.width(#index) when (#index > 0)
{
#name: ~".#{col-name}-#{index}";
#{name}
{
width: (100% / #cols * #index);
}
.width(#index - 1);
}
.width(#cols);
// OFFSET
.offset(#index) when (#index > 0) and (#offsets)
{
#name: ~".#{col-name}-offset-#{index}";
#{name}
{
margin-left: (100% / #cols * #index);
}
.offset(#index - 1);
}
.offset(#index) when (#index = 0) and (#offsets)
{
#name: ~".#{col-name}-offset-#{index}";
#{name}
{
margin-left: 0;
}
}
.offset(#cols - 1);
// PUSH
.push(#index) when (#index > 0) and (#ordering)
{
#name: ~".#{col-name}-push-#{index}";
#{name}
{
left: (100% / #cols * #index);
}
.push(#index - 1);
}
.push(#index) when (#index = 0) and (#ordering)
{
#name: ~".#{col-name}-push-#{index}";
#{name}
{
left: auto;
}
}
.push(#cols - 1);
// PULL
.pull(#index) when (#index > 0) and (#ordering)
{
#name: ~".#{col-name}-pull-#{index}";
#{name}
{
right: (100% / #cols * #index);
}
.pull(#index - 1);
}
.pull(#index) when (#index = 0) and (#ordering)
{
#name: ~".#{col-name}-pull-#{index}";
#{name}
{
right: auto;
}
}
.pull(#cols - 1);
}
// standard bootstrap-3 grid
// .grid-generator-responsive();
// 16-column bootstrap-3 grid with 20px gutter
// .grid-generator-responsive(16, 20px);
.grid-generator-responsive(#cols: 12, #gutter: 30px, #col-name: 'col', #row-name: 'row'){
// XS
.grid-generator(#cols, #gutter, ~"#{col-name}-xs", #row-name, false, false);
// SM
#media (min-width: 768px) {
.grid-generator(#cols, #gutter, ~"#{col-name}-sm", '');
}
// MD
#media (min-width: 992px) {
.grid-generator(#cols, #gutter, ~"#{col-name}-md", '');
}
// MD only
#media (min-width: 1200px){
.grid-generator(#cols, #gutter, ~"#{col-name}-lg", '');
}
}
and add less code
.grid-generator-responsive(16, 30px, 'col', 'row');
or using default
.grid-generator-responsive(16);
It will generate 16-column bootstrap grid with 30px gutter

It's possible to achieve more than 12 columns by nesting a grid within a column. I have experimented with this and came up with this sample code.
<body>
<div class="container">
<div class="row">
<div class="col-md-9">Nullam vehicula magna eget egestas vestibulum. Fusce sagittis vitae enim a interdum. Cras a augue placerat, laoreet nulla vel, posuere quam. Vivamus suscipit, justo at iaculis vulputate, felis ex placerat magna, at tincidunt ligula metus non ligula. Ut maximus neque quis diam aliquam, eget efficitur mauris cursus. Phasellus ultrices dui vitae porttitor fermentum. Mauris id hendrerit felis, nec pellentesque diam. Nullam pellentesque scelerisque orci eget elementum. Phasellus eget risus rhoncus, facilisis nunc sit amet, fringilla mauris. Nunc vitae ultricies nisi, at pretium tortor. Vestibulum vulputate nibh ex, vitae placerat nisi consectetur nec. Maecenas fringilla in eros nec varius. Nam at dolor finibus, porttitor quam nec, consectetur dui. Nulla rhoncus sit amet magna sed condimentum.</div>
<div class="col-md-3">Proin suscipit et urna sit amet ultrices. Morbi et tincidunt augue. Mauris ornare commodo urna quis sagittis. Phasellus egestas vehicula ex et fringilla. Curabitur tristique ultrices massa. Quisque nisl enim, malesuada eget purus id, luctus facilisis libero. Praesent ut nisl ligula. Maecenas augue velit, gravida id enim eu, feugiat laoreet orci.</div>
</div>
<div class="row">
<div class="col-md-12">Sed a dignissim mauris, eget accumsan nunc. Nullam facilisis magna orci, vel volutpat justo accumsan vitae. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eleifend nisi ut purus volutpat varius. Integer volutpat erat vitae imperdiet feugiat. Nullam nec luctus mi. Donec accumsan lacus mi, a aliquam elit pretium sit amet. Aenean laoreet fermentum tempor. Phasellus sagittis dui ornare, varius nisl ut, bibendum urna.</div>
</div>
<div class="row">
<div class="col-md-9">
<div class="row"> <!-- Row nested inside a column -->
<div class="col-md-2">Proin viverra porta orci, et lacinia nisl tempus vitae. Nam a pharetra massa.</div>
<div class="col-md-2 col-md-offset-1">In sed vestibulum risus, ut malesuada nisl. Nulla cursus, enim in pretium euismod, orci est consectetur lorem, ut posuere nunc nisi vitae tellus.</div>
<div class="col-md-2">In sed vestibulum risus, ut malesuada nisl. Nulla cursus, enim in pretium euismod, orci est consectetur lorem, ut posuere nunc nisi vitae tellus.</div>
<div class="col-md-2">In sed vestibulum risus, ut malesuada nisl. Nulla cursus, enim in pretium euismod, orci est consectetur lorem, ut posuere nunc nisi vitae tellus.</div>
<div class="col-md-2 col-md-offset-1">Proin viverra porta orci, et lacinia nisl tempus vitae. Nam a pharetra massa.</div>
</div>
</div>
<div class="col-md-2 col-md-offset-1">Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <!-- Latest compiled and minified JavaScript -->
</body>

Related

How do you get a div to hide/scroll overflow and scale to the viewport with consistent margins?

(EDIT: my current code added to bottom of post)
I need to set a value for the height of the div in order for it to hide/scroll overflow properly, but I don't want a div at a specific pixel height. I can solve that by using % or vh units, but I don't actually want to use those units. By that, I mean I don't want my div to always be, for example, 2/3 of the page, because that means the bottom of the div will be a different distance from the bottom of the browser window, like this-
* {
padding: 0;
margin: 0;
}
html, body {
width: 100%;
height: 100%;
}
body > div {
width: 90%;
height: 90%;
background: yellow;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style2.css">
</head>
<body>
<div>
</div>
</body>
</html>
-I want it to be a consistent distance from the bottom of the browser window,
like this-
html, body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
div {
background-color: yellow;
width: 350px;
position: fixed;
left: 10px;
top: 10px;
right: 10px;
bottom: 10px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style2.css">
</head>
<body>
<div>
</div>
</body>
</html>
(for visual representation primarily, I am not really using the code itself as an example)
Basically, I want my div to be a variable height and hide/scroll overflow, but always 10px from the bottom.
I think these describe the same problem I'm having:
Setting a length (height or width) for one element minus the variable length of another, i.e. calc(x - y), where y is unknown
Getting a scrollable child div to Vertically fill the remainder of its parent dynamically
The answers there are to use tables or flexbox - are these the only options (without using javascript)?
My code:
* {
margin: 0;
padding: 0;
}
body {
font-family: Helvetica, Arial, sans-serif;
overflow-x: hidden;
overflow-y: hidden;
width: 100%;
height: 100%;
}
p {
font-size: 9pt;
}
a {
text-decoration: none;
color: black;
}
.container { /*this contains all the divs!!*/
padding: 10px;
}
.header {
}
.name {
float: left;
width: 25vw;
padding-right: 5vw;
}
.about {
width: 65vw;
}
.main { /*this contains divs 'left' and 'right'*/
/*background-color: #CCCCCC;*/
clear: left;
padding-top: 10px;
width: 95vw;
}
.left {
/*background-color: #E6E6E6;*/
float: left;
min-height: 10px;
width: 25vw;
padding-right: 5vw;
}
.hold { /*this is how i tried your solution*/
position: relative;
height: calc(95vh - 10px);
}
.right { /*this is my problem div*/
background-color: #FFFF00;
width: 65vw;
height: 100%;
overflow-y: hidden;
overflow-x: hidden;
}
.lorem {
margin-right: 20vw;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> Name </title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="header">
<div class="name">
<p> Name </p>
</div> <!-- end div name -->
<div class="about">
<p> about </p>
</div> <!-- end div name -->
</div> <!-- end div header -->
<div class="main">
<div class="left">
</div> <!-- end div left -->
<div class="hold">
<div class="right">
<div class="lorem">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam feugiat facilisis purus at fermentum. Etiam ultricies iaculis nulla maximus cursus. Maecenas justo nulla, suscipit a dapibus at, lobortis nec mauris. Mauris egestas mi sit amet risus convallis, in hendrerit lorem maximus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse sollicitudin tempor libero, nec molestie dui tempor sit amet. Aenean molestie ex id nisl venenatis, quis tincidunt lectus porta. Vivamus aliquam lobortis nulla, id porta leo consequat sollicitudin. Ut iaculis neque placerat ipsum placerat tincidunt.
Quisque libero sem, hendrerit quis urna sit amet, mollis venenatis nisl. Morbi vel neque rhoncus, congue purus ac, condimentum nunc. Morbi vestibulum metus nec velit eleifend, ac sodales nulla posuere. Praesent id fermentum massa. Morbi vestibulum lorem nulla, ac vestibulum nunc auctor non. Donec ultricies placerat mauris, at pretium nibh finibus eu. Suspendisse gravida neque nisl, sit amet bibendum ante placerat eget. Sed laoreet suscipit turpis vitae ullamcorper. Mauris quis pharetra eros. Curabitur quis diam non dui elementum facilisis vel ac sem. Duis vitae augue vitae mi pulvinar placerat ut quis purus. Donec sagittis maximus aliquam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Phasellus pharetra nisi arcu, in laoreet lacus convallis sed. Nam euismod ligula felis, ut laoreet nisl sodales eget. Maecenas cursus, augue vitae suscipit laoreet, purus magna bibendum tellus, sed maximus ex dui ac velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla eget aliquet tellus, in viverra sapien. Sed eget urna mauris. Morbi dapibus dolor et felis viverra condimentum sed a nisl. Integer congue cursus ultrices. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse nulla risus, pulvinar eget odio vitae, scelerisque cursus magna. Nam maximus eros vitae massa euismod, vel tempus felis vulputate.
Nunc blandit massa a nisl viverra, vitae molestie ex rhoncus. Pellentesque finibus luctus nisi. Sed quis luctus metus. Nullam sed augue ultrices, lacinia dolor ac, egestas ante. In non nisi nibh. Sed vitae dui libero. Duis ut ullamcorper urna. Phasellus quis fringilla leo.
Nulla porta tellus ut nibh pharetra dapibus. Mauris ullamcorper egestas aliquam. Cras posuere scelerisque imperdiet. In ultrices, leo eu molestie bibendum, augue dui semper ante, vel faucibus nibh enim sed eros. Mauris ipsum dui, placerat et tincidunt vitae, laoreet vel enim. Praesent at ligula et neque placerat blandit sed vulputate ipsum. Phasellus sodales, odio nec aliquam pretium, augue lacus mattis quam, nec vulputate purus lorem vitae nisi.
Suspendisse nisl ipsum, volutpat ac dapibus at, tincidunt eget nulla. Mauris ornare a nisi ac fringilla. Maecenas leo sapien, vulputate in dictum a, feugiat in eros. Aliquam sit amet sagittis leo. Mauris metus nisl, convallis eget mollis ut, ullamcorper eu tellus. Pellentesque eu dolor tempor, bibendum leo vitae, maximus velit. Aenean volutpat neque sit amet tellus mattis euismod.
Quisque nec vehicula orci. Curabitur varius fringilla risus, convallis tincidunt velit porttitor vitae. Aenean in lacus nec nunc tempor dignissim nec pretium sem. Nullam finibus odio quis metus ornare, in fermentum elit rutrum. Proin vitae dui in metus vehicula sodales. Donec massa neque, suscipit ac est quis, ultrices auctor risus. Cras eu auctor lectus. Nam sagittis vulputate hendrerit. Maecenas consequat odio justo, at malesuada nulla ullamcorper a. Donec arcu tellus, dignissim ut velit vel, consequat scelerisque dolor. Curabitur dictum vel risus quis consequat.
Pellentesque fringilla eu nisi sed tincidunt. Nulla feugiat sit amet purus sit amet cursus. Suspendisse nibh purus, tincidunt eu congue ut, ultricies id lectus. Phasellus convallis in nibh vel molestie. Nunc condimentum congue justo. In congue, turpis at vulputate imperdiet, dolor erat ultricies turpis, vitae egestas est augue in nisl. Ut ut leo diam. Duis vulputate ligula velit, vitae volutpat felis viverra a. Maecenas justo quam, lobortis a placerat ut, ullamcorper ac lorem. Sed eu vehicula odio.
Fusce id mauris ornare, mollis mi at, vulputate turpis. Praesent a risus feugiat, rutrum lacus nec, sodales nisi. Nulla ullamcorper libero pretium lacus accumsan, eu tempor mi porta. In tincidunt porta feugiat. Cras lectus arcu, convallis nec neque ac, vestibulum pretium ex. Curabitur mi ipsum, commodo ut eros eget, fringilla fringilla tortor. Curabitur maximus tellus ut turpis malesuada, auctor semper lectus porta. Suspendisse non sapien sagittis, dapibus tellus et, egestas quam. Aliquam vitae massa sit amet urna rhoncus rutrum sit amet et lorem. Phasellus gravida justo ut vulputate vestibulum.
Nunc sed tempus metus, sit amet volutpat mi. Quisque sed metus rutrum, iaculis enim sed, sodales lacus. Quisque quis mi ac sapien scelerisque efficitur lacinia et nunc. Proin tincidunt scelerisque turpis, non euismod ante interdum at. Sed vitae velit scelerisque, placerat nulla in, egestas justo. Mauris urna orci, pulvinar a nibh a, luctus pellentesque mauris. Nulla faucibus hendrerit urna non venenatis. Quisque nulla mi, suscipit sit amet nunc eu, dictum ullamcorper tellus. Donec lacus libero, commodo quis mauris pellentesque, feugiat iaculis nisl. Nulla facilisi. Suspendisse sed risus quis risus fringilla condimentum. Aenean aliquet in eros vel volutpat. Vivamus malesuada ultrices lorem sit amet feugiat. In interdum leo ac orci sollicitudin, maximus vestibulum nisl gravida. Sed venenatis pharetra fringilla. Etiam mauris risus, cursus et est tristique, mattis venenatis nisi.
</p>
</div> <!-- end div LOREM -->
</div> <!-- end div main -->
</div> <!-- end div hold -->
</div> <!-- end div container -->
</body>
</html>
You're on the right track! You can combine vh with calc to get the desired effect.
height: calc(100vh - 10px) - assuming the element is positioned at the top of the screen, that'll achieve the effect you're describing.
To handle scroll/overflow, you'll need an inner container - a div inside the one you set the height property on. Give that inner div { height: 100%; overflow: auto; } and you should be all set.
Here's a demo - to see it working, use the full screen view and shrink your browser's height.
/* These styles are just to make this easier to see,
and to normalize the display a little. */
* { box-sizing: border-box; margin: 0; padding: 0; }
.page { width: 100px; border: 2px solid; }
/* Here's the box that locks to some distance from the bottom, in this case 30px */
.outer {
height: calc(100vh - 30px);
position: relative;
border: 1px solid blue;
}
/* And here's the scrollable container inside it */
.inner {
height: 100%;
overflow: auto;
}
<div class="page">
<div class="outer">
<div class="inner">
content content content content
content content content content
content content content content
</div>
</div>
</div>

Insert column break in css3 column

Is there a way to insert a column break in HTML content using CSS column style, like <hr>, <br> or something else?
E.g. you have heading than paragraph than heading than paragraph than heading than paragraph etc, and you want to insert a break at some point after a paragraph, so the column flow stops there and the continuation flows to the next column.
section {
columns: 2;
column-rule: 1pt dashed #ECEEF2;
column-fill: auto;
break-inside: avoid; //* this one is done for design purposes, I don't want a css way of column break. */
column-width: 280px;
column-gap: 40px;
}
<section>
<h2>text</h2>
<p>text<p>
<p>text<p>
<h2>text</h2>
<p>text<p>
<p>text<p>
<h2>text</h2>
<p>text<p>
<p>text<p>
<!-- insert column break here, like you can do in word processor -->
<h2>text</h2>
<p>text<p>
<p>text<p>
</section>
The way to break columns is to wrap the elements with a block element, here done with a div
I also removed the margins since they affect how that break renders
section {
-webkit-columns: 2;
-moz-columns: 2;
columns: 2;
width: 100%;
}
section * {
margin: 0;
}
section div {
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
}
<section>
<div>
<h2>text1</h2>
<p>text1</p>
<p>text1</p>
<h2>text2</h2>
<p>text2</p>
<p>text2</p>
<h2>text3</h2>
<p>text3</p>
<p>text3</p>
</div>
<div>
<h2>text4</h2>
<p>text4</p>
<p>text4</p>
</div>
</section>
Another way is to use a small script, here done with a simple comment as a break marker
window.addEventListener("load", function() {
var div = document.querySelector('section');
div.innerHTML = '<div>' + div.innerHTML.replace(/<!-- break -->/g, '</div><div>') + '</div>';
});
section {
-webkit-columns: 2;
-moz-columns: 2;
columns: 2;
width: 100%;
}
section * {
margin: 0;
}
section div {
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
}
<section>
<h2>text1</h2>
<p>text1</p>
<p>text1</p>
<h2>text2</h2>
<p>text2</p>
<p>text2</p>
<h2>text3</h2>
<p>text3</p>
<p>text3</p>
<!-- break -->
<h2>text4</h2>
<p>text4</p>
<p>text4</p>
</section>
Here is a few more samples of mine, doing this using a script
Take control of text styled with css columns attribute
Updated based on a comment
Sometimes one need to combine CSS columns with some other technique, i.e. CSS Flexbox
section {
display: flex;
}
section * {
margin: 0;
}
section .columns {
-webkit-columns: 2;
-moz-columns: 2;
columns: 2;
flex: 2;
}
section .columns {
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
}
section div:not(.columns) {
flex: 1;
}
<section>
<div class="columns">
<h2>Etiam euismod risus ut augue egestas</h2>
<p>Etiam euismod risus ut augue egestas, eget egestas orci efficitur. Nulla at neque et nunc viverra bibendum. Vivamus tincidunt non urna et blandit. Donec nec posuere erat. Nullam consequat velit in rhoncus hendrerit. Vestibulum eu molestie justo. Aenean
mollis dui eget odio blandit, et tempus ligula eleifend. Sed molestie lorem mi, ac condimentum nisi elementum a. Morbi purus dui, hendrerit quis convallis porta, finibus et mi. Maecenas enim tellus, commodo eget tristique quis, elementum quis odio.
Donec nisl urna, aliquam in dui ut, fermentum tristique leo. In viverra venenatis tortor id condimentum. Fusce sed velit ornare, aliquam ante blandit, suscipit purus.</p>
<p>Vivamus non arcu gravida, dignissim orci quis, condimentum metus. Quisque vel orci sollicitudin, sodales arcu sollicitudin, convallis elit. Cras tempor mi id arcu faucibus gravida. Vivamus ac porta tellus. Mauris at sollicitudin leo. Curabitur ultricies
sollicitudin ultricies. Donec condimentum nibh in elementum auctor. Praesent aliquam pharetra ex a pulvinar. Duis vel tincidunt elit. Aenean sem est, bibendum nec euismod quis, egestas a ante. Sed porttitor nulla eget ex accumsan, ac efficitur risus
feugiat. Nulla tempus imperdiet urna eget accumsan. Aenean at ante et sapien vulputate vehicula sodales sit amet est. Sed non ex orci. Nunc diam diam, commodo vitae tempor id, feugiat ultrices risus. In pharetra semper augue ut volutpat.</p>
</div>
<div>
<h2>Lorem ipsum</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vel luctus lectus, tincidunt congue quam. Vestibulum ipsum turpis, dictum in arcu quis, maximus volutpat enim. Mauris eu leo et libero dignissim tempus at id nisi. Nulla tincidunt ut
sapien et porta. Vestibulum non mauris at leo semper molestie quis vel justo. Duis sed neque odio. Sed eget sem ut sapien rhoncus tempus. Mauris maximus diam a nibh scelerisque, in finibus neque pellentesque.</p>
</div>
</section>
To insert a column break inside an element with a css property columns, you need to insert any element with css property column-break-before:always;
It will force the text and other elements to break at that point and continue in following column. I noticed that we cannot do this with <br> but with <hr> it is again possible. For <hr> one might like to hide borders.

Can't get a sticky footer working for the life of me

I've tried every CSS-only implementation of sticky footers that exist on the internet it seems, and for the life of me I cannot figure out why it's not working for me.
The problem code is here: https://jsfiddle.net/7ck2xk2p/1/
So the problem is footer is still just sitting under the content, and is not stuck to the bottom of the page.
As you might be able to see, my most recent attempt was the technique detailed here by Ryan Fait
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important; /* This line and the next line are not necessary unless you need IE6 support */
height: 100%;
margin: 0 auto -155px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
height: 155px; /* .push must be the same height as .footer */
}
I am very new, so if things are messy in that fiddle please excuse me. The relevant details should still be distinguishable though.
What am I doing wrong?
you can use this approach for sticky footer (CSS only)
html,
body {
height: 100%;
margin: 0;
}
div {
min-height: 100%;
/* equal to footer height */
margin-bottom: -70px
}
div:after {
content: "";
display: block
}
footer,
div:after {
height: 70px
}
footer {
background: green
}
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi dictum vel dolor vel commodo. Nam id nisi eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi commodo leo ac enim molestie, vitae sodales
dolor consequat. Donec imperdiet orci at luctus lacinia. Donec bibendum velit sed risus eleifend ultricies. Sed nisl massa, ornare quis augue et, faucibus feugiat sapien. Vestibulum pharetra tempor quam eu congue. Proin posuere lorem quis nisl efficitur
aliquam. Curabitur elit ex, convallis sed fringilla a, varius quis dui. Nullam eget est sed orci imperdiet imperdiet sit amet eget dui. Integer egestas nisi a sagittis rutrum. Quisque id convallis nisl, at blandit nunc. Curabitur elementum viverra tristique.
In auctor pretium mattis. Fusce vulputate porta lacus tincidunt rhoncus. Aenean dapibus tortor non faucibus laoreet. Morbi fringilla leo nisl, imperdiet hendrerit elit semper at. Donec suscipit orci in nulla viverra ultrices. Donec aliquet risus non
libero viverra, sed aliquam massa congue. Aliquam suscipit ullamcorper erat sed vehicula. Donec elementum tincidunt dolor, non scelerisque dolor pretium ut. Praesent vitae porttitor turpis, et pharetra libero. Sed imperdiet tempor facilisis. Cras eget
vehicula dolor.
</div>
<footer>
Sticky Footer.
</footer>

bootstrap equal height divs (Responsive Design)

I have a side-bar div that will have ads. It should have a fixed width of about 333px and need it to be responsive is possible in its height.
It has a background but when content loads in the main div the side-bar div will not extend the length of the main content. I have tried a few things but get varied results in different browsers.
When in the mobile view or when it's in a small view the side bar should fit to the size of the window width wise and only be has high as the content in the side-bar.
I have loaded a few images for examples to show what I need.
Below is the ccs I have
.main
{
padding: 20px;
}
.side-bar
{
background-image: url('../images/BlueBG.jpg');
width: 333px;
display: block;
height: 100%;
}
This has been asked a few times on SO, but you can use flexbox for this. If you are using bootstrap, you most likely will have a container-fluid class. Simply set the display to flex and all the items inside will become flex-items. This will allow you to have them stretch. In your case, you will have to set container-fluid back to block or set your main and side-bar to flex-basis:100% in a media query for your mobile.
Here's the fiddle: http://jsfiddle.net/56we9rmj/2/
HTML
<div class="container-fluid">
<div class="main"><p>Arcu dictumst nec ultricies aptent rhoncus. Sed fermentum ligula. Donec vitae felis. Lectus nec ad. Tempus et quam. Nec dolor eu. Lacus at in eu dolor penatibus. Quis vivamus vehicula. Mauris dui ullamcorper diam eget pretium lectus consectetuer ultrices tincidunt sit nulla. Lobortis lacus et. Dolor ea placerat etiam diam aenean integer nec erat. Suscipit ut elementum. Consectetuer dui id vestibulum cras egestas. Quis nulla nulla. Pariatur pellentesque amet taciti neque lorem fermentum vehicula amet elit blandit pellentesque. Cras sit gravida. Cras vulputate curabitur mauris purus semper mauris lacus et et pulvinar in justo nullam qui sed quam massa. Integer amet ullamcorper. Feugiat quis sed quam fusce non feugiat amet vitae. Arcu elementum eget justo ac sed quis id tellus.</p>
<p>Vivamus non cras. Turpis in eleifend mattis nam arcu aliquam vulputate felis. Dignissim ligula dignissim habitant nonummy proin. Mauris varius varius. Purus lorem ullamcorper dictum cras in felis ullamcorper vitae. Nunc amet interdum nec adipiscing tempus ac vestibulum primis. Nisl purus orci sed sunt mauris. Odio donec nulla. Pellentesque arcu felis. Et varius ornare eros id quisque. Vel dui velit arcu eget in dignissim nunc nec habitasse habitasse elit quis ac aptent duis volutpat facilisis varius ut sem consectetuer erat arcu. Mauris condimentum sodales luctus a ullamcorper amet a pellentesque tellus ac sit. Nam mauris nulla neque aenean tempus. Mi dui ipsum. Laoreet vitae mauris. Arcu at tristique. Quia mi praesent nibh eu est. Dui libero condimentum elementum risus risus. Ut feugiat diam. Quam semper erat felis ultricies vel. Sed proin sollicitudin. Etiam eleifend morbi imperdiet purus pharetra. Vel diam feugiat. Vel volutpat vulputate. Enim ligula fringilla at nunc risus.</p>
</div>
<div class="side-bar">
<img src="http://placehold.it/300x100" />
<img src="http://placehold.it/300x100" />
</div>
</div>
CSS
.container-fluid {
display:flex;
align-items:stretch;
align-content:stretch;
}
.main {
flex-basis:66.66666667%;
padding:20px;
}
.side-bar {
background:red;
flex-basis:33.3333333%;
}
.side-bar img {
width:100%;
}
#media screen and (max-width:Mobile-PX-HERE) {
.container-fluid {
flex-wrap:wrap;
}
.main, .side-bar {
flex-basis:100%;
}
}
Hope that helps!
Giving position:absolute; and 100% height to the sidebar will do. http://jsfiddle.net/fdf01y4b/
Resize the window or add more text to see it in action
.side-bar {
height: 100%;
position: absolute;
top: 0;
right: 0;
}
If you have problems with the sidebar going out of the parent div, just give position:relative; to the parent wrapper like I did on the Jsfiddle example
<div class="wrapper">
<div class="main">Content</div>
<div class="side-bar">Sidebar</div>
</div>
.wrapper{
position:relative;
}
For smaller screens you can just remove the sidebar position:absolute; to position:initial; with media queries:
#media (max-width: 600px){
.side-bar{
position: initial;
}
}

Why css float does not work as expected

I have created 2 div one with float: left and one with float : right, each with 50% column width. Still they don't flow as expected. The second float not just on the right side of the first div but below the first div. Float doesn't behave according to the rule. So what rule am I missing here ?
<html>
<head>
<title>
</title>
<style type="text/css">
.column {
width: 50%;
}
div.right {
float: right;
}
}
div.left {
float: left;
}
img {
float: right;
margin: 0 0 1em 1em;
}
</style>
</head>
<body>
<div class='left column'>
<img src="css-float.png">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit.
</div>
<div class='right column'>
<img src="css-float.png">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit.
</div>
</body>
</html>
Your CSS is invalid, so stopping the rest of your stylesheet loading.
See here:
div.right {
float: right;
}
}
You are closing the rule twice, remove the second closing bracket
Fiddle
.column {
width: 49%;
}
div.left, div.right {
float: left;
border-right: 1px solid;
}
Reduce your width. You need side by side, So you add float left since both are under same container.
Demo.
.column {
width: 50%;
}
div.right {
float: right;
}
div.left {
float: left;
}
img {
float: right;
padding-right: 15px;
margin: 0 0 1em 1em;
}

Resources