Introduction#
part 4 chapter 12 on contrast and color html book, see demo here
HTML#
the html page
<body><nav class="nav-container"><div class="nav-container__inner"><a href="#" class="home-link">Ink</a><ul class="top-nav"><li><a href="#">Features</a></li><li><a href="#">Pricing</a></li><li><a href="#">Support</a></li><li class="top-nav__featured"><a href="#">login</a></li></ul></te></nav><div class="hero"><div class="hero__inner"><h2>Team collaboration done right</h2><a href="#" class="button button--cta">Get started</a></div></div><div class="container"><div class="title-row"><div class="title"><h4>Work together, even if you're apart</h4><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi maiores, officiis ea beatae aut quod nihil voluptatem ab asperiores dolore nesciunt velit dicta vel iusto aspernatur consectetur magnam consequatur similique!</p><a href="#" class="button">Read more</a></div><div class="title"><h4>Work together, even if you're apart</h4><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi maiores, officiis ea beatae aut quod nihil voluptatem ab asperiores dolore nesciunt velit dicta vel iusto aspernatur consectetur magnam consequatur similique!</p><ul class="tag-list"><li>Web</li><li>iOS</li><li>Android</li><li>Window Phone</li></ul><a href="#" class="button">Read more</a></div><div class="title"><h4>Work together, even if you're apart</h4><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi maiores, officiis ea beatae aut quod nihil voluptatem ab asperiores dolore nesciunt velit dicta vel iusto aspernatur consectetur magnam consequatur similique!</p><a href="#" class="button">Read more</a></div></div></div><footer class="page-footer"><div class="page-footer__inner">Copyright © 2023 entest, Inc.</div></footer></body>
Color Variables#
primary color and its variants, by using variables, we can reuse, update and maintain much easier
html {--brand-green: #076448;--dark-green: #099268;--medium-green: #20c997;--text-color: #212529;--gray: #868e96;--light-gray: #f1f3f5;--extra-light-gray: #f8f8fa;--white: #fff;}
Navbar with Constrast#
<nav class="nav-container"><div class="nav-container__inner"><a href="#" class="home-link">Ink</a><ul class="top-nav"><li><a href="#">Features</a></li><li><a href="#">Pricing</a></li><li><a href="#">Support</a></li><li class="top-nav__featured"><a href="#">login</a></li></ul></div></nav>
and css
.nav-container {background-color: var(--medium-green);}.nav-container__inner {display: flex;justify-content: space-between;align-items: center;max-width: 1080px;margin: 0 auto;padding: 0.625em 0;}.home-link {color: var(--text-color);font-size: 1.6rem;font-family: Georgia, serif;font-weight: bold;text-decoration: none;}.top-nav {display: flex;list-style-type: none;}.top-nav a {display: block;padding: 0.3em 1.25em;color: var(--white);background: var(--brand-green);text-decoration: none;border-radius: 3px;}.top-nav a:hover {background-color: var(--dark-green);}.top-nav__featured > a {color: var(--brand-green);background-color: var(--white);}.top-nav__featured > a:hover {color: var(--medium-green);background-color: var(--white);}.top-nav > li + li {margin-left: 1em;}
Hero and Background Image#
<div class="hero"><div class="hero__inner"><h2>Team collaboration done right</h2><a href="#" class="button button--cta">Get started</a></div></div>
css module following the BEM style to create sub-module and variants
.hero {background-image: url('https://d2cvlmmg8c0xrp.cloudfront.net/web-css/singapore.jpg');background-repeat: no-repeat;background-size: cover;margin-bottom: 2.5rem;}.hero__inner {max-width: 1080px;text-align: right;margin: 0 auto;padding: 5.5625em 12.5em 12.5em 0;}.hero h2 {font-size: 1.95rem;margin-top: 0;margin-bottom: 0.625em;}
Container Content#
<div class="container"><div class="title-row"><div class="title"><h4>Work together, even if you're apart</h4><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi maiores,officiis ea beatae aut quod nihil voluptatem ab asperiores dolorenesciunt velit dicta vel iusto aspernatur consectetur magnam consequatursimilique!</p><a href="#" class="button">Read more</a></div><div class="title"><h4>Work together, even if you're apart</h4><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi maiores,officiis ea beatae aut quod nihil voluptatem ab asperiores dolorenesciunt velit dicta vel iusto aspernatur consectetur magnam consequatursimilique!</p><ul class="tag-list"><li>Web</li><li>iOS</li><li>Android</li><li>Window Phone</li></ul><a href="#" class="button">Read more</a></div><div class="title"><h4>Work together, even if you're apart</h4><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi maiores,officiis ea beatae aut quod nihil voluptatem ab asperiores dolorenesciunt velit dicta vel iusto aspernatur consectetur magnam consequatursimilique!</p><a href="#" class="button">Read more</a></div></div></div>
three colums using flex box
.container {max-width: 1080px;margin: auto;}.title-row {display: flex;}.title-row > * {flex: 1;}.title-row > * + * {margin-left: 1.5625em;}.title {background-color: var(--white);border-radius: 0.3em;}.title > h4 {margin-bottom: 1.5em;}
Button Hover#
when mouse hover the button, it style including background changes
.button {display: inline-block;padding: 0.4em 1em;color: var(--brand-green);border: 2px solid var(--brand-green);border-radius: 0.2em;text-decoration: none;font-size: 1rem;}.button--cta {padding: 0.6em 1em;background-color: var(--brand-green);color: var(--white);border: none;}.button:hover {background-color: var(--dark-green);color: var(--white);}