Can't make zurb foundation columns stretch to bottom of page - html

I'm trying to make a three column layout that stretches to the bottom of the screen which uses the Zurb Foundation grid.
The basic structure involves three columns, each with a title in the center and a distinctive background image, and a footer.
This is what I'm trying to achieve (where the three colours would be background images):
The issue is that since there isn't enough content to fill the screen my columns don't stretch to the bottom. I've been able to fix the footer to the bottom of the page using this technique https://css-tricks.com/snippets/css/sticky-footer/.
But the result looks like this:
Here is my html:
<div id="content-wrapper">
<div class="row collapse">
<div class="small-centered large-uncentered large-4 columns episode">
<div class="episode-titles">
<h1>Column01</h1>
</div><!-- ends episode titles-->
</div><!-- ends episode-->
<div class="small-centered large-uncentered large-4 columns episode" >
<div class="episode-titles">
<h1>Column02</h1>
</div><!-- ends episode titles-->
</div><!-- ends columns-->
<div class="small-centered large-uncentered large-4 columns episode" style="background-image:url('{{ featured_image }}');">
<div class="episode-titles">
<h1>Column03</h1>
</div><!-- ends episode titles-->
</div><!-- ends columns-->
</div><!-- ends row collapse-->
</div>
and here is my css:
body, html {
height: 100%;
}
#content-wrapper {
min-height: 100%;
margin-bottom: -90px;
}
#footer, #content-wrapper:after {
height: 90px;
}
#content-wrapper:after {
content: "";
display: block;
}
#footer {
background-color: #161616;
border: none;
}
.episode {
max-width: 100%;
background-size: cover;
background-position: center center;
text-align: center;
height: 100%;
}
.episode-titles {
text-align: center;
display: inline-block;
vertical-align: middle;
}

Here is a fiddle for my approach:
JSFiddle
For the footer though, I just used position: fixed instead. The key thing is that you also need to specify height on the parent elements too, the content-wrapper, the row, etc.
The only caveat with the way I did it though, is that the row-footer div is position fixed and has a z-index of 1. So it is essentially hovering over the 3 columns. So that means if there does happen to be any content contained within these columns that nears the very bottom, there is a potential it can be covered.

Related

CSS - making left div go over right div as an overlay on small screens

I am using zurb foundation in my project and I have a layout with 2 divs in a row. One takes up 4 columns on the left and the other takes up 8 columns on the right. On the left I have some content and on the right I have an image that takes up the whole div.
I would like on small screens to have the content of the left div go on top of the image, like an overlay, instead of right div going below the left div. But I am not sure how and what is the best way to achieve that?
<div class="header row">
<div class="large-12 columns frontpage-header-content">
<div class="large-4 columns frontpage-header-content-div">
<div class="snirky-snark-box">
<h3>Vi arbeider med å bygge kompetanse, spre kunnskap og positiv energi</h3>
<div class="border"></div>
<div class="payment-box">
<label for="support" id="payment-input"><span>Gi et beløp</span>
<input type="text" id="support">
</label>
<button type="button" class="button button-full" id="payment-button">Støtt oss</button>
<div class="payment-methods">
<p><span><img id="vipps" src="<?php echo get_template_directory_uri(); ?>/assets/images/vipps.svg"></span><span>Bankkort</span><span>Sms</span><span>Faktura</span></p>
</div>
</div>
</div>
</div>
<div class="large-8 columns frontpage-header-image-div">
<div class="frontpage-bg-image-wrapper">
<div class="header-bg-image frontpage-header-hero"><img src="<?php echo get_template_directory_uri(); ?>/assets/images/sfk-bg.png"></div>
<div class="overlay"></div>
</div>
</div>
</div>
<?php get_template_part('title-bar'); ?>
</div><!-- /.header -->
<div class="promo row">
</div>
I have managed to achieve with a following css that a left div goes over the right one as an overlay, but I have a problem with a promo row, since now the content of the promo row goes over the header as well, how can I push the promo row to go below the header?
#include breakpoint(medium down) {
.frontpage-header-image, .frontpage-bg-image-wrapper {
width: 100%;
}
.frontpage-header-content, .singlepage-header-content {
padding-top: 84px!important;
position: relative;
}
.frontpage-header-content-div, .frontpage-header-image-div {
position: absolute;
top: 84px;
padding: 0;
}
.snirky-snark-box {
position: absolute;
top: 22%;
width: 100%;
padding-left: 30px;
padding-right: 30px;
h3 {
width: 200px;
font-size: 24px;
}
}
.snirky-snark-box .payment-box {
padding: 0;
}
.payment-methods, .border {
display: none!important;
}
.header > .columns {
padding: 0;
}
}
Rather than moving the divs around; how about duplicating the image as a background?
Add the class show-for-medium to .frontpage-header-image-div, this only shows the div if screen size > medium (docs) and add something like this in your (s)css:
.frontpage-header-content {
#include breakpoint(medium down) {
background-image: url([your image url]);
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
background-attachment: fixed;
background-repeat: no-repeat;
}
}
(N.B. As you are using Foundation's SASS version, you don't need all the prefixes, they are added for you when it builds)
So for medium + screens you get the two divs side by side with the image on the left, but for small you only get the first div, but now it has a background image.
Here's a basic JSFiddle, you'd need to tweak it to your image though.
Try making the right column absolute and stick it to the right side, while giving it a lower z-index than the left column:
.snirky-snark-box{z-index:2;}
.frontpage-bg-image-wrapper{position:absolute; right:0; z-index:1;}
This should work. If it doesn't, please post a working snippet of your code (including CSS).

How to setup a master-detail page with Bootstrap?

I'm having trouble setting up a "master-detail" view using Bootstrap 3. I'm attaching a picture of the specific layout I'm trying to get:
I've created a div with .row spanning the 12 columns for the header, and then another div.row with a div.col-md-4 and div.col-md-8 for the two columns. But obviously this doesn't achieve what I'm looking for. I've tried playing with the position attribute, but it seems to conflict with the Bootstrap CSS and I always just get jumbled text.
Thank you very much in advance and let me know if you'd like me to provide more details on what I'm looking for. Hopefully the pic is clear.
You are looking for
position: fixed;
This ensures that the element is always static relative to the viewport. You will then use the relative positioning properties to place it where you want it to go.
For the top element (say, your navbar), you can set:
top: 0;
For the bottom element, you can set:
bottom: 0;
So, something like this:
.row, .col-md-4, .col-md-8 {
border: 2px solid pink; /* For showing the div borders */
}
.row.main-content {
background-color: blue;
height: 300px;
margin-top: 20px; /* Needs to match the height of .row.top */
}
.row.top {
position: fixed;
top: 0;
height: 20px;
width: 100%;
background-color: red;
z-index: 9999;
}
.row.bottom {
position: fixed;
bottom: 0;
height: 20px;
width: 100%;
background-color: green;
z-index: 9999;
}
.scrollable {
overflow-y: scroll;
height: 300px; /* May need to be set somehow */
}
<div class="container-fluid"><!-- To get it to take up the whole width -->
<div class="row top">
</div><!-- row -->
<div class="row main-content">
<div class="col-md-4">
<div class="sub-header">
</div>
<div class="scrollable">
<!-- menu items here -->
</div>
<div class="sub-footer">
</div>
</div>
<div class="col-md-8 scrollable">
<!-- Product detail goes here -->
</div>
</div><!-- row -->
<div class="row bottom">
</div><!-- row bottom -->
</div><!-- container-fluid -->
Hope that helps.

CSS float alignment uneven on wide screens

On wider screen resolutions the gap in-between widget areas 2&3 is obviously greater then the gap between widget area 1&2 making the 3 areas together look uneven.
.footer-widgets-1,
.footer-widgets-2,
.footer-widgets-3 {
width: 332px;
}
.footer-widgets-1 {
margin-right: 36px;
}
.footer-widgets-1,
.footer-widgets-2 {
float: left;
}
.footer-widgets-3 {
float: right;
}
Is there a way to ensure even spacing between all 3 when using float: left on & a single float:right?
<div class="widget-group">
<div class="footer-widgets-1">
</div>
<div class="footer-widgets-2">
</div>
<div class="footer-widgets-3">
</div>
</div>
.widget-group
{
width: 1068px;
margin: 0 auto;
display: block;
overflow: hidden;
}
.footer-widgets-1,
.footer-widgets-2,
.footer-widgets-3 {
width: 332px;
margin-right: 36px;
float: left;
}
.footer-widgets-3 {
margin-right: 0px;
}
You might want to try using a "Table" display here. A Table display can be used in situations where you want to have control over the width of each column.
It is hard to give the exact solution you need, but something similar as below should be good to get you started.
Structure your widgets to enable them to be displayed as a table.
<div id="tableContainer"> <!-- Serves as a container for the whole table -->
<div id="tableRow"> <!-- We have only one row in this table, which has 3 columns, one for each widget. -->
<div class="footer-widgets-1"></div> <!-- First column. -->
<div class="footer-widgets-2"></div> <!-- Second column. -->
<div class="footer-widgets-3"></div> <!-- Third column. -->
</div> <!-- End row. -->
</div> <!-- End table. -->
Apply the styles to display your widgets as table cells within a table.
#tableContainer {
display: table;
}
#tableRow {
display: table-row;
}
#footer-widgets-1, #footer-widgets-2, #footer-widgets-3 {
display: table-cell;
vertical-align: top; /* Vertically aligns the content within each table cell at the top of the cell. */
width: 33%; /* Set each table cell to approximately one-third of the total width of the page. */
}
/* Any other styles specific to each widget go here... */
Hope this works for you.

CSS DIVs Break On Zoom

I have been struggling with this for over 4 hours now and I can't figure this out.
Usually when I design a site I always have it centered so I never face the problems were divs break out of the layout.
ISSUE 1
I have a sidebar on the left, followed by a content block and then a sidebar on the right.
Each sidebar should be 180px wide and the content block should fill the empty space between those two sidebars.
I can't even get them to float next to eachother now, I could do so before but I am really getting crazy.
Even if I do get them to float next to eachother, when I zoom in the page the content block breaks layout and falls down below the left sidebar it is so super annoying I never had this issue before.
ISSUE 2
The div Block at the header should automatically size between the two logos, similar to what i need for the content_wrapper, how can i do this?
Can someone help me please?
Thanks
HTML
<div id="header">
<div id="left_logo" class="logo"></div> <!-- Logo on the Left -->
<div id="block">This is a block</div> <!-- Div block inbetween the two logos -->
<div id="right_logo" class="logo"></div> <!-- Logo on the Right -->
</div>
<div id="content_wrapper">
<div id="left_sidebar" class="sidebar">Left Sidebar</div>
<div id="middle_content">Middle Content</div>
<div id="right_sidebar" class="sidebar">Right Sidebar</div>
</div>
CSS
html,body {
height:100%;
}
body {
background-image: url('../bg.jpg');
}
#header {
width: 100%;
border: solid 1px;
overflow: hidden;
}
.logo {
width: 180px;
height: 180px;
background-image: url('../avatar.jpg');
border: solid 1px;
}
#block {
border: solid 1px;
float: left;
}
#left_logo {
float: left;
}
#right_logo {
float: right;
}
#content_wrapper {
width: 100%;
}
.sidebar {
width: 180px;
float: left;
}
#middle_content {
min-height: 500px;
width: 100%;
float: left;
}
There are several points to note
move the #right_sidebar before the #middle_content
#right_sidebar must float right not left
#middle_content must not float and not have width: 100%
if you want to have the #middle_content in its own column, i.e. not float below the left and right sidebar, add margin-left and margin-right
The same applies to #header.
See JSFiddle for how this could look like.
Although it's several years old, there's a nice overview of basic layout schemes with CSS at http://www.thenoodleincident.com/tutorials/box_lesson/boxes.html

HTML/CSS - Sidebar Length 100% Page Height, Regardless of Vertical Scrollbar

I'm sure this has been asked quite some times however after quite some time searching for a solution I have finally resorted to asking a question here!
I am working on an HTML Help file for an application I am developing, where the file is split into two sections. One, a sidebar (floated to the left) and two, the main content section (also floating left).
The problem I am facing is that when the main content extends beyond 100% of the page height, the sidebar background stops.
I would use the faux column effect where I assign the a background image of my sidebar however to maintain my design's integrity I have to set a different background image for the body.
Check out this JS Fiddle I set up - http://jsfiddle.net/5gpFx/
Hopefully that can help you see what the issue is if I failed to communicate it well enough!
Cheers!
Just wrap both columns in a container and set the faux-column background on that - this way the body will be available for setting whatever image you want. I've made a simple example here: http://jsfiddle.net/5gpFx/2/
I had the same problem but I could not make work the solution with flexboxes above. So I created my own template, that includes:
a header with a fixed size element
a footer
a side bar with a scrollbar that occupies the remaining height
content
I used flexboxes but in a more simple way, using only properties display: flex and flex-direction: row|column:
I do use angular and I want my component sizes to be 100% of their parent element.
The key is to set the size (in percents) for all parents inorder to limit their size. In the following example myapp height has 100% of the viewport.
The main component has 90% of the viewport, because header and footer have 5%.
I posted my template here: https://jsfiddle.net/abreneliere/mrjh6y2e/3
body{
margin: 0;
color: white;
height: 100%;
}
div#myapp
{
display: flex;
flex-direction: column;
background-color: red; /* <-- painful color for your eyes ! */
height: 100%; /* <-- if you remove this line, myapp has no limited height */
}
div#main /* parent div for sidebar and content */
{
display: flex;
width: 100%;
height: 90%;
}
div#header {
background-color: #333;
height: 5%;
}
div#footer {
background-color: #222;
height: 5%;
}
div#sidebar {
background-color: #666;
width: 20%;
overflow-y: auto;
}
div#content {
background-color: #888;
width: 80%;
overflow-y: auto;
}
div.fized_size_element {
background-color: #AAA;
display: block;
width: 100px;
height: 50px;
margin: 5px;
}
Html:
<body>
<div id="myapp">
<div id="header">
HEADER
<div class="fized_size_element"></div>
</div>
<div id="main">
<div id="sidebar">
SIDEBAR
<div class="fized_size_element"></div>
<div class="fized_size_element"></div>
<div class="fized_size_element"></div>
<div class="fized_size_element"></div>
<div class="fized_size_element"></div>
<div class="fized_size_element"></div>
<div class="fized_size_element"></div>
<div class="fized_size_element"></div>
</div>
<div id="content">
CONTENT
</div>
</div>
<div id="footer">
FOOTER
</div>
</div>
</body>