In this lesson, we will build a respnsive web page.
At the bottom of this page there is a code editor pre-loaded with the
lesson's code.
* {
box-sizing: border-box;
}
[class*="col-"] {
float: left;
padding: 15px;
}
.row::after {
content: "";
clear: both;
display: table;
}
/***** RESPONSIVE DESIGN CSS*****/
/* For Small Devices*/
[class*="col-"] {
width: 100%;
}
/* For Large Devices*/
@media only screen and (min-width: 768px) {
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
}
/***** HEADER CSS: top menu, logo, page heading*****/
/* Container for Page Header*/
.topContainer{
width: 97%;
margin-left: 1.5%;
background-color: #050937;
box-shadow: 4px 4px 2.5px black;
border-radius: 9px;
}
/* Page Heading*/
.headline{
display: inline-block;
color: #FFECD8;
float: right;
}
/*Top Menu*/
.topMenu {
overflow: hidden;
background-color: #820808;
border-radius: 9px;
}
/* Links in the Top Menu*/
.topMenu a {
float: left;
display: block;
color: #E7F0D8;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
Related Lessons: CSS Links, CSS Menus, CSS Align & Position, HTML divs, CSS Colors, CSS Padding, CSS Fonts
/* On mouse hover: unvisited links*/
.topMenu a:hover {
background-color: blue;
color: lightyellow;
}
/* On mouse hover: visited links*/
.topMenu a:visited:hover {
background-color: blue;
color: lightyellow;
}
Related Lessons: CSS Links, CSS Colors
/* Header image*/
img.topImage {
max-width: 150px;
float: left;
}
/******* PAGE BODY********/
body {
background-color: #F0D2CB;
color: #02052A;
font-family: helvetica, arial, sans-serif;
font-size: 16px;
}
/* Link inside paragraphs*/
p a {
color: red;
}
Related Lesson: CSS Links, HTML paragraphs
/* Labels*/
.myLable {
color: #050937;
font-size: 26px;
font-weight:800;
}
.redLable {
color: darkred;
font-size: 26px;
font-weight: 800;
}
/* side logos*/
img.side {
display: inline-block;
width: 80%;
float: center;
}
/* Bordered Container*/
div.bordered {
font-size: 18px;
font-weight: bold;
color: #09326B;
background-color: white;
border-style: solid;
border-color: #09326B;
border-width: 4px;
padding: 10px;
}
/******* SIDE NAVIGATION******/
/* unordered list: "sideMenu"*/
ul.sideMenu {
list-style-type: none;
padding-top:20px;
padding-bottom: 20px;
}
/* links in "sideMenu" unordered lists*/
ul.sideMenu a {
display:block;
width = 70%;
border-style: solid;
border-width: 1px;
border-color: red;
padding: 5px;
font-size: 20px;
background-color: #050937;
color: white;
border-radius: 18px;
text-decoration: none;
padding: 5px;
margin: 5px;
text-align: center;
}
/* on hover: links in ul class = "sideMenu"*/
ul.sideMenu a:hover {
background-color: red;
}
/****** FORM CONTAINER*****/
form.signUp {
border-style: double;
border-color: #050937;
border-width: 1px;
color: #050937;
padding-left: 15px;
padding-bottom: 15px;
}
<!DOCTYPE html>
<html lang="en-us">
<head>
<!-- Meta Viewport-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS Stylesheet -->
<link rel="stylesheet" type="text/css" href="responsive.css">
<!-- Font Awesome Stylesheet: Social Media (and other) icons: http://fontawesome.io/ -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Page Title-->
<title>Coding Commanders</title>
</head>
<body>
<!--- HEADER------------------------>
<div class = 'topContainer'>
<!-- Top Menu-->
<div class = 'topMenu'>
<a href = 'https://www.youtube.com/channel/UC-gCUMK_EGUqJ7P9VA7BJmQ' class='fa fa-youtube'> YouTube</a>
<a href='https://www.facebook.com/codingcommanders/' class='fa fa-facebook'> Facebook</a>
<a href='https://www.instagram.com/codingcommanders' class='fa fa-instagram'> Instagram</a>
<a href='https://twitter.com/codingCommander' class = 'fa fa-twitter'> Twitter</a>
<a href='https://plus.google.com/102944579677628755090' class='fa fa-google'> Google+</a>
<a href='https://github.com/codingCommanders/' class='fa fa-github'> Github</a>
<a href = "photoGallery.php" class="fa fa-camera" aria-hidden="true"> Photos</a>
</div>
<div class = 'row'>
<div class = 'col-4'>
<!-- Logo-->
<img class = "topImage" src = 'usaLogo.png'>
</div>
<div class = 'col-6'>
<!-- Heading-->
<div class = 'headline'>
<h1>Coding Commanders: Annihilating Bugs</h1>
<strong><i>One line of code at a time...</i></strong>
</div>
</div>
</div>
<br><br>
</div>
<!--- MAIN CONTENT------------------------>
<!-- Row 1-->
<div class = "row">
<p align = "center">Coding Commanders uses web development to fight the alien-bug invasions. We believe Earth should, once again,
belong to the humans. Join the fight! The Human Resistance is currently recruiting Coding Cadets.</p>
</div>
<!-- Row 2-->
<div class = "row">
<!-- Column 1, takes up 3/12 horizontal space-->
<div class = "col-3">
<img class = "side" src = "Logo2.png">
</div>
<!-- Column 2, takes up 6/12 horizontal space-->
<div class = "col-6">
<div class = "bordered">
<label class = "myLable">Coding Cadet Benefits</label><br>
<ol>
<li>You will learn full stack web development.</li>
<li>It's fun! Writing code is like playing a strategy game or solving a puzzles.</li>
<li>You will be a hero. Humanity wants Earth back and the Bugs gone. By joining Coding Commanders you will be a hero.</li>
<li>You get to help people.</li>
<li>You get to annihilate bugs!</li>
</ol>
<p align = "center">Together we can debug Earth!</p>
</div>
</div>
<div class = "col-3">
<img class = "side" src = "fullLogo.png">
</div>
</div>
<!-- Row 3-->
<div class = "row">
<!-- Side Menu: Column 1, takes up 3/12 horizontal space-->
<div class = "col-3">
<ul class = "sideMenu">
<label class = "redLable"> Try HTML</label>
<li><a href="htmlL/element.php">What is an element? </a> </li>
<li><a href="htmlL/heading.php">Headings</a> </li>
<li><a href="htmlL/links.php">Links</a> </li>
<li><a href="htmlL/media.php">Media</a> </li>
<li><a href="htmlL/paragraphs.php">Paragraph</a> </li>
<li><a href="htmlL/span.php">Span</a> </li>
<li><a href="htmlL/list.php">List</a> </li>
</ul>
<ul class = "sideMenu">
<label class = "redLable"> Try CSS</label>
<li><a href="cssL/css.php">What is CSS?</a> </li>
<li><a href="cssL/colors.php">Colors</a> </li>
<li><a href="cssL/font.php">Font</a> </li>
<li><a href="cssL/list.php">Lists</a> </li>
<li><a href="cssL/border.php">Border</a> </li>
</ul>
<ul class = "sideMenu">
<label class = "redLable"> Try PHP</label>
<li><a href="phpL/datatypesM.php">Data Types</a> </li>
<li><a href="phpL/echoM.php">Echo</a> </li>
<li><a href="phpL/mathOperators.php">Math Operator</a> </li>
<li><a href="phpL/stringOperators.php">String Operator</a> </li>i>
</ul>
</div>
<!-- Column 2, takes up 6/12 horizontal space-->
<div class = "col-6">
<!-- Sign up Form-->
<form class = "signUp" method = 'post' action = 'signUp.php'>
<!-- Heading-->
<h1>The Human Resistance Sign Up<</h1>
<!-- Text imput fields-->
<h4>First Name</h4>
<input type= "text" name= "firstName" placeholder= "First Name" required><br>
<h4>Last Name</h4>
<input type="text" name= "lastName" placeholder= "Last Name" ><br>
<h4>Email</h4>
<input type= "email" name= "userEmail" placeholder= "youremail@email.com" required><br>
<!-- Select-->
<h4>Which volunteer squad will you be joining?</h4>
<select name = "squad" >
<option></option>
<option for = "squad" value = "4">Infintry</option>
<option for = "squad" value = "3">Child Protection</option>
<option for = "squad" value = "2">Domestic</option>
<option for = "squad" value = "1">Research</option>
</select>
<br>
<!-- Radio buttons-->
<h4>How many Bugs have you annihilated?</h4>
<input type = "radio" name = "exp" value = "1">None<br>
<input type = "radio" name = "exp" value = "2">Less than 10<br>
<input type = "radio" name = "exp" value = "3">Less than 100<br>
<input type = "radio" name = "exp" value = "4">Over 100<br>
<br>
<!-- Submit Button-->
<input type="submit" value="Submit">
</form>
</div>
<!-- Column 3, 3/12 horizontal space-->
<div class = "col-3">
<br><br><br>
<div class = "bordered">
Save our children!<br>
Save humanity!<br>
Save Earth!<br>
</div>
<br><br><br>
<div class = "bordered">
<h3>Let's debug!</h3>
</div>
<br><br><br>
<div class = "bordered">
<h3>Let's debug!</h3>
</div>
</div>
</div>
</body>
</html>
Finish the Ad Project. Make all the pages responsive.
Part I: Explained on the bottom of CSS Color Lesson.
AND
Part II: Explained on the bottom of CSS Links Lesson.