๐Ÿ‘‰ 5 CSS useful properties I TOTALLY ignored. ๐Ÿค“

Desirรฉ ๐Ÿ‘ฉโ€๐ŸŽ“๐Ÿ‘ฉโ€๐Ÿซ - Apr 16 '20 - - Dev Community

Hello, users! ๐Ÿ‘‹

Today I'm sharing with you some CSS properties I discovered too late and that nobody told me about their existence before.

Maybe you already know them, that was not my case.

I'm not making this boring, scroll to check'em: ๐Ÿ‘‡

โž€ Disable selecting text of an element

With the property user-select and the value none, we'll disable the text selection of a text for the user.

element {
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none; /* IE 10+ and Edge */
  user-select: none; /* Standard syntax */
}
Enter fullscreen mode Exit fullscreen mode

Useful when you don't want your original content to be copied.

โž Change the text-selection background color

With the selector ::selection:

::selection {
  color: #ececec;
  background: #222831;
}
Enter fullscreen mode Exit fullscreen mode

Remember using good contrast combinations.

โž‚ Breaking the text in lines without br

With the property white-space and the value pre-wrap or pre-line:

element {
  white-space: pre-wrap; /*pre-wrap*/
  white-space: pre-line; /*pre-line*/
}
Enter fullscreen mode Exit fullscreen mode

โžƒ Creating space between words

This may be a bit obvious to you. It wasn't for me until I searched for it.
You can separate words of a text using the word-spacing property.

element {
  word-spacing: 6px; /* word spacing wow such */
}
Enter fullscreen mode Exit fullscreen mode

โž„ Hiding ugly scrollbars in the browser

I didn't even know back then that this was a possibility.
You must use different code depending on the browser you're using:

/* Hide scrollbar for Chrome, Safari, and Opera */
html::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE and Edge */
html {
  -ms-overflow-style: none;
}

/* Remove Scrollbar Firefox Fix, suggested in the comments */
html {
overflow: auto;
scrollbar-width: none;
}

Enter fullscreen mode Exit fullscreen mode

If you disable scrollbars make sure to add UP/DOWN buttons and other handy navigation options. Please note Firefox stopped giving support to the scrollbar hiding issue, the above code seem to be a trick to perform the same functionality as the others I included.

Side note

I guess I'll be updating this post from time to time with other interesting features that I discover.

๐ŸŒผSources๐ŸŒผ:

About hiding scrollbars
About disabling text selection for the user
About word spacing
About white-space
About text selection background color

. . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player