{"id":117,"date":"2017-12-14T14:55:27","date_gmt":"2017-12-14T14:55:27","guid":{"rendered":"https:\/\/jmrowe.com\/blog\/?p=117"},"modified":"2018-01-11T17:35:55","modified_gmt":"2018-01-11T17:35:55","slug":"notes-for-advanced-css-and-sass-udemy-course","status":"publish","type":"post","link":"https:\/\/jmrowe.com\/blog\/notes-for-advanced-css-and-sass-udemy-course\/","title":{"rendered":"Notes for &#8220;Advanced CSS and SASS&#8221; Udemy course"},"content":{"rendered":"<p>The course can be found at :\u00a0<a href=\"https:\/\/www.udemy.com\/advanced-css-and-sass\">https:\/\/www.udemy.com\/advanced-css-and-sass<\/a><\/p>\n<p>To center an absolute item in the middle of its\u00a0 parent ( parent position must be set to relative ) with out using flex-box,the following can be done:<\/p>\n<pre class=\"lang:css decode:true\">.center-item{\r\nposition:absolute;\r\ntop:50%;\r\nleft:50%;\r\ntransform: translate(-50%,-50%);\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The following CSS3 property can be used to make an element not visible until its animation starts by having it&#8217;s 0% keyframe set\u00a0 an opacity to 0. For example:<\/p>\n<pre class=\"lang:css decode:true \">@keyframes animated-frames{\r\n0%{opacity:0;}\r\n\r\n100%{opacity:1;}\r\n}\r\n\r\n.item-to-be-animated {\r\nanimation-fill-mode: backwards;\r\n\r\n\/* The backwards setting will apply what is in the 0% settings\r\nbefore the animation starts. So, the item will have an opacity \r\nof 0 which will make it \"invisible\" until the animation begins. *\/\r\n\r\nanimation:animated-frames .5s ease-out .7s;\r\n\r\n\/* The above animation would use the animated-frames keyframes , \r\nit would take .5seconds to complete, \r\nwould use a ease-out method for it's animation, \r\nand the animation would be delayed before it starts by .7seconds *\/\r\n}<\/pre>\n<h2><strong>How CSS is processed and how styles that will be used will be determined:<\/strong><\/h2>\n<p>!importance -&gt; Specificity &#8211; &gt; order that CSS is loaded ( cascade )<\/p>\n<p><a href=\"https:\/\/jmrowe.com\/blog\/design\/css\/notes-for-advanced-css-and-sass-udemy-course\/attachment\/css-specifty-info\" rel=\"attachment wp-att-124\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-124\" src=\"https:\/\/jmrowe.com\/blog\/wp-content\/uploads\/2017\/12\/css-specifty-info.png\" alt=\"\" width=\"1014\" height=\"529\" srcset=\"https:\/\/jmrowe.com\/blog\/wp-content\/uploads\/2017\/12\/css-specifty-info.png 1014w, https:\/\/jmrowe.com\/blog\/wp-content\/uploads\/2017\/12\/css-specifty-info-300x157.png 300w, https:\/\/jmrowe.com\/blog\/wp-content\/uploads\/2017\/12\/css-specifty-info-768x401.png 768w, https:\/\/jmrowe.com\/blog\/wp-content\/uploads\/2017\/12\/css-specifty-info-624x326.png 624w\" sizes=\"auto, (max-width: 1014px) 100vw, 1014px\" \/><\/a><\/p>\n<h2>How relative values ( %, em, rem, vh , vw ) are converted to absolute values (px)<\/h2>\n<p>Relative values such as em and rem. em for fonts uses the <strong>parent element<\/strong>\u00a0as it&#8217;s reference, em for lengths ( like padding etc ) uses the <strong>current element<\/strong> the\u00a0 while rem uses the <strong>root element\u00a0<\/strong>(html element) for both font and length type values.<\/p>\n<p>Viewport-based<b> : vh<\/b> ( View Height) and <b>vw<\/b>\u00a0(View Width) will use the devices View height\/width to determine the site. So 90vh would be a height of 90% of the viewports height.<\/p>\n<h2>Misc Notes on Inheritance:<\/h2>\n<p><em>initial<\/em>\u00a0keyword resets a property to its initial value ( reset ).<\/p>\n<p>Properties related to text ( font-family, size, color ) are inherited. Things like margin\/padding are not by default. Can force inheritance of a property by using the <em>inherit<\/em> keyword on that property.<\/p>\n<h2>How and why to use rem instead of px<\/h2>\n<p>Set html element (root) font-size property to 10px\u00a0 . This way when using rem in other element properties it is easier to figure out since it is a multiple\/divisible by 10. This creates a good method in case the view point resizes. However, this is bad in the event that the user sets a different font size in their browser. Because of this, it is better to set the html element ( root ) to font-size of 62.5% . It is 62.5% because the default font-size in a browser is 16px. Since we want 10px, we use 10\/16 = .625 or 62.5% for the font-size.<\/p>\n<h2>Box Types ( inline, block, inline-block )<\/h2>\n<p>All determined by the display: property.<\/p>\n<p><strong>\u00a0Block<\/strong><\/p>\n<p>Displayed as blocks. 100% of parent&#8217;s width. Vertically, one after another. Creates line breaks before and after it.<\/p>\n<p><strong>Inline<\/strong><\/p>\n<p>Inline box only occupies just the size it needs. Does not create line breaks. Height and width property do no apply. Can only apply left and right padding and margins.<\/p>\n<p><strong>Inline-block<\/strong><\/p>\n<p>Mostly inline that it only occupies content spaces that is using, does not create line breaks. Block on inside so all margin padding ( top and bottom) can be set.<\/p>\n<h2>Positioning Schemes<\/h2>\n<p><strong>position: relative\u00a0<\/strong><\/p>\n<p>Elements laid out in natural order that is written in code. Not floats or absolutely positioned.<\/p>\n<p><strong>float: left\u00a0 , float: right<\/strong><\/p>\n<p>Element is removed from the normal flow; Text and inline element will wrap around floated element. Container of a floated item will not adjust it&#8217;s height to the element but can use <em>clear:both fixes<\/em><\/p>\n<p><strong>position: absolute; , position:fixed;<\/strong><\/p>\n<p>Element is removed from normal flow. No impact on surrounding contents\/elements. Can use top,bottom, left and right to offset the element from its <strong>relatively positioned<\/strong> contained.<\/p>\n<p><strong>Stacking contexts<\/strong><\/p>\n<p><em>z-index <\/em><\/p>\n<p>higher z-index appears on top, the lower the z-index the lower on the stack.<\/p>\n<h3>SASS<\/h3>\n<p><strong>Variables<\/strong><\/p>\n<p>Can be used to store any type of values, must start with $ &#8211; for example:<\/p>\n<p>$text-color:#f2f2f2;<\/p>\n<p>$button-width:150px;<\/p>\n<p><strong>Nesting<\/strong><\/p>\n<p>Can nest elements\/classes to reduce the need to rewrite certain code. For example:<\/p>\n<pre class=\"lang:css decode:true\">.nav {\r\n  background-color: red;\r\n\r\n  &amp;:hover {\r\n    background-color: darken(yellow, 15%);\r\n  }\r\n  ul {\r\n    width: 100px;\r\n    background-color: yellow;\r\n  }\r\n}\r\n\r\n\r\n\/* Would produce below *\/\r\n\r\n.nav {\r\n  background-color: red;\r\n}\r\n.nav:hover {\r\n  background-color: #b3b300;\r\n}\r\n.nav ul {\r\n  width: 100px;\r\n  background-color: yellow;\r\n}\r\n<\/pre>\n<p><strong>&amp;\u00a0<\/strong>is used to join the pseudo element or state to the element before it. With out\u00a0 it, it would of produced .nav :hover {} instead which is not what was intended.<\/p>\n<p><strong>darken and lighten<\/strong><\/p>\n<p>Color methods in SASS to darken\/lighten a color. First param is the color. Second param is the % you want to adjust it by. i.e.<\/p>\n<p>darken(#f2f2f2,15%); or lighten(#f2f2f2,10%);<\/p>\n<p><strong>Mixin<\/strong><\/p>\n<p>A type function or block of code you can define to use in different areas of your css.<\/p>\n<p>To define a mixin:<\/p>\n<pre class=\"lang:sass decode:true \">@mixin clearfix{\r\n$::after{\r\ncontent:\"\";\r\nclear:both;\r\ndisplay:table; \r\n }\r\n}\r\n\r\n\/**  To use the mixin: **\/\r\n@include clearfix;<\/pre>\n<p>Can also use parameters i.e.<\/p>\n<pre class=\"lang:sass decode:true \">@mixin button-config($color)\r\n{\r\nwidth:150px;\r\nbackground-color:$color;\r\n}<\/pre>\n<h2>Misc Notes<\/h2>\n<p>In order to use scss variables in the <strong>calc()<\/strong> function it must be enclosed within #{ }<\/p>\n<pre class=\"lang:sass decode:true \">.random-class{\r\nwidth:calc((100%-#{$variable-with-a-width-value})\/2);\r\n}<\/pre>\n<p>To make text or a font type icon have a gradient\u00a0 background you can do the following CSS:<\/p>\n<pre class=\"lang:css decode:true\">display:inline-block;\r\nbackground-image:linear-gradient(to-right, $begin-color,$end-color);\r\n-webkit-background-clip:text;\r\ncolor:transparent;<\/pre>\n<p>To use a linear-gradient, you must apply it to the background-image property.<\/p>\n<p><strong>box-decoration-break or -webkit-box-decoration-break<\/strong><\/p>\n<p>If a single line of text i.e. &lt;p&gt; line of text that exceeds more than 1 line&lt;\/p&gt; exceeds a single line.. any padding added to the element would normally not apply to both lines if the element is broken in to two lines. Can use <strong>box-decoration-break:clone;\u00a0<\/strong>to make it so any padding added to the element will be applied to both ( or more ) lines for that element.<\/p>\n<h3>Notes if rotating an object<\/h3>\n<p><strong>perspective &amp; -moz-perspective:\u00a0 \u00a0<\/strong><\/p>\n<p>Add a decent amount of pixels to smooth the rotation to look more natural. Must be added to the parent element.<\/p>\n<p><strong>backface-visibility:hidden;<\/strong><\/p>\n<p>Will make the backside of an element not visible . i.e. if it is <strong>transform: rotateY(180deg);<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The course can be found at :\u00a0https:\/\/www.udemy.com\/advanced-css-and-sass To center an absolute item in the middle of its\u00a0 parent ( parent position must be set to relative ) with out using flex-box,the following can be done: .center-item{ position:absolute; top:50%; left:50%; transform: translate(-50%,-50%); } &nbsp; &nbsp; The following CSS3 property can be used to make an element [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-css"],"_links":{"self":[{"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":32,"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":152,"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/posts\/117\/revisions\/152"}],"wp:attachment":[{"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jmrowe.com\/blog\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}