Skip to content

Instantly share code, notes, and snippets.

@pedrodelgallego
Last active December 14, 2015 19:28
Show Gist options
  • Save pedrodelgallego/5136353 to your computer and use it in GitHub Desktop.
Save pedrodelgallego/5136353 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>Chapter 9: 2 Column Layout - positioning</title>
<link rel="stylesheet" href="style.css" />
<style type="text/css" media="screen">
/* Write here your code */
</style>
</head>
<body>
<div class="container elem">
<span class="label">&lt;div class="container"&gt;</span>
<nav class="elem elem-red">
<span class="label">&lt;nav&gt;</span>
<ul>
<li>
<a href="position-example.html">Home</a>
</li>
<li>
<a href="position-example.html">Contact</a>
</li>
</ul>
<span class="endlabel">&lt;/nav&gt;</span>
</nav>
<section class="elem elem-green">
<span class="label">&lt;section&gt;</span>
<p>
The <code>margin-left</code> style for <code>section</code>s makes sure there is room for the <code>nav</code>.
</p>
<span class="endlabel">&lt;/section&gt;</span>
</section>
<section class="elem elem-green ipsum">
<span class="label">&lt;section&gt;</span>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit.
</p>
<span class="endlabel">&lt;/section&gt;</span>
</section>
<section class="elem elem-green">
<span class="label">&lt;section&gt;</span>
<p>
Notice what happens when you resize your browser. It works nicely!
</p>
<span class="endlabel">&lt;/section&gt;</span>
</section>
</div>
</body>
</html>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.elem {
border: solid #6AC5AC 3px;
position: relative;
}
.elem p {
padding: 0 1em;
}
.elem-inline .label, .elem-inline .endlabel {
position: static;
}
.label, .endlabel {
position: absolute;
background-color: #6AC5AC;
color: #414142;
line-height: 1em;
}
.label {
top: 0;
left: 0;
padding: 0 3px 3px 0;
}
.endlabel {
right: 0;
bottom: 0;
padding: 3px 0 0 3px;
}
.elem-green {
border: solid #FDC72F 3px;
}
.elem-green > .label, .elem-green > .endlabel{
background-color: #FDC72F;
}
.elem-red {
border: solid #D64078 3px;
}
.elem-red > .label, .elem-red > .endlabel{
color: white;
background-color: #D64078;
}
.elem-orange {
border: solid #96C02E 3px;
}
.elem-orange > .label, .elem-orange > .endlabel{
background-color: #96C02E;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment