About this snippet

Create a subtle and modern link hover effect where a background color slides in from the side. This CSS-only technique adds a touch of elegance to text links on your website.

Size
1015 bytes
Uses
HTML, CSS
Loads
Nothing external
Views
358
<div class="link-container">
  <a href="#" class="link-style-modern-3">Slide Background</a>
</div>
/* Basic body styling for demonstration (can reuse) */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Arial', sans-serif;
  background-color: #f0f2f5;
  margin: 0;
}
.link-container {
  padding: 20px;
}

.link-style-modern-3 {
  position: relative;
  text-decoration: none;
  color: #2c3e50;
  font-size: 1.5rem;
  padding: 8px 5px;
  z-index: 1;
  transition: color 0.4s ease;
}

.link-style-modern-3::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-color: #3498db;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease-in-out;
  z-index: -1;
  border-radius: 3px;
}

.link-style-modern-3:hover,
.link-style-modern-3:focus {
  color: white;
  outline: none;
}

.link-style-modern-3:hover::before,
.link-style-modern-3:focus::before {
  transform: scaleX(1);
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save