CSS div background circle padding

1. Target effect

div content circle padding

insert image description here

2. Function realization

1. border-radius

border-radius: 50%;
background: #F56C6C;

Problem: If the div is not a square, the filled circle is not a circle either
insert image description here

2. clip-path

clip-path: circle(30%);
background: #F56C6C;

Problem: Borders are affected
insert image description here

3. radial-gradient

background: radial-gradient(circle, #F56C6C 66%, transparent 66%);

Problem: The edges of the circle will be jagged and blurry
insert image description here

Guess you like

Origin blog.csdn.net/YG_zhh/article/details/129315457