Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我的学习日志(十一) #13

Open
xxxgitone opened this issue Jul 3, 2017 · 0 comments
Open

我的学习日志(十一) #13

xxxgitone opened this issue Jul 3, 2017 · 0 comments

Comments

@xxxgitone
Copy link
Owner

今天又发现一种新的居中方式,给父元素加相对定位,待居中元素,使用绝对定位

<div class="box">
  <div></div>
</div>

css样式

.box {
  width: 200px;
  height: 200px;
  border: 1px solid red;
  position: relative;
}

.box div {
  width: 50px;
  height: 50px;
  background: red;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: auto;
}

垂直居中

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant