How to use css to implement a circular avatar frame

不言
Release: 2018-07-14 17:38:32
Original
9913 people have browsed it

This article mainly introduces how to use css to realize a circular avatar frame, which has certain reference value. Now I share it with you. Friends in need can refer to it

1. Method 1

Directly set the img to a circle. In this case, if the image is not square, the image will be stretched

<img class="circleImg" src="../img/photo/img.jpg"  />
Copy after login

The corresponding css is

.circleImg{
  border-radius: 30px;
  width:60px;
  height:60px; 
}
Copy after login

boder-radius is the width of the image Half

2. Method 2

Set by background image

<p class="bgImg"></p>
Copy after login

The corresponding css is

.bgImg{ 
  border-radius: 30px;
  width:60px;
  height:60px; 
  background: url("../img/photo/img.jpg") no-repeat center;
  background-size:60px;
}
Copy after login

If the dragged image is not square, it will be displayed in proportion to the width , then the background-size is set to the width of the picture and the height to auto. If it needs to be displayed in proportion to the height, then background-size:auto 60px;

The display effect is

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use css to achieve text wrapping

How to use CSS3 to achieve the effect of text origami

The above is the detailed content of How to use css to implement a circular avatar frame. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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