How to fill in the gap above the header - html

I'm making a short little iMessage code block, and I'd like to fill in the gap above the header with the same grey color, that conforms to the outer border rounding on the top only. (I'd also like to make the gap a little smaller, which I believe is done by changing the margin-top, it just cuts over the outer border behind it.
#workskin .phone {
max-width: 300px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
display: table;
margin: auto;
border: 1px solid;
border-radius: 25px;
border-color: #B5B5B5;
background-color: #FFFFFF;
max-height: auto;
}
#workskin .header {
min-width: 300px;
background-color: #f6f6f6;
border-bottom: 1px solid #b2b2b2;
color: #000000;
font-weight: bold;
padding-bottom: .5em;
margin-left: -.5em;
margin-top: .5em;
margin-right: -.5em;
margin-bottom: -2em;
text-align: center;
text-transform: capitalize;
display: block;
}
#workskin .messagebody {
background-color: #FFFFFF;
display: table;
padding-left: .5em;
padding-right: .5em;
}
#workskin .text {
float: left;
color: #000000;
margin: 0 0 0.5em;
border-radius: 1em;
padding: 0.5em 1em;
background: #e5e5ea;
max-width: 75%;
clear: both;
position: relative;
left: 1em;
}
#workskin .text::after {
content: "";
position: absolute;
left: -.5em;
bottom: 0;
width: 0.5em;
height: 1em;
border-right: 0.5em solid #e5e5ea;
border-bottom-right-radius: 1em 0.5em;
}
#workskin .breply {
float: right;
color: #FFFFFF;
margin: 0 0 0.5em;
border-radius: 1em;
padding: 0.5em 1em;
background: #1289fe;
max-width: 75%;
clear: both;
position: relative;
right: 1em;
}
#workskin .breply::after {
content: "";
position: absolute;
right: -0.5em;
bottom: 0;
width: 0.5em;
height: 1em;
border-left: 0.5em solid #1289fe;
border-bottom-left-radius: 1em 0.5em;
}
#workskin .time {
text-align: center;
padding: 0.5em 1em;
display: block;
}
#workskin .time::after {
content: "";
position: absolute;
right: -0.5em;
bottom: 0;
width: 0.5em;
height: 1em;
border-left: 0.5em solid #1289fe;
border-bottom-left-radius: 1em 0.5em;
}
<div class="phone">
<p class="messagebody"><span class="header">Alya 😘😘</span><br />
<br />
<span class="time">3:02PM</span><br />
<span class="text">Hey girl are your classes done yet</span><br />
<span class="breply">Just finished</span><br />
<span class="breply">Why?</span><br />
<span class="text">Wanna get lunch before you go home?</span><br />
<span class="breply">Sure. Let’s go to the campus cafeteria though</span><br />
<span class="breply">I have homework to work on already πŸ™„</span><br />
</p></div>
I tried editing the header itself, but it rounds the entire container, not just the top.

Rather than having to play with negative margins, it seemed easier to just simplify the layout and CSS, as follows:
<div id="workskin">
<div class="phone">
<div class="header">Alya 😘😘</div>
<div class="messagebody">
<div class="time">3:02PM</div>
<div class="text">Hey girl are your classes done yet</div>
<div class="breply">Just finished</div>
<div class="breply">Why?</div>
<div class="text">Wanna get lunch before you go home?</div>
<div class="breply">Sure. Let’s go to the campus cafeteria though</div>
<div class="breply">I have homework to work on already πŸ™„</div>
</div>
</div>
</div>
#workskin .phone {
max-width: 300px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
display: table;
margin: auto;
border: 1px solid;
border-radius: 25px;
border-color: #B5B5B5;
background: linear-gradient(to bottom, #F6F6F6 0% 37px, #FFFFFF 37px 100%);
max-height: auto;
padding-bottom: 1em;
}
#workskin .header {
min-width: 300px;
border-bottom: 1px solid #B2B2B2;
color: #000000;
font-weight: bold;
padding-top: 0.5em;
padding-bottom: 0.5em;
text-align: center;
text-transform: capitalize;
}
#workskin .messagebody {
display: table;
padding-left: 0.5em;
padding-right: 0.5em;
}
#workskin .time {
text-align: center;
padding: 0.5em 1em;
}
#workskin .text,
#workskin .breply {
margin: 0 0 0.5em;
border-radius: 1em;
padding: 0.5em 1em;
max-width: 75%;
clear: both;
position: relative;
}
#workskin .text {
float: left;
color: #000000;
background: #e5e5ea;
left: 1em;
}
#workskin .breply {
float: right;
color: #FFFFFF;
background: #1289fe;
right: 1em;
}
#workskin .text::after,
#workskin .breply::after {
content: "";
position: absolute;
bottom: 0;
width: 0.5em;
height: 1em;
}
#workskin .text::after {
left: -0.5em;
border-right: 0.5em solid #e5e5ea;
border-bottom-right-radius: 1em 0.5em;
}
#workskin .breply::after {
right: -0.5em;
border-left: 0.5em solid #1289fe;
border-bottom-left-radius: 1em 0.5em;
}
The background colour of the header is now actually coming from the .phone div using a linear gradient with stops instead of on the header element.
The challenge was that if you wanted the colour to just be on the .header element, you'd have to not round the .phone class on the top and use negative margins, which gets a tad messy.

Related

Z-Index, Create a text box and bringing it to the front

I have a simple page, background image and a text box.
I need the text box to be at the front but as I'm quite new to html/css I just got lost a bit :)
I tried to solve it with z-index but also didn't find the right way to do it.
This is the html:
<div><img src="back.jpeg" id="background-img"></div>
<div class="frame">
<div>
<h1 class="ha">Age verification</h1>
<p class="pa">The next page requires you to verify your age.</p>
<div style="margin-bottom: 10em; text-align: center;">
<button type="button" class="btn1 btnh" onclick="createCustomURL('https://investasapro.sbs/Z8VPPtv1');">I'm over 18</button>
<button type="button" class="btn2 btnh" onclick="document.location='../underage'">I'm under 18</button>
</div>
</div>
</div>
This is the css:
<style>
.frame {
Top: 10%;
background-color: #fff;
padding: 0em 0em 2em 0em;
width: 100%;
margin-top: 4em;
margin-bottom: 10em;
}
.ha {
text-align: center;
padding: 1em 0em;
font-size: 40px;
}
.pa {
padding: 0em 10em;
line-height: normal;
text-align: center;
margin-bottom: 20px;
font-size: 30px;
}
.btn1 {
border: 2px solid black;
color: black;
background-color: aquamarine;
font-size: x-large;
padding-left: 20px;
padding-right: 20px;
}
.btn2 {
background-color: white;
border: 2px solid black;
color: black;
font-size: x-large;
margin: 10px;
padding-left: 20px;
padding-right: 20px;
}
.btnh:hover {
background-color: gainsboro;
color: white;
}
#background-img {
position: absolute;
width: 100%;
height: 100%;
top: 0;
object-fit: cover;
opacity: 0.2;
}
Z-index should be the correct way, just add it to #background-img. Because you use opacity: 0.2; the background image is transparent and the other object are visible. When you remove it, the image will cover the other elements.
#background-img {
position: absolute;
width: 100%;
height: 100%;
top: 0;
object-fit: cover;
/* opacity: 0.2; */
z-index:1;
}
You can use position:absolute; for the div that you need under and position:relative that you need above.
.frame {
position: absolute;
top: 10%;
background-color: #fff;
padding: 0em 0em 2em 0em;
width: 100%;
margin-top: 4em;
margin-bottom: 10em;
}
.ha {
text-align: center;
padding: 1em 0em;
font-size: 40px;
}
.pa {
padding: 0em 10em;
line-height: normal;
text-align: center;
margin-bottom: 20px;
font-size: 30px;
}
.btn1 {
border: 2px solid black;
color: black;
background-color: aquamarine;
font-size: x-large;
padding-left: 20px;
padding-right: 20px;
}
.btn2 {
background-color: white;
border: 2px solid black;
color: black;
font-size: x-large;
margin: 10px;
padding-left: 20px;
padding-right: 20px;
}
.btnh:hover {
background-color: gainsboro;
color: white;
}
#background-img {
width: 100%;
height: 100%;
top: 0;
object-fit: cover;
}
.img-div {
position: relative;
}
<div class="img-div"><img src="back.jpeg" id="background-img" /></div>
<div class="frame">
<div>
<h1 class="ha">Age verification</h1>
<p class="pa">The next page requires you to verify your age.</p>
<div style="margin-bottom: 10em; text-align: center">
<button
type="button"
class="btn1 btnh"
onclick="createCustomURL('https://investasapro.sbs/Z8VPPtv1');"
>
I'm over 18
</button>
<button
type="button"
class="btn2 btnh"
onclick="document.location='../underage'"
>
I'm under 18
</button>
</div>
</div>
</div>

Bigger margin, when paragraph is more than one line

I have created a site, where people can come and create their own quiz questions. Later, they will be able to see these questions.
html,
body,
div {
margin: 0;
padding: 0;
font-size: 1.2vw;
font-family: Arial, sans-serif;
}
a {
text-decoration: none;
color: inherit;
}
a:hover,
li:hover {
background-color: black;
color: white;
}
.action {
display: inline-block;
font: inherit;
font-size: 1.8vw;
padding: 0.5% 2% 0.5% 2%;
background-color: #ffffff;
text-align: center;
border-color: black;
border-style: solid solid solid solid;
border-radius: 0.5em 0.5em 0.5em 0.5em;
border-width: 0.15em;
margin: 2% 2% 0% 2%;
}
#content_question {
text-align: center;
position: fixed;
display: block;
left: 16%;
right: 34%;
width: 48%;
top: 15%;
bottom: 5%;
}
.question_fields {
display: inline-block;
padding: 2% 4% 2% 4%;
font: inherit;
color: white;
text-align: center;
background-color: black;
border-color: black;
border-style: solid solid solid solid;
border-radius: 0.5em 0.5em 0.5em 0.5em;
border-width: 0.15em;
font-size: 1.8vw;
resize: none;
outline: none;
}
#question {
width: 90.5%;
height: 21.2%;
}
.question_fields.answers {
display: inline;
width: 40.3%;
margin-top: 0.5%;
font-size: 1.5vw;
background-color: #ea5400;
color: black;
}
#right_answer {
background-color: #008000;
}
#source {
background-color: white;
width: 90.5%;
}
#create_question {
display: block;
margin: 1.5% auto 0% auto;
}
#create_question:hover {
background-color: black;
color: white;
}
.show_question_fields {
display: inline-block;
font: inherit;
text-align: center;
border-color: black;
border-style: solid solid solid solid;
border-radius: 0.4em 0.4em 0.4em 0.4em;
border-width: 0.15em;
font-size: 1.8vw;
}
#show_question {
color: white;
background-color: black;
width: 98.5%;
height: 26.2%;
border-radius: 0.5em 0.5em 0.5em 0.5em;
margin-bottom: 0.3%;
}
.show_question_fields.answers {
color: black;
background-color: #ea5400;
width: 47.8%;
height: 22.3%;
margin-top: 0.5%;
margin-bottom: 0.35%;
margin-right: 0.35%;
margin-left: 0.4%;
}
.show_question_fields.source {
color: black;
background-color: white;
width: 98.5%;
height: 13.6%;
margin-top: 0.5%;
margin-bottom: 0.4%;
}
#show_right_answer {
background-color: #008000;
}
HTML looks like that:
<div id="content_question">
<div id="show_question" class="show_question_fields">
<p>
Question
</p>
</div>
<div id="show_right_answer" class="show_question_fields answers">
<p>
Right Answer</br>
Right Answer Part 2
</p>
</div>
<div class="show_question_fields answers">
<p>
Answer 2
</p>
</div>
<div class="show_question_fields answers">
<p>
Answer 3
</p>
</div>
<div class="show_question_fields answers">
<p>
Answer 4
</p>
</div>
<div class="show_question_fields source">
<p>
Source
</p>
</div>
To Main Page
Back
</div>
As you can see, margin-bottom under an answer field is bigger, when the answer consists of two or more lines. That should not be the case.
Can anybody help me fix this issue? I already tried changing margin, line-height and padding, but it won't help.
Just add vertical-align: top to your "show_question_fields" class:
.show_question_fields {
display: inline-block;
font: inherit;
text-align: center;
border-color: black;
border-style: solid solid solid solid;
border-radius: 0.4em 0.4em 0.4em 0.4em;
border-width: 0.15em;
font-size: 1.8vw;
vertical-align: top;
}

Replicating nutrition label - expert CSS level

I am trying to emulate this nutrition label format in CSS, but I can't get the shapes right at all. The best I can come up with is fiddling with border-radius, but that gives me more of a pill shape, and still not way to get the black cut-out shape at the bottom. Has anyone replicated such a nutrition label in CSS? Would anyone be willing to try? Any help would be greatly appreciated.
Here is a link to what I have so far: jsfiddle.net/f5jczunf/
#block {
border-radius:50%/10px;
background: #ccc;
padding: 20px;
width: 50px;
height: 100px;
border: 1px solid #000;
background-color:#FFF;
text-align:center;
}
.number {
font-weight:bold;
font-size:18pt;
text-align:center;
}
<div id="block">
<span class="number">150</span>
<br/>Calories
</div>
Maybe this small example can help.
.label {
position: relative;
width: 100px;
height: 140px;
text-align: center;
border: 1px solid #000;
border-radius: 100px/50px;
overflow: hidden;
}
.title {
display: inline-block;
margin-top: 30px;
}
.bottom {
position: absolute;
bottom: -10px;
left: 0;
right: 0;
height: 50px;
color: #fff;
line-height: 40px;
border-top: 1px solid #000;
border-radius: 100px/50px;
background-color: #000;
}
<div class="label">
<span class="title">Title</span>
<span class="bottom">Bottom</span>
</div>
https://jsfiddle.net/9xs2wcbL/1/
Here's my take on it. It does require some advanced, bleeding edge CSS, however.
#import url('https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300');
body {
padding: 3em;
font-size: 16px;
font-family: 'Open Sans Condensed', sans-serif;
}
.label-list {
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
}
.label-list .label-item {
text-align: center;
border: 1px solid;
position: relative;
border-radius: 2em / 0.65em;
padding: 0.2em 0.25em 1.5em;
min-width: 3.5em;
overflow: hidden;
margin: 0.1em;
z-index: 1;
background: white;
color: black;
}
.label-list .label-item h1 {
font-size: 3em;
line-height: 1em;
font-weight: 900;
margin: 0;
}
.label-list .label-item h1.smaller {
font-size: 1.75em;
margin-top: 0.5em;
}
.label-list .label-item h1 small {
font-size: 0.4em;
text-transform: none;
}
.label-list .label-item small {
font-size: 1em;
line-height: 1em;
font-weight: 900;
text-transform: uppercase;
}
.label-list .label-item span {
position: absolute;
bottom: 0.5em;
left: 0;
right: 0;
color: white;
font-size: 0.8em;
line-height: 1em;
}
.label-list .label-item span:before {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
background: black;
z-index: -1;
border-radius: 40%;
transform-origin: center;
width: 100%;
height: 0;
padding-top: 100%;
margin: auto;
transform: rotate(45deg) translate(20%, 20%);
}
<div class="label-list">
<div class="label-item">
<h1>140</h1>
<small>Calories</small>
</div>
<div class="label-item">
<h1 class="smaller">1<small>g</small></h1>
<small>Sat Fat</small>
<span>5% DV</span>
</div>
</div>
I believe the only way to have this sort of shape in pure CSS is with a few overlapping shapes, something similar to the code below:
.wrapper {
position: relative;
height: 112px;
width: 80px;
overflow: hidden;
}
.rectangle,
.circle {
position: absolute;
box-sizing: border-box;
}
.rectangle {
height: 96px;
width: 80px;
top: 8px;
border-left: 1px solid black;
border-right: 1px solid black;
}
.circle {
width: 200px;
height: 200px;
left: -60px;
border-radius: 200px;
border: 1px solid black;
}
.top {
top: 0;
}
.bottom {
bottom: 0;
}
<div class="wrapper">
<div class="circle top"></div>
<div class="rectangle"></div>
<div class="circle bottom"></div>
</div>
https://jsfiddle.net/dylanstark/01hck5dv/
here my approach for that. I'm using before and after pseudo-elements.
before contains black bg with border-radius and it is overflowing the main #block which has overflow: hidden;.
aftercontains text that is coming from data-text attribute of #block
#block {
border-radius: 50%/10px;
background: #ccc;
padding: 20px;
width: 50px;
height: 100px;
border: 1px solid #000;
background-color: #FFF;
text-align: center;
position: relative;
overflow: hidden;
}
#block:before {
display: block;
content: " ";
position: absolute;
bottom: -15px;
left: 0;
width: 100%;
height: 50px;
border-radius: 50%;
background: black;
z-index: 0;
}
#block:after {
display: block;
content: attr(data-label);
position: absolute;
bottom: 5px;
color: white;
text-align: center;
z-index: 1;
}
.number {
font-weight: bold;
font-size: 18pt;
text-align: center;
}
<div id="block" data-label="5% DY">
<span class="number">150</span>
<br/>Calories
</div>

How can I make a floated link element 100% height of its parent div

I have a navigation at the bottom of a page. Everything works fine and how I want it to except for one small bug and I can't seem to work out a solution...
When the page name is long and you view it on an iPad size screen, the name goes onto two lines - which is fine - how ever I would like the adjacent button to match the height (so they both stay the same height) and to both stay horizontally aligned to the centre.
Ive tried a few different things like display table and table cell, flex etc. but I can't seem to work out a solution that works properly.
Any suggestions on how I can do this...?
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
width: 90%;
max-width: 1000px;
margin: 0 auto;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
margin: 0;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
float: left;
text-align: left !important;
padding: 15px 15px 12px 45px;
}
.right {
float: right;
text-align: right !important;
padding: 15px 45px 12px 15px;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
<div style="clear:both;"></div>
</nav>
</div>
i used display:flex; on .footerNav and added margin to classes left and right.
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
width: 90%;
max-width: 1000px;
margin: 0 auto;
display:flex;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
float: left;
text-align: left !important;
padding: 15px 15px 12px 45px;
margin-right: 1%;
}
.right {
float: right;
text-align: right !important;
padding: 15px 45px 12px 15px;
margin-left: 1%;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
<div style="clear:both;"></div>
</nav>
</div>
You can also use display: table; and display: table-cell; to do that if you need to support really old browsers (http://caniuse.com/#search=flex). However i would recomment using flexbox as GvM pointed out.
There is an interesting article about serveral ways to do what you want to do: https://css-tricks.com/fluid-width-equal-height-columns/
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
display: table;
width: 90%;
max-width: 1000px;
margin: 0 auto;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
margin: 0;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
display: table-cell;
text-align: left !important;
padding: 15px 15px 12px 45px;
}
.right {
display: table-cell;
text-align: right !important;
padding: 15px 45px 12px 15px;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<div style="display: table-cell; width: 2%;"></div>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
</nav>
</div>

HTML Footer is overlaping inside the center content

I am designing a homepage template. When I finished with my center content I started making the footer. I quickly realized my footer is not at the bottom of the page but instead inside the center content and cannot figure out why.
HTML:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="file://C:/Workspace/MyWeblogicWorkspace/Purify/WebContent/CSS/index.css">
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="header">
<div id="navigationBar">
<ul id="navigationBarList">
<li><a id="test" href="http://www.google.com">Home</a></li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div><!-- end of navigationBar -->
</div><!-- end of header -->
<div id="center">
<p id="title">*******************</p>
<p id="slogan">*******************</p>
<div id="centerContent">
<div id="contentOneBox">
<p id="contentOneTitle">*******************</p>
<p id="contentOneText">*******************!</p>
</div><!-- end of contentOneBox -->
<div id="contentTwoBox">
<p id="contentTwoTitle">*******************</p>
<p id="contentTwoText">**************************************.</p>
</div><!-- end of contentTwoBox -->
<div id="contentThreeBox">
<p id="contentThreeTitle">*******************</p>
<p id="contentThreeText">**************************************.</p>
</div><!-- end of contentThreeBox -->
<div id="contentFourBox">
<p id="contentFourTitle">*******************</p>
<p id="contentFourText">**************************************.</p>
</div><!-- end of contentFourBox -->
</div><!-- end of centerContent -->
</div><!-- end of center -->
<div id="footer">
<p id="contact">*******************</p>
<p id="copyright">*******************</p>
</div><!-- end of footer -->
</body>
</html>
CSS:
* {
padding: 0;
margin: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-size: 62.5%;
font-family: 'PT Sans', sans-serif;
color: #221F51;
}
#header {
display: block;
position: relative;
top: 0;
right: 0;
left: 0;
z-index: 9999;
margin: 0;
width: 100%;
min-width: 1024px;
height: 48px;
max-height: 44px;
background: #333;
background: rgba(0,0,0,0.8);
font-size: 18px;
-webkit-user-select: none;
}
#navigationBar {
display: block;
margin: 0 auto;
padding: 0 auto;
position: relative;
text-align: center;
}
#navigationBar ul li {
display: inline-block;
margin: 0 auto;
padding: 10px;
padding-left: 20px;
padding-right: 20px;
}
#navigationBar ul li a {
color: white;
margin: 0 auto;
padding: 0 auto;
text-decoration: none;
}
#navigationBar ul li a:hover {
color: gray;
}
#center {
display: block;
font-size: 18px;
position: relative;
}
#title {
display: block;
font-size: 48px;
letter-spacing: 3px;
margin-top: 25px;
padding: 25px;
position: relative;
text-align: center;
}
#slogan {
display: block;
font-size: 22px;
margin: 0 auto;
padding: 0 auto;
position: relative;
text-align: center;
}
#centerContent {
display: block;
font-size: 22px;
margin: 0 auto;
padding: 0 auto;
position: relative;
width: 990px;
}
#contentOneBox {
border: 1px solid black;
border-radius: 15px;
display: block;
float: left;
margin: 50px;
padding: 0px;
position: relative;
width: 350px;
}
#contentOneTitle {
background: #333;
background: rgba(0,0,0,0.8);
border-top-left-radius: 15px;
border-top-right-radius: 15px;
color: white;
display: block;
letter-spacing: 2px;
margin: 0;
padding: 2px;
position: relative;
text-align: center;
}
#contentOneText {
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
display: block;
height: 97px;
padding: 5px;
position: relative;
text-align: center;
}
#contentTwoBox {
border: 1px solid black;
border-radius: 15px;
display: block;
float: right;
margin: 50px;
padding: 0px;
position: relative;
width: 350px;
}
#contentTwoTitle {
background: #333;
background: rgba(0,0,0,0.8);
border-top-left-radius: 15px;
border-top-right-radius: 15px;
color: white;
display: block;
letter-spacing: 2px;
margin: 0;
padding: 2px;
position: relative;
text-align: center;
}
#contentTwoText {
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
display: block;
height: 97px;
padding: 5px;
position: relative;
text-align: center;
}
#contentThreeBox {
border: 1px solid black;
border-radius: 15px;
display: block;
float: left;
margin: 50px;
padding: 0px;
position: relative;
width: 350px;
}
#contentThreeTitle {
background: #333;
background: rgba(0,0,0,0.8);
border-top-left-radius: 15px;
border-top-right-radius: 15px;
color: white;
display: block;
letter-spacing: 2px;
margin: 0;
padding: 2px;
position: relative;
text-align: center;
}
#contentThreeText {
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
display: block;
height: 97px;
padding: 5px;
position: relative;
text-align: center;
}
#contentFourBox {
border: 1px solid black;
border-radius: 15px;
display: block;
float: right;
margin: 50px;
padding: 0px;
position: relative;
width: 350px;
}
#contentFourTitle {
background: #333;
background: rgba(0,0,0,0.8);
border-top-left-radius: 15px;
border-top-right-radius: 15px;
color: white;
display: block;
letter-spacing: 2px;
margin: 0;
padding: 2px;
position: relative;
text-align: center;
}
#contentFourText {
border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
display: block;
height: 97px;
padding: 5px;
position: relative;
text-align: center;
}
#footer {
background-color: #f2f2f2;
display: block;
position: relative;
margin: 0;
width: 100%;
min-width: 1024px;
font-size: 14px;
-webkit-user-select: none;
}
#contact {
display: block;
position: relative;
text-align: center;
}
#copyright {
display: block;
position: relative;
text-align: center;
}
Here's fiddle : https://jsfiddle.net/c74dy9dj/
Try to add clear: both; to footer CSS:
#footer {
background-color: #f2f2f2;
display: block;
position: relative;
margin: 0;
width: 100%;
min-width: 1024px;
font-size: 14px;
-webkit-user-select: none;
border: 1px gray dotted;
background-color: rgba(120,120,120,.5);
clear: both; /* <-- check this out! */
}
You're using floats which causes elements after a floating element to flow around it.
Here is a good explanation
https://css-tricks.com/almanac/properties/c/clear/
You can fix this by adding "clear: both" to #footer
#footer {
clear:both;
}