My FeedDiscussionsHashnode Enterprise
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

7 CSS Tricks You Should Know

dipak maluskar's photo
dipak maluskar
·Sep 27, 2021·

1 min read

.inactive-link{ 
     color : black; 
     text-decoration : none; 
     pointer-events : none; 
     cursor : default;
}

You can disable any link using CSS, so that no action occurs while clicking on the link.

Disable resizing of textarea

textarea{  
   resize : none;
}

Resize property defines resizing of textarea, in order to disable resizing this can be done.

Change the placeholder color

: : placeholder{  
     color : red;
}

The pseudo element ::placeholder allow you to style your placeholder text.

Unordered list in bullets

ul{ 
    list-style-type : none;
}

The property list-style-type defines the type of list item makers.

Disable text selection

.non-select-element{  
      user-select : none;
}

The property user-select defines wether user can select text of the element or not.

Resize image proportionally

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

Width can also be used instead of max-width if desired. The key is use height : auto to override any height="..." attribute already present on the image.

Make image fit

img{ 
  width : 100%;
  height : 100%;
  object-fit : contain;
}

Another way is use of object fit property, this will fit image, without changing proportionally.