Skip to content

[css] 第729天 使用css实现圆形的头像的效果(注:要考虑正方形、长方形情况) #3814

Open
@haizhilin2013

Description

@haizhilin2013

第729天 使用css实现圆形的头像的效果(注:要考虑正方形、长方形情况)

3+1官网

我也要出题

Activity

Eacolt

Eacolt commented on Apr 14, 2021

@Eacolt

CSS, 命名一个App.css:
`.circle{
position: relative;
border:2px solid black;
width:100px;
height:100px;
border-radius: 50%;
overflow: hidden;
}
.circle img{
position: relative;
height:auto;
max-width: 100%;
object-fit: cover;
top:50%;
transform: translate(0%,-50%);
border-radius: 50%;

}
`
HTML部分,我使用的是React:
随便用Img元素,引入任意一个图片,把img元素包裹在一个div里,div类名是circle

`
import './App.css'
export function App(){
return (


<div className={"circle"}><img src={'./img/158.png'}/>

);
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @haizhilin2013@Eacolt

        Issue actions

          [css] 第729天 使用css实现圆形的头像的效果(注:要考虑正方形、长方形情况) · Issue #3814 · haizlin/fe-interview