I am rebuilding the front-end for an application that I am building and have the content laid out the way I need.
I would appreciate any suggestions on how to improve the structure, specifically the header section) with web standards in mind.
You can view the Fiddle here. - edit please ignore the non loading icons in the navigation on jsfiddle.
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* Some CSS Setup - nothing to do with flexbox */
html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }
body { font-family: 'Source Sans Pro', sans-serif; font-size: 1.5em; font-weight: 100; margin: 0; }
body {
background: #FAFAFA;
}
header {
background: white;
}
header h1 {
font-weight: 400;
padding: 1em;
background: #5E35B1;
color: white;
}
#h-wrapper {
display: flex;
justify-content: space-between;
}
nav {
display: flex;
}
nav a {
display: block;
padding: 1em;
border-left: 1px solid lightgray;
color: black;
}
img {
width: 100%;
}
.user-functions,
.user-settings,
.search {
display: none;
width: 100%;
background: #FAFAFA;
padding: 1em;
}
.user-functions.open,
.user-settings.open,
.search.open {
display: block;
}
.user-functions ul li,
.user-settings ul li {
text-align: right;
}
.user-functions ul li a,
.user-settings ul li a {
color: red;
text-decoration: none;
text-transform: uppercase;
font-size: .65em;
display: inline-block;
background: #FFF;
padding: .5em;
margin: .5em 0;
}
.search input {
display: block;
width: 100%;
}
.search button {
display: inline-block;
float: right;
}
#top-rated {
background: #7E57C2;
padding: .5em 1em;
display: flex;
justify-content: space-between;
}
span.top-posts,
span.top-builds {
color: white;
font-size: .65em;
}
.top-posts-toggle,
.top-builds-toggle {
background: #000;
color: white;
padding: 1em;
display: none;
}
.top-posts-toggle.open,
.top-builds-toggle.open {
display: block;
}
.top-posts-toggle ul li a,
.top-builds-toggle ul li a {
color: #ECEFF1;
text-decoration: none;
text-transform: uppercase;
font-size: .65em;
display: inline-block;
background: #455A64;
padding: .5em;
margin: .5em 0;
}
#container {
width: 100%;
}
.post,
.comments {
margin: .5em;
padding: .5em;
background: white;
}
.post h1 a {
text-decoration: none;
display: block;
margin-bottom: .25em;
}
.post ul {
display: flex;
justify-content: space-between;
margin-bottom: .25em;
}
.post ul li a {
text-decoration: none;
font-size: .75em;
background: #80CBC4;
padding: .35em;
display: block;
color: white;
}
.post p,
.comment p {
font-size: .75em;
line-height: 1.15em;
}
.comment {
display: flex;
justify-content: space-between;
border-bottom: #E0E0E0 1px solid;
margin-bottom: .5em;
padding-bottom: .5em;
}
.comment:last-child {
border: 0;
margin: 0;
padding: 0;
}
.comment .avatar {
flex-basis: 15%;
margin-right: .5em;
}
.comment div {
flex-basis: 85%;
}
.comment p a {
text-decoration: none;
margin-bottom: .5em;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BS</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel="stylesheet" href="assets/css/style.css">
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300' rel='stylesheet' type='text/css'>
</head>
<body>
<header>
<div id="h-wrapper">
<h1>BS</h1>
<nav>
<a href="#" class="toggleNav" data-target-id="user-functions"><i class="fa fa-plus"></i></a>
<a href="#" class="toggleNav" data-target-id="user-settings"><i class="fa fa-cog"></i></a>
<a href="#" class="toggleNav" data-target-id="search"><i class="fa fa-search"></i></a>
</nav>
</div>
<div id="user-functions" class="user-functions">
<ul>
<li><a href="#">Create Post</a></li>
<li><a href="#">Create Build</a></li>
</ul>
</div>
<div id="user-settings" class="user-settings">
<ul>
<li><a href="#">Edit My Account</a></li>
<li><a href="#">Profile</a></li>
</ul>
</div>
<div id="search" class="search">
<form>
<input type="text" placeholder="search">
<button>search</button>
</form>
</div>
</header>
<div id="top-rated">
<span class="toggleNav top-posts" data-target-id="top-posts">Top Posts</span>
<span class="toggleNav top-builds" data-target-id="top-builds">Top Builds</span>
</div>
<div id="top-posts" class="top-posts-toggle">
<ul>
<li><a href="#">This is a top post...</a></li>
<li><a href="#">This is another top post...</a></li>
<li><a href="#">How did this become so...</a></li>
<li><a href="#">Maybe we can do this...</a></li>
<li><a href="#">This is a top post...</a></li>
</ul>
</div>
<div id="top-builds" class="top-builds-toggle">
<ul>
<li><a href="#">This is a top build...</a></li>
<li><a href="#">This is another top build...</a></li>
<li><a href="#">How did this become so...</a></li>
<li><a href="#">Maybe we can do this...</a></li>
<li><a href="#">This is a top build...</a></li>
</ul>
</div>
<div id="container">
<article class="post">
<img src="http://www.history-of-cars.com/images/ford-usa/1931-model-a-5window-coupe-old-style-112.jpg" alt="some image" />
<h1><a href="#">1931 Ford 5 Window Coupe</a></h1>
<ul>
<li><a href="#"><i class="fa fa-thumbs-o-up"></i> 23 Likes</a></li>
<li><a href="#"><i class="fa fa-heart-o"></i> 44 Favorites</a></li>
</ul>
<p>Here is a nice ride by Camsnappers Hot Rods & Customs!</p>
</article>
<article class="comments">
<div class="comment">
<div class="avatar">
<img src="https://upload.wikimedia.org/wikipedia/commons/c/cd/Joni_Mitchell_(1975).png" alt="joni mitchell avatar" />
</div>
<div>
<p><a href="#">nucky15</a></p>
<p>What a great pic!</p>
</div>
</div>
<div class="comment">
<div class="avatar">
<img src="https://upload.wikimedia.org/wikipedia/commons/c/cd/Joni_Mitchell_(1975).png" alt="joni mitchell avatar" />
</div>
<div>
<p><a href="#">nucky15</a></p>
<p>Please show us more of your work!</p>
</div>
</div>
<div class="comment">
<div class="avatar">
<img src="https://upload.wikimedia.org/wikipedia/commons/c/cd/Joni_Mitchell_(1975).png" alt="joni mitchell avatar" />
</div>
<div>
<p><a href="#">nucky15</a></p>
<p>Walking on broken glass. The sun is still shining in the big blue sky.</p>
</div>
</div>
</article>
</div>
<script>
var currentOpenId;
// apply handler to all elements with the data-target-id attribute
$('[data-target-id]').click(function(e) {
// prevent default action
e.preventDefault();
// get target id
var id = $(this).data('target-id');
// close previous menu
if (currentOpenId) {
$("#"+currentOpenId).removeClass('open');
}
// open different menu
if (currentOpenId !== id) {
$("#"+id).addClass('open');
currentOpenId = id;
}
// unset id because no menu is open anymore
else {
currentOpenId = null;
}
});
</script>
</body>
</html>