Skip to content

Instantly share code, notes, and snippets.

@larapollehn
Last active August 11, 2020 10:09
Show Gist options
  • Select an option

  • Save larapollehn/a0c4f43e08c13138b842a4837d55d0cf to your computer and use it in GitHub Desktop.

Select an option

Save larapollehn/a0c4f43e08c13138b842a4837d55d0cf to your computer and use it in GitHub Desktop.

center absolute elem without knowing exact width

center ul in div

* ul {
  text-align: center;
  list-style: inside;
}

fit font-size to window

*  font-size: 16px; //fallback
    /* 100 = viewport width, as 1vw = 1/100th of that
       So if the container is 50% of viewport (as here)
       then factor that into how you want it to size.
       Let's say you like 5vw if it were the whole width,
       then for this container, size it at 2.5vw (5 * .5 [i.e. 50%])
    */
    font-size: 2.5vw;

vertical center text in div

*  display: flex;
  justify-content: center;
  align-content: center;
  flex-direction: column;

vertical alignment of text in li

* display: flex;
      flex-direction: row;
      align-items: center;

hide overflowing text with ...

* .ellipsis {
  text-overflow: ellipsis;

  /* Required for text-overflow to do anything */
  white-space: nowrap;
  overflow: hidden;
}

manage display, set with css

  • if the element's display is being inherited or being specified by a CSS rule, you'll need to get its computed style: return getComputedStyle(element, null).display;

scale site as desktop view on mobile

<meta name="viewport" content="width=1280, initial-scale=1">

custom scrollbar

::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
  background: #888;
}
::-webkit-scrollbar-thumb:hover {
  background: #555;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment