Custom Slider with Overlay Text

User
create a custom slider with overlay text with 80 percent 1 section and 20% other section
Assistant
To create a custom slider with an 80% and 20% section layout and overlay text, you can use HTML and CSS. Here's an example implementation:

### Code Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Custom Slider</title>
  <style>
    body {
      margin: 0;
      font-family: Arial, sans-serif;
    }

    .slider-container {
      display: flex;
      width: 100%;
      height: 100vh;
      overflow: hidden;
    }

    .main-slider {
      position: relative;
      width: 80%;
      background: url('https://via.placeholder.com/800x600') center/cover no-repeat;
    }

    .main-slider .overlay-text {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: #fff;
      text-align: center;
      background: rgba(0, 0, 0, 0.5);
      padding: 20px;
      border-radius: 5px;
    }

    .side-content {
      width: 20%;
      background: #f4f4f4;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    }

    .side-content p {
      font-size: 1rem;
      color: #333;
    }
  </style>
</head>
<body>
  <div class="slider-container">
    <div class="main-slider">
      <div class="overlay-text">
        <h1>Main Slider Text</h1>
        <p>Subtitle or additional description here.</p>
      </div>
    </div>
    <div class="side-content">
      <p>Additional content, links, or images here.</p>
    </div>
  </div>
</body>
</html>

### Explanation
1. **HTML Structure**:
– The slider is divided into two sections: `main-slider` (80%) and `side-content` (20%).
– The `main-slider` has a background image and an overlay for text.
– The `side-content` is styled with a solid background for additional information.

2. **CSS Styling**:
– **Flexbox** is used to create the layout with two sections.
– The `main-slider` has a relative position to position the overlay text absolutely.
– The `overlay-text` is centered in the `main-slider` and has a semi-transparent background for better readability.
– The `side-content` is styled for visual distinction with padding and shadow.

3. **Responsive**:
– The design uses percentages and `vh` units to make it responsive to different screen sizes.

### Customization
– Replace the placeholder image (`https://via.placeholder.com/800×600`) with your slider images.
– Modify text content in the `overlay-text` and `side-content` sections.
– Enhance functionality with JavaScript if needed (e.g., auto-slide, arrow navigation).

Would you like me to include JavaScript for sliding functionality or further refine this?

Leave a Comment

Your email address will not be published. Required fields are marked *