Unnecessary huge empty space at the bottom of page - html

This is my project: http://linguall.com/
We bought a template and edited it. I deleted some of the page that is not needed for us. However, as you scroll the bottom of the page you can spot the the huge blank space.
I could not found any reason for that.

You are using relative positioning on some of your elements. The problem with this is that the element still takes up space where it originally was and you will struggle to get rid of that.
I'd investigate replacing your usage of relative positioning for large blocks of content that you don't want to take up space on your page - try absolute positioning or using a grid layout.

Related

I have two flexboxes that occupy the same space but I want them to be next to one another

I am pretty new to HTML and CSS, and one of the things I have read is that you should keep your <header> and <main> tags separate. When I do this, however, it makes it harder for me to align content on a page the way I want. Currently I'm having issues with the content of the main overlapping with the content of the header elements, and they are both occupying the same space. I tried setting the :root to display: flex;, and then flex-direction: column;, but this didn't seem to prevent the elements from overlapping. I would like them to behave as if the header and main were both in the same flexbox and aligned in a single column, but so far I haven't seen anything addressing this issue. I have attached a Codepen link of what I have so far (the borders in the CSS were just to help me visualize where things were going wrong).
After continuing to mess around with some of the values in the CSS selectors, I found that the one causing the issue was the position: fixed. I knew that I wanted the nav-bar to remain at the top of the screen when scrolling, but I didn't fully understand the implications of having other elements in the same page as a fixed element, without using a relative parent.
When I used position: fixed; it caused that element to essentially be disregarded from the normal flow of the page, and other elements filled the top, making them appear stacked on top of one another. In my particular case, I chose to go with sticky instead, as this accomplishes the same objective without complications.

Removing unwanted vertical space at end of post resulting from pile-up of negative positioning of <div> elements

In this blog post of mine, I needed many two-column bits, and that resulted in many elements. That caused lots of unwanted vertical space between them. I googled, and found out how to position: relative; top: -<whatever number>px. Now all the vertical space has piled up at the end. My googling did not reveal any command for negative vertical space (think LaTeX \vspace with negative argument), though that's what I was googling for. Is there any way to remove that huge space at the end?
PS I'm a total noob when it comes to web page design: all I know is a little HTML which I figured out by looking at the HTML for my other blog posts or which I googled for, and that little bit of CSS for the padding of tables. I do not know if Blogger accepts anything but pure HTML+CSS.
Update
Problem solved with CBroe's comment. Blog post originally ended like this:
Relative positioning only moves an element in regard to its “default” position (that it would have in normal flow, if the element was not positioned at all), but preserves the original space required by the element.
If you want to “move” elements without that effect, you can use for example margin instead.

Unwanted space in 2 column layout

I'm trying to design a 2 column layout for getting a feel for HTML again.
I want to avoid using floats because I want to keep the natural document flow. Every other question on Stack Overflow I browsed through incorporate floats or worse tables. I tried layouting it with flex as well but I couldn't figure out how to make both the columns stay the same size on the other pages with different amounts of content in the first column.
Here's what I got so far: http://jsfiddle.net/wykenakw/
I figured out through trial and error that I can use a negative margin to line up the sidebar to the main content but it feels awkward, quirky and hacky. I inspected every element inside my columns but I couldn't find any potential child elements with margins that could cause this 4px gap. It's driving me nuts.
Am I missing something? Am I doing something wrong?
float is ideal because it will essentially cut out the "white space" for you. You can try and use: white-space-collapse:discard on parent elements (in this case #wrapper), but I rarely have success using it.
White space is just a "natural" occurrence created by the browser rendering. In order to avoid this (without using float), you need to simply remove the white space between your elements. This isn't ideal because of the flow and indentation of the elements, but without using float it's what has to be done.
Additionally, in my opinion there is nothing wrong with using float as a "natural document flow". You can always clear the elements.
So instead of:
</main>
<aside id="col_2">
You'd have:
</main><aside id="col_2">
Hope this helps!
http://jsfiddle.net/wykenakw/1/
Change your <main> into a <div> or use css to turn it into a block element:
main {
display: block;
}
As mentioned in the other answer actual spaces between the two elements is causing the unwanted whitespace. However spaces between two block elements is always ignored.

Reducing height of html document

I have this situation:
I made 2 div's, both should be at the exact same spot. By JavaScript, I can activate one if I want and hide the other. That's how I did it:
<div style="height:100px"></div>
<div style="position:relative; top:-100px;height:100px"></div>
This works pretty well. But I noticed that the place where you would expect the second div (without the top:-100px) is used by blank space.
What is the most elegant way to get rid of that space again? I don't want that my webusers think they can scroll down more but there is just white space left.
Thanks for your tips! I hope my description is clear enough, it's not that easy to describe. ;)
they are not in the same spot, relative divs always leave the spot they moved from occupied by blank space. you need to use 'position:absolute' or negative margins. You can still position them in the flow if you need by wrapping them both in the same relative div.

Vertical Centering, Unknown Height, Other Content on Page

Alright, so this is basically the usual "how to vertically center with CSS" question, but with some catches.
No Javascript. HTML and CSS only. CSS3 is fine as long as it's reasonably well supported by today's browsers.
The element's content, and therefore height, is not known. It may be anywhere from a few dozen to a few hundred pixels. In the future I might even have a script adding and removing elements inside, so it may change height as the user is interacting with it.
There is other content on the page - a navigation bar at the left and a menu at the top. These need to be accessible.
The approach I've used is the three-container-div method using display: table-cell, as documented at: http://www.jakpsatweb.cz/css/css-vertical-center-solution.html this solves issues 1 and 2, but not 3.
http://imgh.us/vcenter.jpg shows the design and the problem. The yellow box is the innermost container. The red and green dotted boxes around the entire page (which have become somewhat blurred together due to JPEG encoding) are the outermost and middle containers respectively. (The out-of-place footer is a separate issue...)
The problem with this layout is the outer containers cover the entire page, and this makes it impossible to click on the navbar, because it's now "under" those containers. Z-index can move them to the bottom, but then it becomes impossible to click on anything inside the red box, because it's now "under" the page's main content box. (XHTML only allows a single element inside the <body>, so I've just wrapped it all in a <div>.) Even if the outer two containers have z-index: -100 and the inner container has z-index: 200, it still ends up under the main content box for some reason. (I did try various position attributes.)
The only solution I've seen is a new CSS3 property, pointer-events, that would in theory allow me to make events pass through the transparent containers as I'd expect; however this seems to be quite new and not yet supported by most browsers outside of SVG, and I imagine I'd have the same trouble as with Z-index.
I do want the element at the center of the page, not the center of the content area (i.e. ignoring navbars in the calculation of position), so placing the container inside the content area isn't an ideal solution. (I'm using this style on the login page as well, which has no navbars, and it'd look a bit strange if the "centered" elements were centered relative to a navbar that isn't always visible.)
In summary what I need is to center, without using Javascript, an element of unknown height on a page with other content at its edges, without covering any of the content with an invisible layer (and thus making it unclickable).
While this is obviously an old question and the OP has undoubtedly solved this problem, I figured I'd add a link to Chris Coyier's marvelous write-up on how to deal with this issue for future wayfarers in need of a similar solution.
http://css-tricks.com/centering-in-the-unknown/