Bookmarked CSS

Page Container

Basic

.container {
  padding: 0 20px;
  background-color: #333;
}

.content {
  max-width: 1170px;
  margin: 0 auto;
}

Advanced

.container {
  width: calc(100% - 20px);
  max-width: 960px;
  margin: 0 auto;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  flex-shrink: 0;
}

main {
  flex-grow: 1;
  flex-shrink: 0;
}

footer {
  flex-shrink: 0;
}

Center Vertically Without Flex

position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

Border

Reversed Dotted

.div1,
.div3 {
  height: 50px;
  background-color: pink;
}

.div2 {
  border-top: 5px dotted pink;
}

Live Button Border

.top,
.right,
.bottom,
.left {
  position: absolute;
  background-color: currentColor;
  transition: transform 0.3s;
}

.top,
.bottom {
  left: 0;
  width: 100%;
  height: 1px;
  transform: scaleX(1);
}

.top {
  top: 0;
  transform-origin: left center;
}

.bottom {
  bottom: 0;
  transform-origin: right center;
}

.left,
.right {
  top: 0;
  width: 1px;
  height: 100%;
  transform: scaleY(0.6);
}

.left {
  left: 0;
  transform-origin: top center;
}

.right {
  right: 0;
  transform-origin: bottom center;
}

button:hover .top,
button:hover .bottom {
  transform: scaleX(0.6);
}

button:hover .right,
button:hover .left {
  transform: none;
}

.top, .right, .bottom, .left reference separate span elements

Live Button Border 2

&::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 0;
  z-index: -1;
  background-color: $green;
}

&::after {
  content: '';
  position: absolute;
  bottom: -4px;
  right: 0;
  z-index: -1;
  background-color: $green;
}

&:hover::before,
&:hover::after {
  animation-name: button;
  animation-duration: 0.6s;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes button {
  0% {
    width: 0;
    height: 4px;
  }
  70% {
    width: calc(100% + 4px);
    height: 4px;
  }
  100% {
    width: calc(100% + 4px);
    height: calc(100% + 8px);
  }
}

Live Link Underlining

.nav__link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s;
}

.nav-link:hover::after {
  transform: scaleX(1);
  transform-origin: right center;
}

Live Element Opacity

section {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0s 0.3s;
}

article:hover section {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

Live Background Color

&::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: orange;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.6s;
}

&.active::before {
  transform: scaleX(1);
}

&:nth-child(2)::before {
  transform-origin: left;
}

span {
  position: relative;
}

Slider

.slider {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: #ccc;
  border-radius: 20px;
  transition: 0.2s;
  opacity: 0.6;
  cursor: pointer;

  &::before {
    content: '';
    position: absolute;
    width: 17px;
    height: 17px;
    left: 4px;
    bottom: 4px;
    background-color: #fff;
    border-radius: 50%;
    transition: 0.2s;

    @media (min-width: 768px) {
      width: 20px;
      height: 20px;
      left: 5px;
      bottom: 5px;
    }
  }

  &::after {
    content: 'AUS';
    display: inline-block;
    margin-top: 2px;
    margin-left: 56px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    color: #aaa;
    transition: 0.4s;

    @media (min-width: 768px) {
      margin-top: 4px;
      margin-left: 68px;
    }
  }
}
body {
  overflow: hidden;
}

.modal-container {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  overflow-y: auto;
  background-color: rgba(0, 0, 0, 0.8);
}