Press ESC to close

5 CSS Hints and Tips every Web Developer must recognize in 2022

Preface

Hey guys it’s Zeerak Jamshaid. In this article, I’m going to show you 5 CSS hints & tricks that every web developer should know. You can read my article on Web designing: How to Become a Web Designer in 2022

Maximizing CSS Sibling Selectors

The CSS general sibling selector is used to select all the elements that follow the first element such that both are children of the same parents. The first tip is the use of sibling selectors whenever you are working with a list of items, and you treated the first or the last item differently, the first instinct may be to use the:first-child and:last-child  CSS selectors. The nested list is an example of why this selector is useful. We thought of it as a way to prevent styling from cascading down deeper than you would like. You want to make the outer-most list items large and header-like nevertheless the nested lists are smaller and more body and copy-like. Using a child combinator you can select only those top-level list items and not worry about the header style cascading down to a nested list and having to fight against that styling.
For example, when creating a CSS-only hamburger menu icon as follows:

Cursors

One of the tricks in CSS is using the cursor property. Cursors help you to set the mouse cursor when you point it to any element on the web interface. Below are some of the standard cursors available:
wait: shows that the program is busy and users can’t interact with the interface till it goes back to default
help: Shows that some help information is available to Users.
crosshair: A ross cursor is used for indicating a selection of a media or bitmap.
grab: Used in situations where we want to show that an element can be gripped.
 

CSS Smooth Scrolling

The smooth scrolling feature provides us to set the behavior of the scrolling box when the scrolling is trigged. It comes with two simple properties that are auto and smooth scrolling. When set to auto, you will see that the scrolling box will scroll instantly while with smooth, scrolls smoothly using a timing function decided by the user’s platform. The technology you use for smooth scrolling and accessibility is a concerning factor. For example, if you click a #hash link, the native behavior is for the browser to change focus to the element matching that ID. The page may scroll, but the scrolling is a side effect of the focus changing.
If you override the default focus-changing behavior (which you have to, to prevent instant scrolling and enable smooth scrolling), you need to handle the focus-changing yourself

Example:

 When we need to scroll to a specific section on a webpage.

Create a typewriter effect

Creating a simple typewriter effect on a text is possible. We need to clear two things here; the first is the text part as to how it should be clipped and the second is the actual typewriter animation which gives us the overall effect we need like:

Google Font

The next isn’t actually a trick but the knowledge that you can use different fonts on your website if you navigate to fonts in google search. you’re going to find almost 1000 different fonts available for you to use for free so if you navigate there you can browse different fonts um and if you choose one you’re going to see a preview of the font how does it look like using a different weight and different style like italic uh for example here we have a like a light 300 italic and while here we have a bold so just pick the font you like let’s say I’m going to use this one I’m going to choose a style I like you can actually use one style or you can select multiple styles and add them and then we can use this embed option which will give you the code you have to use on your page.

Gradients

Gradients can be used anywhere you would use an <image>, such as in backgrounds. Because gradients are dynamically generated, they can negate the need for the raster image files that traditionally were used to achieve similar effects. Furthermore, because gradients are generated by the browser, they look better when zoomed in and maybe scaled, unlike bitmap pictures. So you can generate different kinds of gradients using just a CSS so let’s have a look at the example you already know that you can set a background color to your elements like this RGB and then some color let’s say 70 between green and blue so like this one but we can also add a gradient so can use a different kind of gradients.

I’m going to use a radial one and we’re going to define this we want to circle shape and then we will provide two colors so one is going to be the same as we used here and then color shift and then the second color actually we should let add some opacity here to zero or actually let’s leave it for one for a moment and then something more bluish and then this one 100% and let’s see how does it work and this is our gradient so there are many properties which you can change here but don’t worry you don’t have to remember all of them what you can do you can just use one of the CSS gradient generators like that one and simply by using these color pickers you can generate whatever gradient you like you can also change this color shift so using this range selector you can also generate linear gradient like this one.

Leave a Reply

Your email address will not be published. Required fields are marked *