In this lab, I followed the instruction from JavaScript30 and recreated the CSS Variables activity. First off, I made the HTML, CSS, and JavaScript files. Secondly, the <html>, <head>, <body>, <meta>, and <title> tags were already inserted in the HTML file. Thirdly, I typed in <link rel="stylesheet" type="text/css" href="Lab_16.css"> inside the <head> tags to link the CSS file with my HTML file. Fourthly, I typed in <script src="Lab_16.js" type="text/javascript"></script> inside the <body> tags which linked my JavaScript file with my HTML file. Inside the <body> tags, I typed in <div> tags and inside those <div> tags, I typed in <h1>, <h2>, <h3>, and <span> tags that wrote my name, lab number, and date. After that, I inserted another <div> tags that contains <label> and <input> tags. That created the sliders and color picker. Afterwords, I typed in <img>, <br>, and <a> tags that created the picture frame. Lastly, I typed in the copyright notice with <div> and <p> tags. For the CSS I did html {width: 100%; height: auto;} body {background-color: #00FFA8; min-width: 100%; min-height: 100%;} to give the webpage a background color and make the webpage responsive to screen size changes. #heading {text-align: center; font-size: 16px;} to center the heading of the lab. #copyright {font-size: 16px; font-family: Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", "serif"; font-weight: normal; padding-left: 1%; padding-right: 1%;} to change the font of the copyright notice. :root {--base: #0000ff; --spacing: 10px; --blur: 10px;} img {padding: var(--spacing); background: var(--base); filter: blur(var(--blur));}.first {color: var(--base);} .controls {margin-bottom: 50px; text-align: center;} input {width: 100px;} #spacing {cursor: pointer;} #blur {cursor: pointer;} #base {cursor: pointer;} to stylize the canvas and sliders. For the JavaScript I put:
// JavaScript Document
const inputs = document.querySelectorAll('.controls input');
function handleUpdate() {
const suffix = this.dataset.sizing || '';
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
}
inputs.forEach(input => input.addEventListener('change', handleUpdate));
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
This makes the sliders control the blurriness and color of the canvas/image. Knowing how to use CSS variables is useful to a web designer because it allows him/her to do their job more effectively and efficiently.
Link: http://techteach.us/Web2020/ZWeiJian/WCP/Labs/Lab_16/Lab_16.html
No comments:
Post a Comment