{"id":430,"date":"2012-09-11T18:00:29","date_gmt":"2012-09-11T18:00:29","guid":{"rendered":"http:\/\/a.parsons.edu\/~dejongo\/12-fall\/?p=430"},"modified":"2024-12-02T18:21:55","modified_gmt":"2024-12-02T18:21:55","slug":"09-the-basics","status":"publish","type":"post","link":"https:\/\/b.parsons.edu\/~dejongo\/09-the-basics\/","title":{"rendered":"09 The Basics"},"content":{"rendered":"<p>We start with the CSS3 additions that were rolled out first: <a href=\"http:\/\/www.w3.org\/TR\/css3-color\/#hsl-color\">HSL color<\/a> <a href=\"http:\/\/www.w3.org\/TR\/css3-color\/#transparency\">transparency<\/a> <a href=\"http:\/\/www.w3.org\/TR\/css3-background\/#corners\">rounded borders<\/a> and <a href=\"http:\/\/www.w3.org\/TR\/css3-background\/#the-box-shadow\">box shadow<\/a>. You can be introduced to the properties here pursue them in the exacting details of the W3.org specification itself or use a <a  href=\"http:\/\/css3generator.com\/\">CSS3 generator<\/a> to create the code for you.<\/p>\n<h2>Hue Saturation and Luminance Color<\/h2>\n<\/p>\n<p>The first specification to be widely implemented CSS3 color includes opacity and the hue saturation and luminance (HSL) color space.<br \/>\n<img decoding=\"async\" style=\"margin: 0 auto;\" src=\"http:\/\/b.parsons.edu\/~dejongo\/12-fall\/stuff\/09-HSL-illustration.jpg\"\/>\n<\/p>\n<p><a href=\"http:\/\/www.w3.org\/TR\/css3-color\/#hsl-color\">HSL<\/a> takes three values: <strong>Hue<\/strong> is a degree on the color wheel from 0 to 360 where 0 is red 180 is green and 240 is blue and 360 is red again. So is 720 or any other multiple of 360 \u2014 the colors repeat.\n<\/p>\n<p><strong>Saturation<\/strong> is a percentage value: 100% is full saturation and 0% is no saturation. Saturation works in conjunction with luminance. <\/p>\n<table style=\"float: right; margin-left: 60px; width: 45%; border: 1px solid #808080;\">\n<tr style=\"font-weight: 700;\">\n<th>Hexadecimal<\/th>\n<th>Percent<\/th>\n<\/tr>\n<tr style=\"background: hsl(0 0% 0%); color: #fff;\">\n<td style=\"letter-spacing: .1em;\">#000<\/td>\n<td>0%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 7%); color: #fff;\">\n<td style=\"letter-spacing: .2em;\">#111<\/td>\n<td>7%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% \/ 13%); color: #fff;\">\n<td style=\"letter-spacing: .1em;\">#222<\/td>\n<td>13%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 20%); color: #fff;\">\n<td style=\"letter-spacing: .2em;\">#333<\/td>\n<td>20%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 27%); color: #fff;\">\n<td style=\"letter-spacing: .1em;\">#444<\/td>\n<td>27%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 33%); color: #fff;\">\n<td style=\"letter-spacing: .2em;\">#555<\/td>\n<td>33%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 40%); color: #fff;\">\n<td style=\"letter-spacing: .1em;\">#666<\/td>\n<td>40%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 47%); color: #fff;\">\n<td style=\"letter-spacing: .2em;\">#777<\/td>\n<td>47%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 50%); color: #fff;\">\n<td style=\"letter-spacing: .1em;\">#808080<\/td>\n<td>50%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 53%); color: #fff;\">\n<td style=\"letter-spacing: .1em;\">#888<\/td>\n<td>53%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 60%); color: #000;\">\n<td style=\"letter-spacing: .1em;\">#999<\/td>\n<td>60%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 67%); color: #000;\">\n<td style=\"letter-spacing: .2em;\">#aaa<\/td>\n<td>67%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 73%); color: #000;\">\n<td style=\"letter-spacing: .2em;\">#bbb<\/td>\n<td>73%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 80%); color: #000;\">\n<td style=\"letter-spacing: .3em;\">#ccc<\/td>\n<td>80%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 87%); color: #000;\">\n<td style=\"letter-spacing: .2em;\">#ddd<\/td>\n<td>87%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 93%); color: #000;\">\n<td style=\"letter-spacing: .3em;\">#eee<\/td>\n<td>93%<\/td>\n<\/tr>\n<tr style=\"background: hsl(0 0% 100%); color: #000;\">\n<td style=\"letter-spacing: .4em;\">#fff<\/td>\n<td>100%<\/td>\n<\/tr>\n<\/table>\n<p><strong>Luminance<\/strong> is also a percentage; 0% is dark (black) 100% is light (white) and 50% allows for full chroma before it is made lighter or darker. The table on the right gives percentages of grey translated from hexadecimal or base 16 with middle grey being <code>#808080<\/code>.\n<\/p>\n<p>Connecting up the color with the degree is the least intuitive part of this more intuitive way to think about color but it is preferred over the RGB method of specifying a color. With <em>hsl<\/em> it is easy to increase the saturation or luminance for a particular hue something that is not at all intuitive using RGB. <\/p>\n<h2>Opacity<\/h2>\n<\/p>\n<p>CSS3 also added the alpha property <a href=\"http:\/\/www.w3.org\/TR\/css3-color\/#transparency\">transparency<\/a> or opacity or alpha which can be combined with color to change RGB to RGBA and HSL to hsl. The value range is from 0 to 1 with 0 being transparent and 1 being opaque. That makes .5 half way transparent. <code>color: hsl(0 50% 50% \/.5);<\/code> You can make any element transparent by using the <code>opacity<\/code> property.\n<\/p>\n<p>To help you see the relation between the HLS and opacity change the numbers in this demo. I&#8217;m sure you have a favorite color or color combination. Try changing some of these colors to your favorite colors:<\/p>\n<div class=\"handson_demo\">\n<h3>CSS Code View<\/h3>\n<pre>\r\n<style contenteditable=\"true\">\r\n#align div:first-child {\r\ncolor: hsl(0 100% 100% \/ 1);\r\nborder: 20px solid hsl(90 100% 60% \/ 1);\r\nbackground-color: hsl(70 100% 30% \/ 1);\r\ntext-align: right; font-weight: 700;\r\nwidth: 250px; height: 250px;\r\npadding: 5px; \r\nposition: relative; right: 5px; top: 50px;\r\n}\r\n#align div:last-child {\r\ncolor: hsl(0 100% 0% \/ 1);\r\nborder: 20px solid hsl(240 100% 50% \/.4);\r\nbackground-color: hsl(180 100% 50% \/.4);\r\ntext-align: right; font-weight: 700;\r\nwidth: 250px; height: 250px;\r\npadding: 5px;\r\ndisplay: table-cell; vertical-align: bottom;\r\nposition: relative; left: 5px; top: -50px;\r\n}\r\n<\/style><\/pre>\n<\/div>\n<div style=\"width: 300px; margin: 20px auto; padding: 10px 20px; border: 3px solid #aaa;background: #eee\" id=\"align\">\n<div>Hue is from 0 to 360\u00b0: <br \/>red=0\u00b0 orange=30\u00b0 <br \/>yellow=60\u00b0 green=120\u00b0 <br \/>cyan=180\u00b0 blue=240\u00b0 <br \/>purple=280\u00b0 magenta=300\u00b0 <br \/>pink=320\u00b0 red=360\u00b0 and so on for the colors repeat. <\/div>\n<div>Saturation is from 0% to 100%. Luminance is from 0% to 100% with 50% being fully saturated. Transparency is from 0 to 1 with 0 being fully transparent and 1 being fully opaque. <\/div>\n<\/div>\n<h2>Pick a Color: hsl Generator<\/h2>\n<\/p>\n<p> <a href=\"http:\/\/mothereffinghsl.com\/\">Mother-effing hsl() by Paul Irish (using the old notation)<\/a><\/p>\n<h2>Border Radius<\/h2>\n<\/p>\n<p><a href=\"http:\/\/www.w3.org\/TR\/css3-background\/#corners\">Rounded corners<\/a> was one of the most requested features and was released early as the work around was complicated and inflexible. We used to create rounded corners by placing a picture of a rounded corner in each of the four corners. No Fun!\n<\/p>\n<p>Using only one value every corner is rounded an equal amount. Using four values each corner can be given its own unique border. Using eight values or two values for each corner its it possible to create asymmetric or oval corners.\n<\/p>\n<p>The individual border-radius property can accept either one or two values expressed as a length or a percentage (percentages refer to the corresponding dimensions of the border box). The individual corner are: <code>border-bottom-left-radius<\/code> <code>border-bottom-right-radius<\/code> <code>border-top-left-radius<\/code> and <code>border-top-right-radius<\/code>.\n<\/p>\n<p> When two values are defined they determine the horizontal and vertical radii of a quarter ellipse separately which in turn determines the curvature of the corner of the outer border edge. When only one value is supplied the horizontal and vertical radii are the same. If either value is zero the corner will be square not round. It is possible to go beyond 100% but that begins to eat into the border itself. I pushed the number to distort the border in Safari\/Chrome as an example.  Play with it and see how it works for you. Check out <a href=\"https:\/\/diana-adrianne.com\"> Diana Smith\u2019s<\/a> <a href=\"https:\/\/diana-adrianne.com\/purecss-francine\/\"> Francine<\/a>. She goes into <a href=\"https:\/\/diana-adrianne.com\/how\/\">how<\/a> she does it, which is worth a read. In it she shows what happens when she <a href=\"https:\/\/diana-adrianne.com\/how\/#noborderradius\"> disengages border radius<\/a> What a difference! She also demos the difference when box shadow and transformation are not engaged.<\/p>\n<div class=\"handson_demo\">\n<h3>CSS Code View<\/h3>\n<pre>\r\n<style contenteditable=\"true\">\r\n#corner div:first-child {\r\nborder: 20px solid #666;\r\nborder-radius: 50% 50%;\r\nwidth: 150px; height: 150px;\r\nmargin-left: 90px;\r\nmargin-bottom: \u221280px;\r\n}\r\n#corner div {\r\nborder: 20px solid #666;\r\nborder-radius: 0% 1000%;\r\nwidth: 150px; height: 150px;\r\n}\r\n#corner div:last-child {\r\nborder: 20px solid #666;\r\nborder-bottom-left-radius: 30% 70%;\r\nborder-bottom-right-radius: 70% 100%;\r\nborder-top-left-radius: 100% 30%;\r\nborder-top-right-radius: 0% 0%;\r\nwidth: 150px; height: 150px;\r\n}\r\n<\/style><\/pre>\n<\/div>\n<div style=\"width: 300px; margin: 20px auto; padding: 10px 20px; border: 3px solid #aaa;background: #eee\" id=\"corner\">\n<div> <\/div>\n<div> <\/div>\n<div> <\/div>\n<\/div>\n<h2>Border Radius Shorthand<\/h2>\n<\/p>\n<p>The border-radius shorthand property can be used to define all four corners simultaneously. If you want to define both horizontal and vertical radii separately for each corner you can do that by first specifying the horizontal for each corner separating them with a slash <code>\/<\/code> and then specifying the vertical radii. For example: <code>border-radius: 30px 80px 30px 80px \/ 80px 30px 80px 30px;<\/code> Don&#8217;t forget that the shorthand code can be further compacted if the values are the same for example: <code>border-radius: 30px 90px \/ 110px;<\/code> The 8 points are masterfully manipulated by the <a href=\"https:\/\/9elements.github.io\/fancy-border-radius\/#70.98.1.38--656.655\"> Interactive Border-Radius Tool<\/a>.<\/p>\n<div class=\"handson_demo\">\n<h3>CSS Code View<\/h3>\n<pre>\r\n<style contenteditable=\"true\">\r\n#corner-sh div:first-child {\r\nborder-radius: 30px 90px \/ 110px;\r\nmargin-left: 90px;\r\nmargin-bottom: \u2212100px;\r\n}\r\n#corner-sh div {\r\nborder: 20px solid #666;\r\nborder-radius: 0px 170px;\r\nwidth: 150px; height: 150px;\r\n}\r\n#corner-sh div:last-child {\r\nborder-radius: 120px 0px 300px 100px \/ 160px 0px 300px 150px;\r\n}\r\n<\/style><\/pre>\n<\/div>\n<div style=\"width: 300px; margin: 20px auto; padding: 10px 20px; border: 3px solid #aaa;background: #eee\" id=\"corner-sh\">\n<div> <\/div>\n<div><\/div>\n<div> <\/div>\n<\/div>\n<h2>Box Shadow<\/h2>\n<\/p>\n<p>Another place that CSS3 has removed the need for additional images is the drop shadow. The browser will handle multiple <a href=\"http:\/\/www.w3.org\/TR\/css3-background\/#the-box-shadow\">shadows<\/a> on both the inside and the outside of the box. The property <code>box-shadow:<\/code> takes up to five values, one each for x-offset y-offset blur radius spread distance and color.\n<\/p>\n<p>By default the value for box-shadow is none. If only one number is supplied it determines a drop shadow with the same horizontal and vertical offset and the default color which is black. You can specify the horizontal and vertical distances separately add an optional blur distance and a spread distance as well as the color: <code>box-shadow: 0px 0px 15px 5px #966;<\/code>. <\/p>\n<div class=\"handson_demo\">\n<h3>CSS Code View<\/h3>\n<pre>\r\n<style contenteditable=\"true\">\r\n#shdw div:first-child {\r\nborder-radius: 50% 50%; border: none;\r\nwidth: 150px; height: 150px;\r\nmargin: 10px auto;\r\nbox-shadow: 8;\r\n}\r\n#shdw div {\r\nborder: 20px solid #666;\r\nborder-radius: 0% 1000%; border: none;\r\nwidth: 150px; height: 150px;\r\nmargin: 10px auto;\r\nbox-shadow: 8px 8px 8px #666;\r\n}\r\n#shdw div:last-child {\r\nborder-radius: 0;\r\nwidth: 150px; height: 150px;\r\nmargin: 0 auto;\r\nbackground: #ded;\r\nbox-shadow: 0px 0px 15px 5px #966;\r\n}\r\n<\/style><\/pre>\n<\/div>\n<div style=\"width: 300px; margin: 20px auto; padding: 10px 20px; border: 3px solid #aaa;background: #eee\" id=\"shdw\">\n<div> <\/div>\n<div> <\/div>\n<div> <\/div>\n<\/div>\n<p>By default the shadows are on the outside of the box but it&#8217;s possible to place them on the inside of the box by specifying <code>inset<\/code>. If the inset is in addition to the regular shadow, you need to add a comma <code>,<\/code> The code for the 3D looking ball then looks like this: <code>box-shadow: 40px 40px 50px -20px #444, inset -40px -40px 50px 25px #666; <\/code>.<\/p>\n<div class=\"handson_demo\">\n<h3>CSS Code View<\/h3>\n<pre>\r\n<style contenteditable=\"true\">\r\n#shdwi div:first-child {\r\nborder-radius: 50% 50%; border: none;\r\nbox-shadow: 40px 40px 50px -20px #444, inset -40px -40px 50px 25px #666;\r\n}\r\n#shdwi div {\r\nborder: 20px solid #666;\r\nborder-radius: 0% 1000%; border: none;\r\nwidth: 150px; height: 150px;\r\nmargin: 10px auto;\r\nbox-shadow: 8px 8px 8px #666, inset 8px 8px 8px #666;\r\n}\r\n#shdwi div:last-child {\r\nborder-radius: 0;\r\nbackground: #ded;\r\nbox-shadow: 0px 0px 15px 5px #966, inset 0px 0px 15px 5px #966;\r\n}\r\n<\/style><\/pre>\n<\/div>\n<div style=\"width: 300px; margin: 20px auto; padding: 10px 20px; border: 3px solid #aaa;background: #eee\" id=\"shdwi\">\n<div> <\/div>\n<div> <\/div>\n<div> <\/div>\n<\/div>\n<p>Multiple shadows, each on its own layer, can be created using a comma <code>, <\/code>. Learn more about <a href=\"https:\/\/css-tricks.com\/getting-deep-into-shadows\/\">shadows at CSS-Tricks<\/a>. <\/p>\n<div class=\"handson_demo\">\n<h3>CSS Code View<\/h3>\n<pre>\r\n<style contenteditable=\"true\">\r\n\r\n#shc div {\r\nborder: 20px solid #666;\r\nborder-radius: 50%; border: none;\r\nwidth: 150px; height: 150px;\r\nmargin: 10px auto;\r\nbox-shadow: inset 40px 40px 20px -20px orange, inset -40px 60px 50px 25px red, inset 58px 58px 20px 28px purple, -30px -20px 70px 90px blue;\r\n}\r\n<\/style><\/pre>\n<\/div>\n<div style=\"width: 300px; margin: 130px auto 60px; padding: 10px 20px; border: 3px solid #aaa;background: #eee\" id=\"shc\">\n<div> <\/div>\n<\/div>\n<h2>Combining All of These Techniques<\/h2>\n<div class=\"handson_demo\">\n<h3>CSS Code View<\/h3>\n<pre>\r\n<style contenteditable=\"true\">\r\n#glow {\r\nbackground: hsl(0 0% 93%);\r\nborder: 1px solid hsl(0 0% 67%)\r\n}\r\n#glow div {\r\nmargin: 30px auto;\r\npadding: 30px;\r\nborder-radius: 200em \/ 50em;\r\nborder: 3px solid hsl(0 30% 0% \/.3);\r\nbackground: hsl(0 50% 50% \/.3);\r\nbox-shadow: 0px 0px 150px hsl(180 70% 80% \/.8), inset 0px 0px 50px hsl(260 100% 60% \/.9);\r\n}\r\n#glow h3{\r\ntext-align: center;\r\nmargin-top: 25px; \r\npadding: 5px;\r\nborder-radius: 200em \/ 50em;\r\nborder: 3px solid hsl(200 100% 50% \/.7);\r\nbackground: hsl(0 0% 100% \/.8);\r\nbox-shadow: 0px 0px 20px hsl(60 100% 80% \/.6);\r\n}\r\n<\/style><\/pre>\n<\/div>\n<div id=\"glow\" style=\"padding: 50px; \">\n<div>\n<div>\n<h3>CSS3 hsl Border Radius &#038; Glow<\/h3>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We start with the CSS3 additions that were rolled out first: HSL color transparency rounded borders and box shadow. You can be introduced to the properties here pursue them in the exacting details of the W3.org specification itself or use &hellip; <a href=\"https:\/\/b.parsons.edu\/~dejongo\/09-the-basics\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/posts\/430"}],"collection":[{"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/comments?post=430"}],"version-history":[{"count":42,"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/posts\/430\/revisions"}],"predecessor-version":[{"id":6342,"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/posts\/430\/revisions\/6342"}],"wp:attachment":[{"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/media?parent=430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/categories?post=430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/b.parsons.edu\/~dejongo\/wp-json\/wp\/v2\/tags?post=430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}