{"id":893,"date":"2018-10-31T00:38:17","date_gmt":"2018-10-31T00:38:17","guid":{"rendered":"http:\/\/ucsbwebdev.local\/?p=893"},"modified":"2018-10-31T00:38:17","modified_gmt":"2018-10-31T00:38:17","slug":"css-reference","status":"publish","type":"post","link":"https:\/\/ucsbwebdev.fzilla.com\/?p=893","title":{"rendered":"CSS Reference"},"content":{"rendered":"<p>Let&#8217;s start with some sample div that has a class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;div class=\"nameOfDiv\"&gt;\n    Some text\n&lt;\/div&gt;<\/pre>\n<p>Now in our stylesheet (or in a codepen\u00a0use the CSS section and enter your CSS code) we select this specific div with the\u00a0<strong>.\u00a0<\/strong>selector for class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">.nameOfDiv {\n   \/* We'll enter our declarations here *\/ \n}<\/pre>\n<p>Inside the curly brackets, we can enter a new declaration on each line. Here is a nice overview of the possible properties you can specify:<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 216px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 244px; height: 24px;\"><strong>Declaration key<\/strong><\/td>\n<td style=\"width: 243px; height: 24px;\"><strong>Declaration values<\/strong><\/td>\n<td style=\"width: 244px; height: 24px;\"><strong>Explanation\u00a0of property<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 48px;\">\n<td style=\"width: 244px; height: 48px;\"><span style=\"text-decoration: underline;\">background<\/span><\/td>\n<td style=\"width: 243px; height: 48px;\">black, red, orange, pink, tomato, green, white, etc<\/td>\n<td style=\"width: 244px; height: 48px;\">Sets the background color of our element. It takes in\u00a0a name of a color.<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 244px; height: 24px;\"><span style=\"text-decoration: underline;\">color<\/span><\/td>\n<td style=\"width: 243px; height: 24px;\">same as background, a named color<\/td>\n<td style=\"width: 244px; height: 24px;\">Set the text color of the element (all children of the element will inherit this color!)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 244px; height: 24px;\"><span style=\"text-decoration: underline;\">width<\/span><\/td>\n<td style=\"width: 243px; height: 24px;\">% (of the page) or pixels using px. <strong>30%<\/strong> or <strong>300px<\/strong><\/td>\n<td style=\"width: 244px; height: 24px;\">Sets the horizontal size of our element<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 244px; height: 24px;\"><span style=\"text-decoration: underline;\">height<\/span><\/td>\n<td style=\"width: 243px; height: 24px;\">% (of the page) or pixels using px. <strong>30%<\/strong> or <strong>300px<\/strong><\/td>\n<td style=\"width: 244px; height: 24px;\">Sets the vertical height of our element<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 244px; height: 24px;\"><span style=\"text-decoration: underline;\">padding<\/span><\/td>\n<td style=\"width: 243px; height: 24px;\">Preferably use pixels, but can also take in %. <strong>15px<\/strong><\/td>\n<td style=\"width: 244px; height: 24px;\">Sets the inner padding of an element<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 244px; height: 24px;\"><span style=\"text-decoration: underline;\">margin<\/span><\/td>\n<td style=\"width: 243px; height: 24px;\">Preferably use pixels, but can also take in %. <strong>15px<\/strong><\/td>\n<td style=\"width: 244px; height: 24px;\">Sets the outer margin of an element<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 244px; height: 24px;\"><span style=\"text-decoration: underline;\">display<\/span><\/td>\n<td style=\"width: 243px; height: 24px;\">block, inline, inline-block, flex<\/td>\n<td style=\"width: 244px; height: 24px;\">Allows us to choose how we want our element to display on the page. Flex makes all immediate children into columns.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Now let&#8217;s combine all these declarations inside our CSS selector:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">.nameOfDiv {\n    background: orange;\n    color: white;\n    width: 150px;\n    height: 50px;\n    padding: 15px;\n    margin: 10px;\n    display: inline-block;\n}<\/pre>\n<p>Great, now the result should look like this:<\/p>\n<p id=\"fGJsVEx\"><img decoding=\"async\" class=\"alignnone size-full wp-image-899 \" src=\"http:\/\/ucsbwebdev.local\/wp-content\/uploads\/2018\/10\/img_5bd8de273c672.png\" alt=\"\" \/><\/p>\n<p>If we simply add a couple more div&#8217;s with the same name the result would be:<\/p>\n<p id=\"hhDrkCZ\"><img decoding=\"async\" class=\"alignnone size-full wp-image-900 \" src=\"http:\/\/ucsbwebdev.local\/wp-content\/uploads\/2018\/10\/img_5bd8de5781ff6.png\" alt=\"\" \/><\/p>\n<p>This is thanks to the power of an inline-block element which gets the benefits of block (padding\/margin) and inline by showing multiple elements on the same line!<\/p>\n<p>An alternative way to accomplish the same result without using display inline-block is to use flex. We need to add a parent that wraps the three div&#8217;s\u00a0<strong>nameOfDiv\u00a0<\/strong>and make the parent display\u00a0<strong>flex<\/strong>. Like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;div class=\"flex\"&gt;\n    &lt;div class=\"nameOfDiv\"&gt;Some text&lt;\/div&gt;\t\n    &lt;div class=\"nameOfDiv\"&gt;Some text&lt;\/div&gt;\t\n    &lt;div class=\"nameOfDiv\"&gt;Some text&lt;\/div&gt;\t\n&lt;\/div&gt;<\/pre>\n<p>And the CSS would be:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">.flex {\n    display: flex;\n}\n.nameOfDiv {\n    background: orange;\n    color: white;\n    width: 150px;\n    height: 50px;\n    padding: 15px;\n    margin: 10px;\n}<\/pre>\n<p>Notice that\u00a0<strong>nameOfDiv\u00a0<\/strong>is no longer display inline-block. However, with the flex parent we still see:<\/p>\n<p id=\"UvZruCs\"><img decoding=\"async\" class=\"alignnone size-full wp-image-901 \" src=\"http:\/\/ucsbwebdev.local\/wp-content\/uploads\/2018\/10\/img_5bd8df0ab2189.png\" alt=\"\" \/><\/p>\n<p>Feel free to play with the flex example here\u00a0<a href=\"https:\/\/codepen.io\/agrublev\/pen\/ZqdGXR\" target=\"_blank\" rel=\"noopener\">https:\/\/codepen.io\/agrublev\/pen\/ZqdGXR<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s start with some sample div that has a class: &lt;div class=&#8221;nameOfDiv&#8221;&gt; Some text &lt;\/div&gt; Now in our stylesheet (or in a codepen\u00a0use the CSS section and enter your CSS code) we select this specific div with the\u00a0.\u00a0selector for class: .nameOfDiv { \/* We&#8217;ll enter our declarations here *\/ } Inside the curly brackets, we [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,7,5],"tags":[],"class_list":["post-893","post","type-post","status-publish","format-standard","hentry","category-class-reference","category-css","category-exercises"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=\/wp\/v2\/posts\/893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=893"}],"version-history":[{"count":0,"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=\/wp\/v2\/posts\/893\/revisions"}],"wp:attachment":[{"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ucsbwebdev.fzilla.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}