"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Create a Two-Tone Background with a Diagonal Line Using CSS?

How to Create a Two-Tone Background with a Diagonal Line Using CSS?

Published on 2024-11-07
Browse:914

How to Create a Two-Tone Background with a Diagonal Line Using CSS?

Creating a Two-Tone Background with a Diagonal Line

To achieve a background divided into two sections by a diagonal line using CSS, follow these steps:

1. Create Two Divs:
Create two separate divs to represent the two background sections.

2. Style the Divs:
Apply the following CSS to the divs:

.solid-div {
  background-color: [solid color];
}

.textured-div {
  background-image: url([texture image URL]); /* Replace with actual image URL */
}

3. Position the Divs:
Use CSS positioning (e.g., absolute or fixed) to place the two divs side by side, ensuring they cover the entire screen.

4. Create the Diagonal Line:
To create the diagonal line, you can use a CSS gradient:

.background-container {
  background: -webkit-linear-gradient(30deg, [solid color] 50%, [textured-color] 50%);
}

5. Animate the Divs:
Utilize jQuery to control the div sizes based on user clicks, creating the "curtain effect" you desire.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3