Home > Web Front-end > CSS Tutorial > How to use css to achieve a ring effect

How to use css to achieve a ring effect

王林
Release: 2020-08-21 17:02:27
forward
3848 people have browsed it

How to use css to achieve a ring effect

There are many ways to achieve the ring effect in css. Here are five methods to share with you:

(Recommended tutorial: CSS Tutorial

First of all, let’s take a look at the implementation effect:

How to use css to achieve a ring effect

Next, I will introduce the method:

1. Two tags Nesting

<div class="element1">
    <div class="child1"></div>
</div>
Copy after login
.element1{
            width: 200px;
            height: 200px;
            background-color: lightpink;
            border-radius: 50%;
        }
        .child1{
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: #009966;
            position: relative;
            top: 50px;
            left: 50px;
        }
Copy after login

2. Use pseudo elements, before/after

<div class="element2"></div>
Copy after login
.element2{
            width: 200px;
            height: 200px;
            background-color: lightpink;
            border-radius: 50%;
        }
        .element2:after{
            content: "";
            display: block;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: #009966;
            position: relative;
            top: 50px;
            left: 50px;
        }
Copy after login

3. Use border:

<div class="element3"></div>
Copy after login
 .element3{
            width: 100px;
            height: 100px;
            background-color: #009966;
            border-radius: 50%;
            border: 50px solid lightpink ;
        }
Copy after login

(Learning video recommendation: css video tutorial

4. Use border-shadow

<div class="element4"></div>
Copy after login
.element4{
            width: 100px;
            height: 100px;
            background-color: #009966;
            border-radius: 50%;
            box-shadow: 0 0 0 50px lightpink ;
            margin: auto;
        }
Copy after login
<div class="element5">
Copy after login
  .element5{
            width: 200px;
            height: 200px;
            background-color: #009966;
            border-radius: 50%;
            box-shadow: 0 0 0 50px lightpink inset;
            margin: auto;
        }
Copy after login

5. Use radial-gradient

<div class="element6"></div>
Copy after login
.element6{
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background: -webkit-radial-gradient( circle closest-side,#009966 50%,lightpink 50%);
        }
Copy after login

The above is the detailed content of How to use css to achieve a ring effect. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template