Skip to content

Instantly share code, notes, and snippets.

@pixelspencil
Last active March 23, 2021 00:33
Show Gist options
  • Save pixelspencil/13c5052880091344ab58deb02f18721e to your computer and use it in GitHub Desktop.
Save pixelspencil/13c5052880091344ab58deb02f18721e to your computer and use it in GitHub Desktop.
CSS Snippets
```css
selector {
color: #000000;
background: #ffffff77
}
```
/*
- Instead of using rgba() you can use #00000078, the last two digits are the alpha value 00-ff
- [1 2 3 4 5 6 7 8 9 A B C D E F]
- [Further reading](https://www.digitalocean.com/community/tutorials/css-hex-code-colors-alpha-values#adding-an-alpha-value-to-your-hex-codes)
*/
```css
.truncate {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
```
/*
- Just add the truncate class to the text element.
- [Further reading](https://css-tricks.com/snippets/css/truncate-string-with-ellipsis/)
*/
/*
This snippet will highlight an image has no alt text:
"You forgot the image alt attribute"
*/
img[alt=""],
img:not([alt]) {
border: 5px dashed #c00;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment