{"id":880,"date":"2021-02-06T17:45:07","date_gmt":"2021-02-06T17:45:07","guid":{"rendered":"https:\/\/dft.wiki\/?p=880"},"modified":"2022-02-23T03:25:01","modified_gmt":"2022-02-23T03:25:01","slug":"cascading-style-sheets-css-cheat-sheet","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=880","title":{"rendered":"Cascading Style Sheets (CSS) Cheat Sheet"},"content":{"rendered":"<p>INLINE STYLE<\/p>\n<pre>&lt;h2 <strong>style=\"color: red\"<\/strong>&gt;Header Text&lt;\/h2&gt;<\/pre>\n<p>EMBED STYLE IN HTML<\/p>\n<pre><strong>&lt;style&gt;<\/strong>\r\nh2 {\r\n  color: red;\r\n}\r\n<strong>&lt;\/style&gt;<\/strong><\/pre>\n<p>LINK STYLE TO CSS FILE<\/p>\n<pre>&lt;head&gt;\r\n<strong>&lt;link rel=\"stylesheet\" href=\"styles.css\"&gt;<\/strong>\r\n&lt;\/head&gt;<\/pre>\n<p>STYLING CLASSES<\/p>\n<pre><strong>.className<\/strong> {\r\n  color: red;\r\n}\r\n\r\n&lt;p <strong>class=\"className\"<\/strong>&gt;Paragraph&lt;\/p&gt;\r\n\r\n&lt;p <strong>class=\"classOneName classTwoName\"<\/strong>&gt;Paragraph&lt;\/p&gt;<\/pre>\n<p>SET ID TO ELEMENT<\/p>\n<pre><strong>#elementId<\/strong> {\r\n  color: red;\r\n}\r\n\r\n&lt;p <strong>id=\"elementId\"<\/strong>&gt;Paragraph&lt;\/p&gt;<\/pre>\n<p>STYLE AN TYPE<\/p>\n<pre><strong>[type=\"radio\"]<\/strong> {\r\n  background-color: red;\r\n}\r\n\r\n&lt;input <strong>type=\"radio\"<\/strong>&gt;<\/pre>\n<p>HIERARCHY ORDER (HIGHER TO LOWER)<\/p>\n<ul>\n<li>Inline Style\n<ul>\n<li>&lt;h2 <strong>style=<\/strong>&#8220;color: red&#8221;&gt;header&lt;\/h2&gt;<\/li>\n<\/ul>\n<\/li>\n<li>ID\n<ul>\n<li>&lt;h2 <strong>id=<\/strong>&#8220;idName&#8221;&gt;header&lt;\/h2&gt;<\/li>\n<\/ul>\n<\/li>\n<li>Class\n<ul>\n<li>&lt;h2 <strong>class=<\/strong>&#8220;className&#8221;&gt;header&lt;\/h2&gt;<\/li>\n<\/ul>\n<\/li>\n<li>HTML\n<ul>\n<li>&lt;h2&gt;header&lt;\/h2&gt;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>OVERSIDE ALL OTHER STYLES<\/p>\n<pre>.className {\r\n  color: red <strong>!important<\/strong>;\r\n}<\/pre>\n<p>ABSOLUTE VS RELATIVE UNITIES<\/p>\n<pre>\/\/ absolute size of 25 <strong>pixels<\/strong>\r\n25<strong>px<\/strong>\r\n\/\/ relative to the 1.5 <strong>times the font site<\/strong>\r\n1.5<strong>em<\/strong><\/pre>\n<p>GRIDS<\/p>\n<pre>.a {\r\n  background: lightsalmon;\r\n}\r\n.b {\r\n  background: lightskyblue;\r\n}\r\n.c {\r\n  background: lightpink;\r\n}\r\n.d {\r\n  background: palegreen;\r\n}\r\n.grid {\r\n  width: 100%;\r\n  height: 200px;\r\n  display: grid;\r\n  grid-template-columns: 1fr 1fr 1fr;\r\n  grid-gap: 10px;\r\n}\r\n\r\n&lt;div class=\"grid\"&gt;\r\n  &lt;div class=\"a\"&gt;a&lt;\/div&gt;\r\n  &lt;div class=\"b\"&gt;b&lt;\/div&gt;\r\n  &lt;div class=\"c\"&gt;c&lt;\/div&gt;\r\n  &lt;div class=\"d\"&gt;d&lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>RESPONSIVE LAYOUTS<\/p>\n<pre>.a {\r\n  grid-area: header;\r\n  background: lightsalmon;\r\n}\r\n.b {\r\n  grid-area: menu;\r\n  background: lightskyblue;\r\n}\r\n.c {\r\n  grid-area: content;\r\n  background: lightpink;\r\n}\r\n.d {\r\n  grid-area: footer;\r\n  background: palegreen;\r\n}\r\n.grid {\r\n  width: 100%;\r\n  display: grid;\r\n  grid-template-columns: 1fr;\r\n  grid-template-row: 100 auto 1fr auto;\r\n  grid-gap: 10px;\r\n  grid-template-areas:\r\n  \"header\"\r\n  \"menu\"\r\n  \"content\"\r\n  \"footer\";\r\n}\r\n@media (min-width: 300px){\r\n  .grid {\r\n    width: 100%;\r\n    display: grid;\r\n    grid-template-columns: auto 1fr;\r\n    grid-template-row: auto 1fr auto;\r\n    grid-gap: 10px;\r\n    grid-template-areas:\r\n      \"menu header\"\r\n      \"menu content\"\r\n      \"footer footer\";\r\n  }\r\n}\r\n@media (min-width: 450px){\r\n  .grid {\r\n    width: 100%;\r\n    display: grid;\r\n    grid-template-columns: auto 1fr;\r\n    grid-template-row: 100 auto 1fr auto;\r\n    grid-gap: 10px;\r\n    grid-template-areas:\r\n      \"menu header\"\r\n      \"menu content\"\r\n      \"menu footer\";\r\n  }\r\n}\r\n\r\n&lt;div class=\"grid\"&gt;\r\n  &lt;div class=\"a\"&gt;a&lt;\/div&gt;\r\n  &lt;div class=\"b\"&gt;b&lt;\/div&gt;\r\n  &lt;div class=\"c\"&gt;c&lt;\/div&gt;\r\n  &lt;div class=\"d\"&gt;d&lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>Link animation:<\/p>\n<pre>&lt;html&gt;&lt;style&gt;\r\na {\r\n  box-shadow: inset 0 0 0 0 <strong>#ff0000<\/strong>;\r\n  color: <strong>#888888<\/strong>;\r\n  margin: 0 -.25rem;\r\n  padding: 0 .25rem;\r\n  transition: color .3s ease-in-out, box-shadow .3s ease-in-out;\r\n}\r\na:hover {\r\n  box-shadow: inset <strong>300px<\/strong> 0 0 0 <strong>#00ff00<\/strong>;\r\n  color: <strong>#0000ff<\/strong>;\r\n}\r\n&lt;\/style&gt;\r\n&lt;body&gt;&lt;a href=\"http:\/\/\"&gt;&lt;big&gt;Link Animation One&lt;\/big&gt;&lt;\/a&gt;&lt;\/body&gt;&lt;\/html&gt;<\/pre>\n<pre>&lt;html&gt;&lt;style&gt;\r\na {\r\n  position: relative;\r\n}\r\na::before {\r\n  content: '';\r\n  position: absolute;\r\n  width: 100%;\r\n  height: 4px;\r\n  border-radius: 4px;\r\n  background-color: <strong>#ff0000<\/strong>;\r\n  bottom: 0;\r\n  left: 0;\r\n  transform-origin: right;\r\n  transform: scaleX(0);\r\n  transition: transform .3s ease-in-out;\r\n}\r\na:hover::before {\r\n  transform-origin: left;\r\n  transform: scaleX(1);\r\n}\r\n&lt;\/style&gt;\r\n&lt;body&gt;&lt;a href=\"http:\/\/\"&gt;&lt;big&gt;Link Animation Two&lt;\/big&gt;&lt;\/a&gt;&lt;\/body&gt;&lt;\/html&gt;<\/pre>\n<hr \/>\n<p><strong>SEE ALSO<\/strong><\/p>\n<p>Responsive Design [<a href=\"https:\/\/dft.wiki\/?p=887\">Link<\/a>]<\/p>\n<p>JS Cheat Sheet [<a href=\"https:\/\/dft.wiki\/?p=864\">Link<\/a>]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>INLINE STYLE &lt;h2 style=&#8221;color: red&#8221;&gt;Header Text&lt;\/h2&gt; EMBED STYLE IN HTML &lt;style&gt; h2 { color: red; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-880","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/880","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=880"}],"version-history":[{"count":10,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/880\/revisions"}],"predecessor-version":[{"id":2820,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/880\/revisions\/2820"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}