From dcfb172704f3afb68a30425029ec834be2883274 Mon Sep 17 00:00:00 2001 From: bt Date: Sat, 8 Jun 2024 13:22:19 -0400 Subject: More content porting, on-going markdown changes for lowdown support --- build/super-mario-blocks-css/index.html | 197 ++++++++++++++++++-------------- 1 file changed, 113 insertions(+), 84 deletions(-) (limited to 'build/super-mario-blocks-css') diff --git a/build/super-mario-blocks-css/index.html b/build/super-mario-blocks-css/index.html index 2f51051..9215eac 100644 --- a/build/super-mario-blocks-css/index.html +++ b/build/super-mario-blocks-css/index.html @@ -1,113 +1,131 @@ - + Super Mario Blocks in CSS - - + + +
-

Super Mario Blocks in CSS

+

Super Mario Blocks in CSS

+

2019-02-15

-

Just because we can, let's make a quick demo on how to build interactive elements based off the original Mario punch blocks.

+ +

Just because we can, let’s make a quick demo on how to build interactive elements based off the original Mario punch blocks.

+

What our final product will look like:

+

Mario blocks cretaed with CSS

+

Live CodePen Example

-

The HTML

-

The set of Mario blocks doesn't require a huge amount of effort for it's html structure, we only need:

+ +

The HTML

+ +

The set of Mario blocks doesn’t require a huge amount of effort for it’s html structure, we only need:

+ +

Sidenote: This is only how I chose to add the inner dots to the Mario blocks. There are many other ways to create these, so please feel free to implement them however you see fit.

-
<!-- Main parent block -->
-<div class="mario-block">
-
-    <!-- Checkbox input (disabled by default) -->
-    <input type="checkbox" id="1" disabled>
-
-    <!-- Checkbox label -->
-    <label for="1">
-        <!-- Inner dots for blocks -->
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-    </label>
-
-</div>
+
+
<!-- Main parent block -->
+<div class="mario-block">
+
+    <!-- Checkbox input (disabled by default) -->
+    <input type="checkbox" id="1" disabled>
+
+    <!-- Checkbox label -->
+    <label for="1">
+        <!-- Inner dots for blocks -->
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+    </label>
+
+</div>
 
+

Now we just add as many default blocks we want, along with the interactive punch block (.mario-block--question):

-
<div class="mario-block">
-    <input type="checkbox" id="1" disabled>
-    <label for="1">
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-    </label>
-</div>
-
-<div class="mario-block">
-    <input type="checkbox" id="2" disabled>
-    <label for="2">
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-    </label>
-</div>
-
-<div class="mario-block mario-block--question">
-    <input type="checkbox" id="3">
-    <label for="3">
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="question-mark"></div>
-    </label>
-</div>
-
-<div class="mario-block">
-    <input type="checkbox" id="4" disabled>
-    <label for="4">
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-        <div class="dot"></div>
-    </label>
-</div>
+
+
<div class="mario-block">
+    <input type="checkbox" id="1" disabled>
+    <label for="1">
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+    </label>
+</div>
+
+<div class="mario-block">
+    <input type="checkbox" id="2" disabled>
+    <label for="2">
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+    </label>
+</div>
+
+<div class="mario-block mario-block--question">
+    <input type="checkbox" id="3">
+    <label for="3">
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="question-mark"></div>
+    </label>
+</div>
+
+<div class="mario-block">
+    <input type="checkbox" id="4" disabled>
+    <label for="4">
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+        <div class="dot"></div>
+    </label>
+</div>
 
-

The CSS

-

First we need to remove the default checkbox input styling and place all new styling on it's corresponding label.

-
/* Mario block parent div */
+
+

The CSS

+ +

First we need to remove the default checkbox input styling and place all new styling on it’s corresponding label.

+ +
/* Mario block parent div */
 .mario-block {
     display: inline-block;
     height: 80px;
-    margin-right: -7px; /* Fixes inline-block margin bug */
+    margin-right: -7px; /* Fixes inline-block margin bug */
     position: relative;
     width: 80px;
 }
 
-/* Hide default checkbox input */
+/* Hide default checkbox input */
 .mario-block input {
     position: absolute;
     visibility: hidden;
     z-index: -1;
 }
 
+

Now to target the label elements found inside the block:

-
/* Style checkbox label accordingly */
+
+
/* Style checkbox label accordingly */
 .mario-block label {
     background: #F88D2E;
     border: 4px solid #070000;
@@ -118,7 +136,9 @@
     width: 100%;
 }
 
+

Next we style our included .dots elements to be placed in the four corners of each block:

+
.mario-block .dot {
     background: #070000;
     height: 5px;
@@ -142,13 +162,16 @@
     right: 4px;
 }
 
-

Punch-able block

-

Now we need to include the "question mark" SVG and custom CSS for the interactive Mario block. You can download a copy of the custom svg question mark I created.

+ +

Punch-able block

+ +

Now we need to include the “question mark” SVG and custom CSS for the interactive Mario block. You can download a copy of the custom svg question mark I created.

+
.mario-block--question label {
     cursor: pointer;
 }
 .mario-block--question .question-mark {
-    background-image: url('/public/images/mario-block-question-mark.svg');
+    background-image: url('/public/images/mario-block-question-mark.svg');
     background-position: center;
     background-repeat: no-repeat;
     background-size: 40px;
@@ -160,31 +183,34 @@
     z-index: 1;
 }
 
-

The last piece

+ +

The last piece

+

The last item we need to design is the checked state of the interactive question mark block. The extra inner dark dashes will be added as pseudo elements:

-
/* Mario block in `checked` state */
+
+
/* Mario block in `checked` state */
 .mario-block input:checked + label {
     background: #885818;
     box-shadow: inset -4px -4px 0 #68400B, inset 4px 4px 0 #FAB89B;
 }
 
-/* Hide both the default dots and question mark svg on checked */
+/* Hide both the default dots and question mark svg on checked */
 .mario-block input:checked + label .dot,
 .mario-block input:checked + label .question-mark {
     display: none;
 }
 
-/* Shared pseudo element styling */
+/* Shared pseudo element styling */
 .mario-block input:checked + label:before,
 .mario-block input:checked + label:after {
-    content: '';
+    content: '';
     height: 20px;
     position: absolute;
     transform: rotate(45deg);
     width: 20px;
 }
 
-/* Right dash */
+/* Right dash */
 .mario-block input:checked + label:before {
     border-right: 4px solid #070000;
     right: 18px;
@@ -192,7 +218,7 @@
     transform: rotate(45deg);
 }
 
-/* Left dash */
+/* Left dash */
 .mario-block input:checked + label:after {
     border-left: 4px solid #070000;
     left: 18px;
@@ -200,9 +226,12 @@
     transform: rotate(-45deg);
 }
 
-

That's it!

-

Taking it further

-

As always, you can take this concept and flesh it out even further. I was trying to mimic the "pixel" style of the original Mario games, but you could make the lighting and depth more realistic with some extra subtle gradients or filter properties.

+ +

That’s it!

+ +

Taking it further

+ +

As always, you can take this concept and flesh it out even further. I was trying to mimic the “pixel” style of the original Mario games, but you could make the lighting and depth more realistic with some extra subtle gradients or filter properties.