About this snippet

Create a striking entrance page that showcases two options side by side. When you hover over one side, it expands smoothly to fill more space, which encourages users to make a choice.

Size
2.0 KB
Uses
HTML, CSS
Loads
placehold.co
Views
641
<div class="split-container">
  <div class="split left">
    <h1>Designer</h1>
    <a href="#" class="btn">View Portfolio</a>
  </div>
  <div class="split right">
    <h1>Developer</h1>
    <a href="#" class="btn">View Projects</a>
  </div>
</div>
.split-container {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  position: relative;
  width: 100%;
  height: 500px;
  background: #333;
  overflow: hidden;
}
.split {
  position: absolute;
  width: 50%;
  height: 100%;
  overflow: hidden;
  transition: width 1s ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.split.left {
  left: 0;
  background: url("https://placehold.co/1000x800/2563eb/ffffff?text=Design") center center/cover no-repeat;
}
.split.left::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(37, 99, 235, 0.7);
}
.split.right {
  right: 0;
  background: url("https://placehold.co/1000x800/1f2937/ffffff?text=Code") center center/cover no-repeat;
}
.split.right::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(31, 41, 55, 0.8);
}
.split h1 {
  font-size: 3rem;
  color: #fff;
  position: relative;
  z-index: 10;
  white-space: nowrap;
}
.btn {
  position: relative;
  z-index: 10;
  text-decoration: none;
  color: #fff;
  border: 2px solid #fff;
  padding: 15px 30px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 20px;
  transition: background 0.2s;
}
.btn:hover {
  background: rgba(255,255,255,0.2);
}

/* Hover Effects */
.split-container:hover .split {
  width: 30%;
}
.split-container .split:hover {
  width: 70%;
}
@media(max-width: 800px) {
  .split-container {
    height: 700px;
  }
  .split h1 {
    font-size: 2rem;
  }
  .split, .split-container:hover .split, .split-container .split:hover {
    width: 100%;
    height: 50%;
    position: relative;
  }
}
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