Skip to content

5.CSS 实现垂直水平居中 #5

@webVueBlog

Description

@webVueBlog
Member

HTML 结构:

<div class="wrapper">
<div class="content"></div>
</div>

CSS结构:

.wrapper {
position: relative;
width: 500px;
height: 500px;
border: 1px solid red;
}
.content{
position: absolute;
width: 200px;
height: 200px;
/*top、bottom、left 和 right 均设置为 0*/
top: 0;
bottom: 0;
left: 0;
right: 0;
/*margin 设置为 auto*/
margin:auto;
border: 1px solid green;
}

Activity

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

        @webVueBlog

        Issue actions

          5.CSS 实现垂直水平居中 · Issue #5 · weekCodeing/interview-answe