10 lifesaving HTML/CSS tricks for designers

 

10 lifesaving HTML/CSS tricks for designers

10) The magic setup

* {padding: 0;
margin: 0;
max-width: 100%;
overflow-x: hidden;
position: relative;
display: block;
}

9) Animated lines and decorations

you can see the line when I hover text.
.item::after {content: "";
position: absolute;
top: XYZ;
left: XYZ;
... properties you want;
}

8) Viewport height as text size

.text {height: XYZvh;
}

7) HTML IMG backgrounds

A typical img used as background case: cards.
.background {
position: relative;
}
.background IMG {width: 100%;
height: 100%;
object-fit: cover;
position: absolute;
top:0;
left:0;
}

6) The overflowing text effect


.parent {
height: /*something similar to the child's font size*/;
overflow-y: hidden;
display: block;
}
.parent .child {animation-name: appear;
animation-duration: ...s;
}
@keyframes appear {
from { transform: translateY(/* parent's height*/) }
to { transform: translateY(0)}
}

5) Sexy hamburger menu’s logic

<div id="hamburger" onClick="handle menu()"> ... </div><div id="navigation"> ... </div>
<script>
var open = false;function handleMenu() {/** open the menu **/
if (!open) {
document.getElementById("navigation").classList.add("opened");
open = true;


}
/** else close the menu **/
else {
document.getElementById("navigation").classList.remove("opened");
open = false;
}
}
}
</script>
#navigation {
display: none;
}
#navigation. opened {
display: block;
}

4) Splitting both HTML and CSS

3) Smooth-scrolling

2) Use a CSS preprocessor

1) Start with Gatsby.js in the first place

2 comments:

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...