"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 Circle with Two Distinct Borders Responsively Using CSS?

How to Create a Circle with Two Distinct Borders Responsively Using CSS?

Published on 2024-11-16
Browse:905

How to Create a Circle with Two Distinct Borders Responsively Using CSS?

Styling Circles with Dual Borders Responsively

Creating a CSS circle is straightforward, as demonstrated by the provided working CSS. However, to achieve a circle with two distinct borders, we need to employ additional CSS techniques.

Using the provided HTML structure, where a single

element represents the circle:

We can modify the CSS as follows to create a circle with two borders:

div {
  width: 20em;
  height: 20em;
  border-radius: 50%;
  background-color: red;
  border: 4px solid #fff;
  box-shadow: 0 0 0 5px red;
}

This CSS adds a second border using the box-shadow property, which creates a 5px wide red shadow around the circle, effectively creating the illusion of a second border. The color of the second border is determined by the red value in the box-shadow property.

The provided CSS achieves the desired effect, creating a circle with two distinct borders that responds fluidly to changes in the container's size.

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