Internet Explorer 11 creating empty white space on div - html

I'm trying to create a print-friendly version of a webpage, however, the webpage and the print preview in Internet Explorer 11 have some mysterious blank space beneath the div's.
I have checked all the CSS classes, html markup, etc.
Setting the height makes no difference
Setting margin and padding to 0 makes no difference
It is just a huge white block beneath each div - there's nothing associated with it, so I do not understand why IE is putting it there.
Example:
<div class="row"> ## this has the big white space beneath it, after its closing tag
<div class="medium-12 columns"> ## this is the correct height
<!-- content -->
</div>
</div>
## WHITE SPACE HERE ##
## around 20-30 lines long ##
<!-- next div begins here -->
CSS rules on the affected tag:
padding: 0 0 5px 0;
page-break-inside: avoid;
margin: 0 -.9375rem;
max-width: none;
width: none;
overflow: hidden;
Does anybody have any ideas as to why this may be?

I see that you have tried zeroing out the margins, but I would suggest that You must try and add a reset for your stylesheet. CSS resets remove nearly all browser presets that usually interfere with custom stylesheets that include various types of document styles.
You just need to add it as a separate file link in your document, or simply copy and paste the code in your main CSS file, before all of your custom styles.
There are a few options out there regarding CSS resets, but I think that Mr. Mayer's reset would do the best job here.

Edited:
As i see that you are using Foundation, i have seen that foundation grid have some kind of issue adding negative margin values like that margin: 0 -0.9375rem;
Basically the 0.9375 is the main margin for your grid, rendered from SCSS to CSS. To avoid additionally compounding margins on nested columns, Foundation applies a negative padding to equalize.
If you're having problems with nested rows, make sure each sub .row is contained withinin a "small-xx ... columns" class, this should bring the edges back to normal.
Don't do this:
<div class="row">
<div class="small-6 columns"></div>
<div class="row">
<div class="small-3 columns"></div>
<div class="small-3 columns"></div>
</div><!-- .row -->
</div><!-- .row -->
Instead do this:
<div class="row">
<div class="small-6 columns"></div>
<div class="small-6 columns">
<div class="row">
<div class="small-6 columns"></div>
<div class="small-6 columns"></div>
</div><!-- .row -->
</div><!-- .small-6 .columns -->
</div><!-- .row -->

Related

How to stop Foundation's `.columns` class adding padding that ruins mobile optimisation?

I'm new to Zurb Foundation (5) and am only just now working on a site that uses it. I've come across an issue where these is unwanted empty space to the right when viewing the site on mobile screen sizes (causing a horizontal scroll). On investigation I see this is caused by Foundations .colunmn class - specifically the padding:
.column, .columns {
width: 100%;
float: left;
padding-left: .625rem;
padding-right: .625rem;
}
This seems like an odd thing for Zurb to do, so I'm assuming I've done somthing wrong on my end. My HTML looks like:
<div class="title-panel">
<div class="row">
<div class="large-12 columns">
<!--CONTENT-->
</div>
</div>
</div>
<div class="main-panel">
<div class="row">
<div class="small-12 medium-4 medium-push-8 columns">
<!--CONTENT-->
</div>
<div class="small-12 medium-8 medium-pull-4 columns">
<!--CONTENT-->
</div>
</div>
</div>
Is there some way to get rid of this width 100% plus padding issue?
Image of problem. The width of the blue box is 100% but the padding set above adds the green area on the right.
Found this was due to the parent element of the above divs having a .row class. You cannot have 2 .rows one after the other, even if they are separated by other elements and classes. They must be separated by a .column class.

Setting height to element with floating elements that can't be cleared

I'm using Bootstrap to make a blog theme in WordPress and I'm encountering an issue with following the structure/classes.
My current markup goes:
<div class="container blog-post">
<div class="row">
<section>
<div class="col-lg-8 col-xs-12">
<article>
[Blog post content]
</article>
</div>
</section>
<div class="col-lg-4 col-xs-12">
<aside>
[Sidebar content]
</aside>
</div>
</div>
</div>
</div>
As illustrated, the <section> height is only affected by the margin and padding, not the content.
Since Bootstrap's col-xx-xx classes are floated left, my section is only accumulating height based on its margin and padding, not the child elements. If I clear the float after the section, then the sidebar doesn't display on the right, like I want it to.
I tried setting the section overflow to hidden and other values, but then the sidebar either cleared to the row below, or the section height didn't change.
Any advice would be appreciated!
you have your layout wrong.
you are seeing what you are seeing because you are not applying a clearfix to that section. and if you do (as you noticed already) the sidebar stacks down the post because <section> is a block element and takes 100% of width space, therefore pushing the sidebar down the dom.
you should either include the sidebar in the section (and apply a clearfix), or float that section as well like so:
section {
overflow:auto;
float:left;
}
i suggest including the sidebar in the section, or removing that section tag all togheter
You should refactor your layout a bit. Bootstrap works fine with row and cols, you just have to make it look something like this
<div class="row">
<div class="main col-lg-8">
/* your content */
</div>
<div class="sidebar col-lg-4">
/* your sidebar */
</div>
</div>

Remove whitespace between dynamically generated html search results for CSS inline-block

I am using the mixItUp jQuery API on my website. I was having an issue with spacing on inline-block elements primarily because of the excess whitespace inline-block adds.
Normally I would use a <!-- --> to remove the whitespace between the html elements where needed, but I can't seem to do that on account of the html results get generated dynamically. The html code that structures the search results are also in a different "search-results" PHP template file for organization.
<div class="container">
<!-- The three DIVs below are generated with PHP in a different template file -->
<div class="result 1">Content</div>
<div class="result 2">Content</div>
<div class="result 3">Content</div>
</div>
So the question is how would I remove the whitespace produced by inline-block on these 3 hypothetical DIV elements?
Please note, I don't want to use any hacky CSS tricks as they always have a support related con (ex. margin-right:-4px, font-size:0, etc).
Thank you!
Super easy:
.container {
font-size: 0;
}
.container > div {
font-size: 1rem;
}
This option sets the font-size to 0 so that the white-space consumes no space. Then, it resets the font-size to the root-level declaration with font-size: 1rem for all immediate children divs.
--OR--
<div class="container"><!--
--><div class="result 1">Content</div><!--
--><div class="result 2">Content</div><!--
--><div class="result 3">Content</div><!--
--></div>
This is simply adding a comment between the items so that you can preserve your document layout (for editing purposes) while essentially telling the browser to ignore everything in between the tags.

Why does my button appear outside the containing div?

I have a fiddle here which shows my issue. You may need to make the 'result' quadrant wider to show the issue.
I have a couple of columns in my bootstrap layout but I can't seem to get my button to layout inside the parent div, it always seems to overlap it:
At first I thought it was due to the padding of the columns in bootstrap but I have removed that and the problem persists. I'm obviously missing something fundamental about how this is supposed to work, so any pointers to some help with css might not go amiss either.
apparently I have to link to some code to include a link to a fiddle so here is some:
My html is:
<div class="col-md-3 col-lg-3 nopadding">
<div class="definition-pallette">
<div class="row nopadding">
<div class="col nopadding"><button data-bind="click: showStepModal">+ Step</button></div>
</div>
</div>
</div>
and the additional css on top of the bootstrap default is:
.nopadding {
padding-left: 0 !important;
padding-right: 0 !important;
}
Seems to be a few things going on here. The main issue is you are using a lot of divs with a class of 'col' inside your 'row' divs. To get them to start behaving you need to define what size the col is. This fixes most of your problems. So for example, where you have this
<div class="row">
<div class="col">Some content</div>
</div>
Change that to something like
<div class="row">
<div class="col-xs-12">Some content</div>
</div>
And it starts behaving.
I also got rid of your .nopadding class as you don't need that.
Here is an updated fiddle - http://jsfiddle.net/T4XY4/1/ - it fixes most of the things in the right panel, but I'll leave the rest to you. You may want to choose which classes you actually want inside your 'row' divs, I just chucked in xs-12 for simplicity.
Edit
The Bootstrap docs confirms that if you are nesting columns you need proper col-* classes - http://getbootstrap.com/css/#grid-nesting
Its caused by bootstraps margins in the row class adding margin:0; to your no padding class will fix this but might cause layout issues in other places or on mobile devices.
.row {
margin-right: -15px;
margin-left: -15px;
}

Why <div class="clear"></div> didn't used?

Hi, sometimes learning something makes you more confused, I am in that position right now, thanks in advance.
I asked a question in this address: Why <div class="clear"></div> used?
After getting the answer and accepting (I also read the links given in comments section), now I've 2nd and 3rd questions.
According to the input codes given in related question,
Why grid demo code below didn't use <div class="clear"></div>? Again there exist 2 sets of two floating div elements so isn't it suitable to use <div class="clear"></div> just after the last floating div elements?
I explicitly mention that I would expect <div class="clear"></div> code in 2 places: Just after <div class="col col_7"> and just after <div class="col col_4">
<div class="row">
<div class="col col_1">col_1</div>
<div class="col col_7">col_7
<div class="row">
<div class="col col_3">col_3</div>
<div class="col col_4">col_4</div>
</div><!-- row -->
</div>
</div><!-- row -->
</div><!-- col_8 -->
The owner of accepted answer wrote that: "Without this the content following your nav element may appear alongside your nav element rather than below it." Since he used MAY grammar & I deleted <div class="clear"></div> and saw that nothing has changed in output for IE9 and Chrome 25.0.1364.172; what maked him to write MAY? Old browsers (especially old IE versions)?
This depends on your CSS that is associated with the different classes/ids/elements in your HTML.
<div class="clear"></div> ALWAYS has some css associated with it, that is:
.clear { clear: both; }
The above CSS is what makes it prevent that floating issue. That said... Using a "clear div" as you have shown above is one of many ways to do this.
In your particular case, given this HTML:
<div class="row">
<div class="col col_1">col_1</div>
<div class="col col_7">col_7
<div class="row">
<div class="col col_3">col_3</div>
<div class="col col_4">col_4</div>
</div><!-- row -->
</div>
</div><!-- row -->
</div><!-- col_8 -->
It is very likely that the class of "row" has the clear: both; property in CSS. That would explain why when you remove the clear div, it stayed the same. Essentially you didn't need the clear div, because the row class already has the CSS attached to it to prevent that issue from happening.
The selector probably looks like this: .row { clear: both; } The .row class probably has other CSS associated with it as well, another very likely property is overflow: hidden; That property can also effect how your divs and surrounding divs interact/behave next to each other.
To summarize: It is NOT the HTML <div class="clear"></div> that prevents this floating issue from happening. It IS the CSS property and value clear: both; which can be applied to any HTML element that prevents the issue from occurring.
Some resources:
CSS Wiki on Overflow property
CSS Wiki on Clear property
Hopefully this clears that up for you? (pardon the pun haha)