{"id":5143,"date":"2020-07-14T13:48:00","date_gmt":"2020-07-14T13:48:00","guid":{"rendered":"https:\/\/azoora.com\/blog\/?p=5143"},"modified":"2020-08-21T13:55:20","modified_gmt":"2020-08-21T13:55:20","slug":"css-disco-text","status":"publish","type":"post","link":"https:\/\/azoora.com\/blog\/code\/css-disco-text\/","title":{"rendered":"CSS Disco Text"},"content":{"rendered":"\n<p>Today, we show you how to create something completely useless, but fun! A Disco text, mainly because we want you to know more about explore the <code>hue-rotate<\/code>\u00a0function.<\/p>\n\n\n\n<p>So, <strong>Let&#8217;s get started<\/strong>.<\/p>\n\n\n\n<h2 id=\"heading-html-structure\">01. HTML<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"container\">  &lt;input type=\"checkbox\" \/>  &lt;div>D I S C O&lt;\/div>  &lt;i>click above&lt;\/i>  &lt;span>&lt;\/span>&lt;\/div><\/code><\/pre>\n\n\n\n<p>I&#8217;m going with a very lazy solution today, and we&#8217;ll use an invisible checkbox to get the party started &#x1f973;. Then we have our word which will be the star of the show. And a span for the background effect.<\/p>\n\n\n\n<h2 id=\"heading-css-hue-rotate\">02. CSS<\/h2>\n\n\n\n<p>For this whole assignment, the major element is showcasing the power of the&nbsp;<code>hue-rotate<\/code>&nbsp;filter in&nbsp;<code>CSS<\/code>.<\/p>\n\n\n\n<p>But let&#8217;s start with some of the more basic styling:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.container {  position: relative;  display: flex;  height: 100vh;  align-items: center;  justify-content: center;  flex-direction: column;}<\/code><\/pre>\n\n\n\n<p>The most important part here is the\u00a0<code>relative<\/code>\u00a0position. The other is just basic\u00a0centering with flex.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.container span {  width: 100%;  height: 100%;  background: #efefef;  position: absolute;  z-index: -1;  transition: all 0.5s ease;}<\/code><\/pre>\n\n\n\n<p>As mentioned this span will be our virtual background, so we give it a starting color that&#8217;s grey and position it&nbsp;<code>absolute<\/code>&nbsp;on the whole background. We then add a transition on all effects.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.container div {  position: relative;  width: auto;  background: #1d1e21;  color: #555;  padding: 20px 40px;  display: flex;  justify-content: center;  align-items: center;  font-size: 46px;  cursor: pointer;  margin: 0 4px;  border-radius: 25px;  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);  transition: all 0.5s ease;}<\/code><\/pre>\n\n\n\n<p>Now for our main div, nothing fancy, some general styling to make it look nice.<\/p>\n\n\n\n<p>As mentioned this article uses a checkbox to turn our disco on\/off, we&#8217;ll make the checkbox invisible and across our whole page for ease.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>input[type='checkbox'] {  position: absolute;  opacity: 0;  cursor: pointer;  height: 100%;  width: 100%;  z-index: 100;}<\/code><\/pre>\n\n\n\n<p>Ok, on to the magic part, what happens if we actually click this checkbox:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>input[type='checkbox']:checked ~ span {  background: #333;}<\/code><\/pre>\n\n\n\n<p>First, we make our background span a darker color to &#8220;turn the lights off&#8221;<\/p>\n\n\n\n<p>And then we turn the actually disco effect on:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>input[type='checkbox']:checked ~ div {  box-shadow: 0px 0px 5px rgba(255, 255, 255, 0.5);  color: yellow;  text-shadow: 0 0 15px yellow, 0 0 25px yellow;  animation: glow 5s linear infinite;}<\/code><\/pre>\n\n\n\n<p>The <strong>glow animation<\/strong> is where the <strong>cool effect<\/strong> takes place:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@keyframes glow {  0% {    filter: hue-rotate(0deg);  }  100% {    filter: hue-rotate(360deg);  }}<\/code><\/pre>\n\n\n\n<h4>Finally, the result output is below<\/h4>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-codepen\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"CSS Disco Text\" id=\"cp_embed_JjXGOMv\" src=\"https:\/\/codepen.io\/rebelchris\/embed\/preview\/JjXGOMv?height=300&amp;slug-hash=JjXGOMv&amp;default-tabs=css,result&amp;host=https:\/\/codepen.io\" scrolling=\"no\" frameborder=\"0\" height=\"300\" allowtransparency=\"true\" class=\"cp_embed_iframe\" style=\"width: 100%; overflow: hidden;\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Today, we show you how to create something completely useless, but fun! A Disco text, mainly because we want you to know more about explore the hue-rotate\u00a0function. So, Let&#8217;s get started. 01. HTML I&#8217;m going with a very lazy solution today, and we&#8217;ll use an invisible checkbox to get the party started &#x1f973;. Then we [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":5144,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[4,145],"tags":[93,25,56,94,146,116,217],"jetpack_featured_media_url":"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/CSS-Disco-Text.jpg","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p7FQPL-1kX","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/5143"}],"collection":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/comments?post=5143"}],"version-history":[{"count":1,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/5143\/revisions"}],"predecessor-version":[{"id":5145,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/5143\/revisions\/5145"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/media\/5144"}],"wp:attachment":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/media?parent=5143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/categories?post=5143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/tags?post=5143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}