<div class="site">
<header class="site-header"></header>
<main class="site-content">
<div class="left">
<p>menu</p>
<ul>
<li>Top</li>
<li>Page 1</li>
<li>Page 2</li>
</ul>
</div>
<div class="contents">
<div class="menu">
<div class="menu-list">
<div class="menu-item">
<button type="button" class="ghost-button" id="addButton">Add</button>
</div>
<div class="menu-item">
<button type="button" class="ghost-button" id="deleteButton">Delete</button>
</div>
</div>
</div>
<div class="field">
<div class="field-list" id="grid-list">
</div>
</div>
</div>
</main>
<footer class="site-footer">
<p class="footer-content"></p>
</footer>
</div>
*, *:before, *:after {
box-sizing: border-box;
}
html {
height: 100%;
font-size: 16px;
}
body {
margin: 0;
padding: 0;
min-height: 100%;
height: 100%;
}
.site {
min-height: 100vh;
height: 100%;
display: flex;
flex-direction: column;
}
.site-header {
flex: none;
height: 50px;
padding: 5px;
background-color: #444;
}
.site-content {
flex: 1 0 auto;
display: flex;
padding: 0;
}
.site-footer {
flex: none;
height: 30px;
margin: 0;
background: #444;
}
.footer-content {
margin: 0;
padding: 0;
}
.left {
width: 100px;
background: #fac;
}
.contents {
flex: 1;
display: flex;
flex-direction: column;
}
.menu {
height: 40px;
background-color: #d0f4ff;
}
.menu-list {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.menu-item {
flex: 0 0 24px;
height: 24px;
}
.ghost-button {
background: #eee;
color: #444;
border: 1px solid gray;
border-radius: 4px;
cursor: pointer;
text-decoration: none;
margin: 2px;
padding: 0.5rem;
outline: none;
}
.field {
flex: 1 0 auto;
background: #aea;
}
.field-list {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.field-item {
flex: 0 0 160px;
max-width: 320px;
height: 100px;
border: 1px solid #666;
background-color: #ffe;
}
@media (max-width: 380px) {
.left {
display: none;
flex: 0 0 0px;
}
}
@media (max-width: 320px) {
.site, .site-header, .site-footer {
width: 320px;
}
.contents {
flex: 0 0 320px;
background: #abe;
}
}
window.addEventListener('load', function() {
document.getElementById('addButton').addEventListener('click', function() {
var item = document.createElement('div');
item.className = "field-item";
document.getElementById('grid-list').appendChild(item);
}, false);
document.getElementById('deleteButton').addEventListener('click', function() {
var items = document.getElementsByClassName('field-item');
if (items != null && items.length > 0) {
for (var i = items.length - 1; i >= 0; i--) {
items[i].parentNode.removeChild(items[i]);
}
}
}, false);
}, false);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.