Two divs within another div overlap - html

I asked a similar question already but haven't found an answer. I am now at a different section of my website but have the the issue here as well. The code is super basic, so I am hoping this will help to solve the issue.
Some context: My front page is sectioned in 3 container divs, each of them with 100vh, so they should take up the entire screen, even when someone resizes the browser. The second div in the code below (.showcase) should stick to the bottom of the Container div (that's why I added position: absolute and bottom: 0).
My issue is now that the two divs in the Container div 1, keep overlapping when I reduce the browser height for example. But I want them to 'push' each other away from each other, basically not giving space for the other div to overlap. So that when I, for example, would add a padding to the two divs, that the padding still shows on the page even if resizing the browser. And no matter what I added (display: block, Flexbox, even putting the divs into a table etc) all of this didn't help and the content of the two divs keeps overlapping.
Can anyone help me here? I literally don't know how to go from here...
Here is the code:
.Container1 {
overflow: hidden;
height: 100vh;
width: 100%;
margin: 0;
background: rgb(74, 105, 113);
background: linear-gradient(90deg, rgba(74, 105, 113, 1) 0%, rgba(129, 161, 170, 1) 60%, rgba(181, 207, 214, 1) 100%);
text-align: center;
display: block;
}
.hp_slogan {
padding-top: 20%;
padding-bottom: 3%;
}
.showcase {
position: absolute;
bottom: 0;
display: block;
}
<div class="Container1">
<div class="hp_slogan">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="showcase">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>

I believe this will solve your problem If I understood correctly what you need.
.Container1 {
overflow:hidden;
height: 100vh;
width: 100%;
margin: 0;
background: rgb(74,105,113);
background: linear-gradient(90deg, rgba(74,105,113,1) 0%, rgba(129,161,170,1) 60%, rgba(181,207,214,1) 100%);
text-align: center;
display: flex;
flex-direction:column;
}
.hp_slogan {
padding-top: 20%;
margin-bottom:20px;
padding-bottom: 3%;
}
.showcase {
bottom: 0;
}
You can simulate it in JSFiddle with this link

See if this works for you. Used flexbox to distance two divs
.Container1 {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
overflow: hidden;
height: 100vh;
width: 100%;
margin: 0;
background: rgb(74, 105, 113);
background: linear-gradient(90deg, rgba(74, 105, 113, 1) 0%, rgba(129, 161, 170, 1) 60%, rgba(181, 207, 214, 1) 100%);
text-align: center;
}
<div class="Container1">
<div class="hp_slogan">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="showcase">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>

Related

CSS textarea image background with opacity without impacting the foreground text

I have a textarea that user can change its size.
I need to have an image background for it but I do not want the image disturbs the text so the image should be partially transparent without impacting the opacity of the text that user can type on top of it.
I followed this link which suggests using ::before but it does not work on my Firefox browser.
<textarea class="hero">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</textarea>
CSS
.hero {
position: relative;
/* height: 100vh; */
/* width: 100%; */
display: flex;
align-items: center;
justify-content: center;
}
.hero::before {
content: "";
background-image: url('https://placekitten.com/1200/800');
background-size: cover;
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
opacity: 0.75;
}
https://jsfiddle.net/z86yfLvh/1/
How should I fix this?
The easiest solution here would be wrapping your textarea element into a container, put background on it and tune the background of your textarea down, through background-color with alpha inside the rgba().
Like this:
.hero {
background-color: rgba(255, 255, 255, .7)
}
.hero-container {
background-image: url('https://placekitten.com/1200/800');
background-size: cover;
display: inline-block;
}
<div class="hero-container">
<textarea class="hero">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</textarea>
</div>
I should mention also that ::before won't work with textarea because it would have to render it inside the textarea which can't contain any HTML elements directly. It's a hard limitation.
Alternative solution that also solves another issue that OP mentioned in the comment:
.hero {
background-color: rgba(255, 255, 255, .7);
width: 100%;
height: 100%;
resize: none;
}
.hero-container {
background-image: url('https://placekitten.com/1200/800');
background-size: cover;
resize: both;
overflow: auto;
width: 100%;
}
<div class="hero-container">
<textarea class="hero">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</textarea>
</div>
I'm using resize: none on textarea to disable the ability to resize it and I'm adding it to the container instead, while width: 100%; height: 100% makes sure textarea stretches with the container too.

My div sections are overlapping when changing browser's height

I am extremely frustrated because I keep running into the same issue. So I apologize for having to ask this question again...
I want my website to have different sections and used divs for that. For some reason, when I reduce my browser's height, the sections will overlap. So for example, I set the middle section (div container 2) to a red background color and the first section (div container 1) to a different color, in this fist section I also have some placeholder text. When I then reduce the browser's height, the red background from section 2 will keep moving into my first section with the placeholder text. I removed all content from the second container but obviously this is an even bigger issue when I have elements in the second container because then not only the background but also the elements from this section will move into my first section and overlapping with the content from the first section.
When I asked this question yesterday, the issue was that I had position absolute but that's no longer the case. I tried all different positioning (flex, block, inline, inline block, absolute) but this overlapping when resizing the browser keeps happening :(
Can anyone please help me??
Here is my code:
.Container1 {
height: 100vh;
width: 100%;
margin: 0;
background: rgb(74, 105, 113);
background: linear-gradient(90deg, rgba(74, 105, 113, 1) 0%, rgba(129, 161, 170, 1) 60%, rgba(181, 207, 214, 1) 100%);
text-align: center;
display: flex;
flex-direction: column;
}
.hp_slogan {
padding-top: 100px;
}
.showcase {
margin-top: auto;
}
/* Container2 Styling */
.container2 {
height: 100vh;
width: 100%;
background-color: red;
color: white;
display: block;
font-size: 16px;
}
<div class="Container1">
<div class="hp_slogan">
<div class="">
<?php
echo do_shortcode('[smartslider3 slider=19]');
?>
</div>
<p>Placeholder Text.</p>
</div>
<div class="showcase">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
<div class="container2">
</div>
From my own comment:
Try using min-height: 100vh instead of height: 100vh.

Elements not filling entire width of screen on mobile using css grid

I am trying to mock up a design for a personal/resume website, the page looks how I intended it too before resizing the page, but after resizing to mobile some of the elements on my page don't occupy the entire width of the screen(I am using a single column on mobile).
I have a 2 column layout on desktop, which changes to a single column layout for mobile with a media query, the problem occurs after the breakpoint for the media query. I have added "width=100%" to all of the elements that are impacted, as well as tried to turn on and off each style rule, such as margin and padding, individually in chrome developer tools. After several days I'm sure I am just missing whatever the problem is, or have a fundamental misunderstanding.
Screenshot of mobie layout issue
My HTML
<div class="wrapper">
<div class="intro-box">
<h1>Who am I, and where am I going?</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
<div class="bio-box">
<div class="photo-box">
<h2>Thanks for discovering more about me</h2>
<img src="davidSized.jpg" alt="David's Photo">
</div>
</div>
<div class="content-wrapper">
<h1>Learn about me here...</h1>
<div class="selector-one selector">
<h2>My Resume</h2>
</div>
<div class="selector-two selector">
<h2>About Me</h2>
</div>
<div class="selector-three selector">
<h2>More stuff</h2>
</div>
<div class="content">
<p class="para-one"></p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<div class="contact-info-box">
<h3>Reach out to me here....</h3>
<ul class="contact-info">
<li>david_jhall#yahoo.com</li>
<li>LinkedIn Profile</li>
<li>Facebook Profile</li>
<li>More ways to contact me....</li>
</ul>
</div>
</div>
My meta tag
<meta name="viewport" content="width=device-width, initial-scale=1.0">
the wrapper element before the media query
wrapper{
display: grid;
grid-template-columns: 30% auto;
grid-template-rows: repeat(5 , auto);
grid-gap: 15px;
}
the wrapper element after the media query
.wrapper{
grid-template-columns: auto;
justify-content: center;
}
the elements that don't span the whole page on mobile (before the mq)
.intro-box{
grid-column: 1/3;
margin: 0px;
background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.1)),border-box,url("road.jpg") no-repeat center center;
background-size: cover;
color: lightgrey;
min-height: 750px;
max-width: 100%;
padding: 0;
}
.bio-box{
margin: 10px;
border: 5px solid rgba(0, 0, 0, 0.25);
text-align: center;
border-radius: 10%;
min-height: 500px;
}
.content-wrapper{
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: auto auto 50%;
text-align: center;
min-height: 500px;
grid-gap: 5px;
max-width: 100%;
justify-content: center;
}
.content{
background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1)),border-box;
grid-column: 1/-1;
}
mq and the elemnts within it
#media screen and (max-width:700px){
.wrapper{
grid-template-columns: auto;
justify-content: center;
}
.intro-box > h1{
font-size: 3em;
padding: 20px;
}
.bio-box{
grid-row: 3/4;
grid-column: 1/3;
}
.content-wrapper{
margin: 0 auto;
grid-column: 1/3;
justify-self: center;
}
.content{
padding: 20px;
margin: 0 auto;
margin-bottom: 50px;
width: 100%;
}
}
Remember that padding is internal to the border of the column, so makes little difference here. Also remeber that classes are gonna be your best friend with this sort of thing, simple change some CSS of the single class in a media query and add this class to each column you want to change for mobile. That way you reduce how much code you chuck into each MQ.
Firstly, as a quick-fix (but ideally not permanent) try adding in the MQ, this CSS:
.your-div-class {
width: 100%;
right: 0;
}
Also, disable your x-overflow (of the body) to avoid any nasty side-scrollbars!
See whether the ' right: 0; ' property helps bring it fully to the right.
Here's what I would do:
Give each column the same class of "responsive-col" or something, then pop this into an MQ, and style it like so:
#media screen and (max-width:700px){
.responsive-col {
margin: 0;
right: 0;
width: 100%;
font-size: 22px;
display: block;
}
}
There's loads to say, but this would hopefully solve it and if you have another question I'll just answer that.
Kieron

Overflow of child div spilling out into parent div

I've been trying to solve a number of issues for this questionnaire I'm making. I've reformatted this question because my old one was pretty confusing and I'm taking a new angle on the issue.
With the new code I've summited the problem is that the child div .question-container inside the .questionnaire-box is spilling out all the text past the set height. I prefer .question-container to have the same height as .questionnaire-box and scroll on overflow.
.questionnaire-container {
position: fixed;
width: 100%;
height: 100%;
padding: 2rem 0;
background-color: rgba(100, 100, 100, .1);
}
.questionnaire-box {
position: relative;
width: 80%;
max-height: 80%;
margin: 0 auto;
background-color: #ffffff;
}
.question-container {
max-height: 80%;
overflow-y: scroll;
}
.questionnaire-nav {
position: absolute;
bottom: 0;
width: 100%;
height: 55px;
border-top: 1px rgba(100, 100, 100, .3) solid;
background-color: #ffffff;
text-align: center;
}
button {
margin 1rem;
}
<html>
<body>
<div class="questionnaire-container">
<div class="questionnaire-box">
<div class="question-container">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="questionnaire-nav">
<button>Submit</button>
</div>
</div>
</div>
</body>
</html>
This is what it looks like inside my app.
And this is what I'm trying to achieve.
The question is a little overly-complex, but I assume the problem here is that you're unable to scroll down and view all of the content in .question-container.
Does this work?
https://jsfiddle.net/tobyl/bemkkz72/
If so, the critical CSS is the additional padding-bottom in this block:
.questionnaire-box {
position: relative;
width: 80%;
max-height: 80%;
margin: 0 auto;
padding: 1.5rem 2rem 6rem 2rem;
border-radius: 20px;
background-color: #ffffff;
overflow: auto;
}
There were quite a few things I changed in your code for the snippet below - it will be too much to explain everything. Still, some of the most important changes:
No flexbox
Fixed element (nav) outside of the DIV above it
Look at the code. I can explain more, if this is what you are after, but not tonight (i.e. "good night" :-)...
* {
box-sizing: border-box;
}
html, body {
height: 100%;
}
.questionnaire-container {
width: 100%;
height: calc(100% -50px);
padding: 5rem 0;
background-color: rgba(255, 100, 100, .1);
}
.questionnaire-box {
width: 80%;
margin: 0 auto;
padding: 1.5rem 2rem;
border-radius: 20px;
background-color: #ffffff;
}
.question-container {
height: 100%;
margin-bottom: 55px;
padding: 3rem 4rem;
}
.questionnaire-nav {
position: fixed;
bottom: 0;
text-align: center;
width: 100%;
height: 30px;
border-top: 1px rgba(100, 100, 100, .3) solid;
background-color: #ffffff;
padding: 10px 0;
}
<html>
<body>
<div class="questionnaire-container">
<form class="questionnaire-box">
<div class="question-container">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor</p>
<p>in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor</p>
<p>in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<nav class="questionnaire-nav">
<button>Previous</button>
</nav>
</form></body>
</html>
Try to change these three things in .questionnaire-nav:
position to fixed
width to 75%
and deleted margin-left: -20px;
Does this work for you?
html, body {
max-height: 100%;
}
.questionnaire-container {
position: fixed;
width: 100%;
height: 100%;
padding: 5rem 0;
background-color: rgba(255, 100, 100, .1);
}
.questionnaire-box {
position: relative;
width: 80%;
max-height: 80%;
margin: 0 auto;
padding: 1.5rem 2rem;
border-radius: 20px;
background-color: #ffffff;
overflow: auto;
}
.question-container {
height: 100%;
margin-bottom: 55px;
padding: 3rem 4rem;
overflow-y: auto;
}
.questionnaire-nav {
display: flex;
position: fixed;
bottom: 0;
align-items: center;
justify-content: center;
width: 75%;
height: 55px;
border-top: 1px rgba(100, 100, 100, .3) solid;
background-color: #ffffff;
}
<html>
<body>
<div class="questionnaire-container">
<form class="questionnaire-box">
<div class="question-container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<nav class="questionnaire-nav">
<button>Previous</button>
</nav>
</form>
</div>
</body>
</html>

Why are elements not lining up horizontally

I have a site that I'm trying to design and I have elements that need to line up horizontally, this isn't working correctly, though. These elements are in a parent wrapper div and they are floated left and right respectively. There is also an image div inside one of the elements that has text wrapping around it. So far, I've been able to get the text to wrap around the image div correctly using floats, however, the other element on the page is not lining up correctly.
Here's a pen and accompanying code:
http://codepen.io/anon/pen/WbXpZz
HTML
<body>
<header></header>
<div id="page">
<div id="image"></div>
<section>
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu.</p>
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</section>
<aside>
<h2>Lorem Ipsum</h2>
<ul>
<li>Lorem - <span>Ipsum</span></li>
<li>Lorem - <span>Ipsum</span></li>
</ul>
<aside>
</div>
</body>
CSS
body{
background-color: rgb(128, 128, 128);
}
header, #image, #page{
display: block;
}
header, #page, #image{
float: left;
}
header, #page{
position: absolute;
z-index: 0;
}
header{
top: 0;
left: 0;
right: 0;
height: 100px;
background-color: rgb(0, 0, 0);
border-bottom: 3px solid rgb(171, 166, 27);
}
header ul{
color: rgb(255, 255, 255);
color: black;
}
header ul li{
display: inline-block;
}
#page{
top: 150px;
left: 5%;
right: 5%;
}
#image{
width: 300px;
height: 400px;
margin-right: 2%;
margin-bottom: 2%;
background-color: white;
background-repeat: no-repeat;
background-size: 100% 100%;
border-radius: 25px;
border: 3px outset rgb(171, 166, 27);
box-shadow: 5px 5px 15px rgb(0, 0, 0);
}
section{
display: block;
float left;
width: 80%;
border-right: 3px solid rgb(171, 166, 27);
background-color: blue;
}
section h1{
font-size: 36px;
font-weight: bold;
color: rgb(255, 255, 255);
}
section p{
font-size: 20px;
color: rgb(0, 0, 0);
}
aside{
display: block;
float: right;
width: 18%;
background-color: red;
}
If I change the section and aside to be inline-block, they line up, but they do so underneath the image. Also, if I position the image div absolutely, everything lines up the way it should, but the text in the section no longer wraps around the image div. Can anyone help?
To make it work the way you want you need to change the order on your markup:
From:
<div id="image"></div>
<section></section>
<aside><aside>
To:
<div id="image"></div>
<aside><aside>
<section></section>
Floated Elements First to ensure the block behavior of section doesn't affect the flow of the floated elements.
CodepenDemo