Web DesignClient ResourcesDesign Resources

10 Best CSS Tricks to Transform Your Web Layout

Stuart Crawford

Welcome
Check out the Top 10 Best CSS Tricks to Transform Your Web Layout and Create a Custom Website Design with these Code Based Snippets.

10 Best CSS Tricks to Transform Your Web Layout

In today’s world of ever-changing technology, learning new techniques to make your website even more interesting, not just to look at but also to create, is essential. 

We want to create something without knowing how or aren’t delighted with what we have created most of the time. During those times, we turned to Google, and sometimes, it made our lives even more complicated. 

If you want to create something unique and new, read this blog; it will make your life easier. Within this article, you will find great ways to transform your website’s layout to make it even better and more attractive. 

We will give you the ingredients needed to make your website stand out and make the journey of having or creating a website a little easier.

Furthermore, you will find handy responsive image CSS tricks for your websites in responsive image CSS, blend modes, etc. By using only a few lines of coding, you can change your website’s layout to something different and something better.

How CSS Transformed Website Styling

In the early days of the web, styling a website's appearance was labour-intensive. Designers had to embed styling instructions directly into the website's HTML code. This approach was time-consuming and created rigid designs that were difficult to update.

The game changed significantly with the introduction of CSS (Cascading Style Sheets). Here's how:

  • Separation of Content and Design: CSS separates a website's content from its design. This means HTML handles the structure and semantics while CSS handles the aesthetics. This separation simplifies updates and maintenance, making the process more efficient.
  • Consistency Across Pages: By using external style sheets, designers can apply the same styles across multiple pages. This ensures a consistent look and feel throughout a website, reducing errors and discrepancies.
  • Efficiency: CSS drastically reduces the amount of code needed for styling. Before CSS, styling had to be repeated within each HTML file, cluttering the codebase. With CSS, a single line in a style sheet can implement changes site-wide, saving time and reducing redundancy.
  • Responsive Design: CSS introduced the ability to create responsive web designs that adapt to different screen sizes and devices. This was a revolutionary step compared to earlier methods, which required separate websites for other platforms.
  • Advanced Styling Capabilities: CSS provides many styling options that were impossible before—think gradients, transitions, animations, and grid layouts. These enable more creative and dynamic web designs without extensive coding.

Ultimately, shifting from inline styles within HTML to using CSS has transformed web design into a more efficient, scalable, and creative process. This evolution allows for rapid development and maintenance, fostering an environment where designers can focus on innovation rather than tedious coding tasks.

1. CSS Blend Modes

Css Tricks Blend Modes Web Design

Regarding technology, you can have many unique innovations in CSS; blend modes stand firm, which you can use to transform the website layout. Two-toned images and colourisation effects are among the top trends in web design

Using the CSS blend modes isn’t just a fantastic way to unite the look. It also allows you to produce various versions of colour for an image. There are fifteen blend modes: screen, overlay, brighten, etc. 

Related:  The 15 Most Popular Fonts of All-Time

There are multiple ways to do this; you can utilise both the background image and the background colour incorporated into the background mode of the container. Furthermore, you can then darken or utilise pseudo-elements to create an (i.e., before and after) on the image wrapper you are using for a colouring effect.

Experts advised using an image high in contrast and black and white colour. You can also apply CSS filters to set the greyscale and a high contrasting level. If you apply blend modes, you can stay assured that you will produce a fantastic website layout.

2. Animation

Css Tricks For Animation

Using animation within your website will make it look fun and exciting. Often, people use it not just to attract the desired audience but also because it’s a trend many individuals use. 

You can create effects such as animated underlines, reappearing text, etc. All you need to do is utilise::after and: before pseudo selectors. 

They work great for these things. Do not forget to set the content property: the pseudo-element will not be rendered if you fail it.

If you want to delay your animation, there’s a way to let it run after 2 seconds, for example. Here’s the code that will help you with that effect.

div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-delay: 2s;
}

Negative numbers are also acceptable. The animation starts as though it has played for N seconds if negative numbers are used.

div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-delay: -2s;
}

You can also let the animation run for how many times you want it to; it can run for an infinite time. For example, the following code will repeat the animation about three times.

div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-iteration-count: 3;
}

And if you want to continue it without stopping it infinite times, here’s the code you can follow.

div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-iteration-count: infinite;
}

Animation is excellent for making your text slide across the browser, done through the following code.

p {
animation-duration: 3s;
animation-name: slide-in;
}
@keyframes slide in {
from {
margin-left: 100%;
width: 300%;
}
to {
margin-left: 0%;
width: 100%;
}
}

3. Typography

If you don’t want to type the whole text in all caps, don’t want to retype what you wrote due to the issue of capitalisation, well, we just found a solution for you. This CSS targets the h2 title tag.

h2 { text-transform: uppercase; } – all caps
h2 { text-transform: lowercase; } – all lowercase
h2 { text-transform: capitalize; } – capitalises the 1st letter of each word.

Also, we constantly want aesthetic chaos within our title; you can always play a game of perspective and be more visually chaotic. The code that can help you achieve is transform:skew(60deg, -30deg) scaleY(.66667);

You can incorporate a phrase’s very initial letter using a drop cap to get an attractive newspaper look. This makes the capital letter significant, and then you can style it how you want.

<span class="dropcap">T</span>
Then
.dropcap {
float: left;
font-size: 400%;
color: #cf142b;
margin: -13px 7px -13px 0;
}

4. Typewriter Effect

Css Tricks Typewriter

Creating the effect on the text through CSS tricks is possible; first, you must know how to clip the text through the text and the animation parts. 

Related:  Bank Branding: Why the Strong Brands Win

Below, you’ll find the code you need to use; the ‘white space is there to be catered to maintain the text on a single container instead of wrapping it around. 

We use a flexbox on the body tag to centre-align the text. There is also the animation part; there are two. The typewriter motion changed the text’s width from 0% to 100% in 3 seconds, while the other cursor animation was added to the cursor for a more realistic look. 

This changes the border colour from transparent to #FF8D8D for 1 second. 

The ‘overflow: hidden’ is so the rest of the letter sentences don’t show till the animation is done. Through ‘border-right’, we added a realistic cursor.

<div class="demo-typewriter">
<span>typewriter effect!</span>
</div>
.demo-typewriter span {
color: #262626;
overflow: hidden; 
border-right: .10em solid #FF8D8D;
white-space: nowrap; 
margin: 0 auto; 
letter-spacing: .4rem; 
animation: demo-typewriter 3s steps(30, end), demo-cursor 1s step-end infinite;
}
@keyframes demo-typewriter {
from {
width: 0;
}
to {
width: 100%;
}
}
@keyframes demo-cursor {
from, to {
border-color: transparent;
}
50% {
border-color: #FF8D8D;
}
}

The: link pseudo-class controls all links that haven’t been clicked yet. The visited pseudo-class handles the styling of all links you’ve already visited. This informs the audience where they’ve already been on the site and the parts website they haven’t seen.

a:link { color: blue; }

a:visited { color: purple; }

6. Scrolling

The smooth scrolling feature on CSS has two options: auto and soft. When it’s on auto, the scrolling box will scroll instantly; meanwhile, on the smooth, it scrolls within a timing function that the user decides.

7. The Hover Effect

If the colours are required to change when an individual’s mouse has hovered over text, icons, buttons, and so on, you need to add hover to the CSS to change the style. For example:

.entry h2{
font-size:36px;
color:#000;
font-weight:800;
}

.entry h2:hover{
color:#f00;
}

This will convert the colour of the Hz tag to black from red when an individual hovers over it. It only switches to what you want, so the font size or anything else won’t change. 

If you desire a more manageable transition into the colour and not so sudden, you can use the below code; it gives it 0.3 seconds to transition.

.entry h2:hover{
color:#f00;
transition: all 0.3s ease;
}

To zoom and equip colour in on an image through hover, you’d need to surround the image you are using in a container; let’s name the container ‘image-of’. 

The container’s overflow attribute must be set to ‘hidden’. So it works. The image is grayscale by default, but the filter is removed when the mouse hovers over it. Zoom can be changed using transform: scale(your_ratio);.

.image {
width: 100%;
overflow: hidden;
}
.image-colorize img {
transition: transform .5s, filter 0.5s ease-in-out;
filter: grayscale(100%);
}
.image-of:hover img {
filter: grayscale(0);
transform: scale(1.1);
}

8. Using width and max-width property

If the width property is set to a percentage and the height property is set to “auto”, the image will be responsive and scale up and down:

img {
width: 100%;
height: auto;
}

The image can be scaled up to be larger than its original size. However, a better solution would be to use the max-width property instead.

Using The max-width Property

If the max-width property is set to 100%, the image will scale down if it has to, but never scale up to be larger than its original size:

img {
max-width: 100%;
height: auto;
}

9. Clippings

Most often, designers desire to do something unique. To produce something unique and attractive, designers try to fit the image in a particular shape, like a triangle or any other shape. 

Related:  What is SASE, and why is it important for Business?

In this scenario, it is recommended to use the clipping path. The CSS clipping feature is great; a shape’s boundary is the clipping path, and clippings define which parts of the image should be visible. Anything around or inside the path will be visible and hidden outside the path.

clip-path: circle(radius at x, y);
clip-path: URL(#clipping); /*referencing to SVG element*/

If the circle function has a clipping mask incorporated on the top of the image, only the image within this circle will be seen. 

Shape functions and SVG may be used as clip paths, giving you various options, such as animating them into morphing shapes. The background of an image can be removed using a clipping path.

10. Shape In and Out

Css Tricks For Shapes

Text containers don’t always have to be rectangular; this is a way to make your website’s layout richer and better. 

The inside and out allow the content to be wrapped around a custom path within CSS tricks. Apply the code to the image or container;

shape-outside: circle(50%); /* the content will flow 360 degree around the circle*/

You need to define the dimension of the float property; the elements, width, and height must be determined. Then, you can choose a circle, polygon, inset, or ellipse for the shapes.

Another option is the URL() function; this allows you to shape outside the feature to define the geometry of an element based on a picture. 

You might use this function instead of the polygon when you have numerous curves and points and want the content to wrap around them neatly ().

You can use the shape margin property if you want more space between the content and elements you are using — it’ll act like a margin. Shape functions can be animated, but only for polygons that have been defined. 

For example, the URL() function cannot be animated.

Before implementing all the abovementioned tricks, here are some bonus tips to make your experience successful. 

Image-based gradients are faster to load than CSS-based gradients because they are a big part of computation and happen after the rest of the CSS has been done. 

This is useful when using an image with a standard linear gradient. Therefore, you can make it with a 1PX-wide JPG. However, if it is a radial or some other gradient, it’s best to use a CSS command as it will be a significantly smaller total file size.

Another handy tip is to combine all CSS into one file and ensure it’s GZIP’ed and has an extended expiry date. Also, do this on your production system and not your DEV.

Achieving the Parallax Effect with CSS

The parallax effect offers a captivating depth to web pages by creating an illusion of three-dimensional space. This is accomplished by having the background move more slowly than the foreground as the user scrolls.

Understanding Parallax Scrolling

In traditional setups, JavaScript or jQuery often handles parallax scrolling. However, with the advancements in CSS, you can achieve this effect through style sheets, eliminating the need for additional scripting.

Steps to Implement

  1. Define the Background: Use CSS to set a background image with the background-attachment: fixed property. This keeps the image stationary as the user scrolls, giving the illusion that it moves slower than the content. .parallax-background { background-image: url('your-image-url.jpg'); background-attachment: fixed; background-size: cover; }
  2. Structure Your Content: Place your main content in a separate container. This allows the foreground to scroll naturally over the stationary background. .content { text-align: center; padding: 50px; font-family: 'Arial', sans-serif; }
  3. Scale and Transform: For additional creative twists, use transformations to adjust your elements' size or appearance but ensure they enhance the user's experience. .foreground-elements { transform: scale(1.2); font-size: 2em; margin: auto; }
  4. Adjust Container Height: Make sure the body or main container is set to a height that triggers scrolling so the parallax effect is noticeable. body { height: 100vh; overflow-y: scroll; }

By adjusting these properties, you can seamlessly integrate the parallax effect into your website, enhancing its visual appeal and engaging your audience without additional JavaScript code. This method simplifies the implementation process and ensures faster page loading times, as you rely solely on CSS for animation and effects.

Related:  Impulse Buying: What Drives Impulsive Purchases?

To conclude

If you are looking forward to changing your website’s layout completely, it is advised to implement the tricks mentioned above. These tricks are specially tested and handpicked to help you innovate your website’s layout.

Hopefully, this article helped you and gave you insight into improving your website. The tips and tricks are there because sometimes we need them; they’re always needed whether or not we’re new to these CSS tricks. 

Hopefully, the article gave you some fantastic CSS tricks to improve your website and the codes for your thoughts. Furthermore, we will be coming up with more tips and CSS tricks that will help you make innovations in the future.

Photo of author
Written By
Stuart Crawford
Stuart Crawford is an award-winning creative director and brand strategist with over 15 years of experience building memorable and influential brands. As Creative Director at Inkbot Design, a leading branding agency, Stuart oversees all creative projects and ensures each client receives a customised brand strategy and visual identity.

Need help Building your Brand?

Let’s talk about your logo, branding or web development project today! Get in touch for a free quote.

Leave a Comment

Trusted by Businesses Worldwide to Create Impactful and Memorable Brands

At Inkbot Design, we understand the importance of brand identity. With our team of experienced designers and marketing professionals, we are dedicated to creating custom solutions that elevate your brand and leave a lasting impression on your target audience.