html
Collapsible element
<details>
<summary>Some text goes here</summary>
... some more text goes here.
</details>
With the
open
attribute<details open>
the details are unfolded by default.
Minimal 2 column layout
<style>
.grid-2col {
display: grid;
grid-template-columns: 2fr 1fr;
gap: 1em
}
.col1 {
grid-column-start: 1;
background-color: red;
padding-left: 1em;
}
.col2 {
grid-column-start: 2;
background-color: green;
padding-left: 1em;
}
</style>
<div class="grid-2col">
<div class="col1">
<p>Some text in the first column.</p>
</div>
<div class="col2">
<p>Some text in the second column.</p>
</div>
</div>
Minimal grid area
<style>
.page-grid {
display: grid;
grid-template-columns: 1fr 2fr;
grid-template-areas:
"h h"
"s m"
"f f";
gap: 1em;
}
.gh {
grid-area: h;
background-color: orange;
}
.gs {
grid-area: s;
background-color: green;
}
.gm {
grid-area: m;
background-color: gray;
}
.gf {
grid-area: f;
background-color: yellow;
}
.nav-items {
display: flex; /* flexbox model => flexible layout on row */
justify-content: space-around; /* align flex boxes horizontally with space around */
align-items: center; /* center flex items vertically */
list-style: none;
}
p {
margin: 1em;
}
</style>
<div class="page-grid">
<div class="gh">
<ul class="nav-items">
<li class="nav-item"><a href="">aa</a></li>
<li class="nav-item"><a href="">bb</a></li>
<li class="nav-item"><a href="">cc</a></li>
</ul>
</div>
<div class="gs">
<p>Some text in the second column.</p>
</div>
<div class="gm">
<p>Some text in the second column.</p>
</div>
<div class="gf">
<p>Some text in the second column.</p>
</div>
</div>
Minimal tabs
<script>
const showTab = (E, T) => {
const TABS = Array.from(document.getElementsByClassName("content"));
TABS.forEach(T => {
T.style.display = "none";
});
document.getElementById(T).style.display = "block";
};
window.onload = () => {
document.getElementById("bTab1").onclick = (E) => {
showTab(E, "tTab1");
};
document.getElementById("bTab2").onclick = (E) => {
showTab(E, "tTab2");
};
}
</script>
<button type="button" id="bTab1">Tab1</button>
<button type="button" id="bTab2">Tab2</button>
<div id="tTab1" class="content" style="display: block;">
<p>Some content goes here ...</p>
</div>
<div id="tTab2" class="content" style="display: none;">
<p>... and there.</p>
</div>
Minimal tags filter
<script>
/// Map HTML elements to display kinds.
const elementToDisplay = (E) => {
switch (E.nodeName) {
case "LI":
return "list-item";
default:
return "block";
}
}
/// Display only elements with tag T.
const showTag = (T) => {
Array.from(document.getElementsByClassName("content")).forEach(E => {
E.style.display = "none";
});
Array.from(document.getElementsByClassName(T)).forEach(E => {
E.style.display = elementToDisplay(E);
});
};
/// Initialize buttons and callbacks.
window.onload = () => {
// Handle to the filter placeholder.
const filter = document.getElementById("filter");
// Create buttons for each tag T.
["arm", "x86", "clear"].forEach(T => {
const btn = document.createElement("button");
btn.innerHTML = T;
btn.onclick = T === "clear"
? (E) => {
showTag("content");
filter.innerHTML = "";
}
: (E) => {
showTag(T);
filter.innerHTML = `<p>filter: <mark>${T}</mark></p>`;
};
document.body.prepend(btn);
});
}
</script>
<div id = "filter"></div>
<ul>
<li class = "content arm">arm 1</li>
<li class = "content arm">arm 2</li>
<li class = "content arm">arm 3</li>
<li class = "content x86">x86 1</li>
<li class = "content x86">x86 2</li>
<li class = "content x86 arm">x86 + arm</li>
</ul>
<div class = "content arm">arm</div>
<div class = "content arm x86">arm x86</div>
<div class = "content x86">x86</div>