Skip to content

Instantly share code, notes, and snippets.

@cmbaughman
Created June 13, 2025 14:08
Show Gist options
  • Save cmbaughman/5bcbd5e4370a0a8604d43688c2f18cda to your computer and use it in GitHub Desktop.
Save cmbaughman/5bcbd5e4370a0a8604d43688c2f18cda to your computer and use it in GitHub Desktop.
Minimalist CSS Only Stuff

Cool CSS Only Stuff

CSS Only Modals

<a href="#modal">Open Modal</a>

<div id="modal" class="modal">
  <a href="#" class="close">×</a>
  <p>This is a CSS-only modal window!</p>
</div>
.modal {
  display: none;
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translate(-50%);
  background: white;
  padding: 1rem;
}

:target.modal {
  display: block;
}

Toggle Switch

<label class="switch">
  <input type="checkbox">
  <span class="slider"></span>
</label>
.switch {
  display: block;
  position: relative;
  width: 50px;
  height: 25px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  background-color: #ccc;
  border-radius: 25px;
  transition: 0.4s;
  height: 100%;
  width: 100%;
}

input:checked + .slider {
  background-color: #4CAF50;
}

CSS Marquee

<div class="marquee">
  <span>This is a scrolling text animation using only CSS.</span>
</div>
.marquee {
  overflow: hidden;
  white-space: nowrap;
}

.marquee span {
  display: inline-block;
  padding-left: 100%;
  animation: scroll 10s linear infinite;
}

@keyframes scroll {
  0%   { transform: translateX(0%); }
  100% { transform: translateX(-100%); }
}

Menu

<input type="checkbox" id="menu-toggle">
<label for="menu-toggle">☰ Menu</label>

<ul class="menu">
  <li>Home</li>
  <li>About</li>
  <li>Contact</li>
</ul>
#menu-toggle ~ .menu {
  display: none;
}

#menu-toggle:checked ~ .menu {
  display: block;
}

Tooltip

<button class="tooltip">
  Hover me
  <span class="tooltip-text">Tooltip Text</span>
</button>
.tooltip {
  position: relative;
}

.tooltip-text {
  position: absolute;
  visibility: hidden;
  background-color: #000;
  color: #fff;
  padding: 5px;
  top: -30px;
  left: 0;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment