css variables 1
global variables
by PK Son
HTML
<section class="ai-section ai-padding_v1">
<div class="ai-row ai-container ai-flex">
<div class="ai-col ai-col_1-2 ai-col_img">
<img src="/url/image_name.jpg" alt="yo image">
</div>
<div class="ai-col ai-col_1-2 ai-col_txt">
<h2 class="txt-color_accent">
This is the h2
</h2>
<p class="txt-color_body">
This is the body text. Lorem ipsum something something dolor, yada yada yada.
</p>
</div>
</div>
</section>
CSS
:root {
--body-color: blue;
--accent-color: red;
--line-height: 1.2;
--margin-unit1: 6rem;
}
h2 {
font-size: 2rem;
margin-top: var(--margin-unit1);
margin-bottom: calc(var(--margin-unit1) * .25);
}
p {
font-size: .9rem;
margin: 1em 0;
}
h2,
p {
line-height: var(--line-height);
}
.txt-color_accent {
color: var(--accent-color);
}
.txt-color_body {
color: var(--body-color);
}
img {
display: block;
background-color: #999;
width: 10rem;
height: 10rem;
}