小编ser*_*der的帖子

任何人都可以告诉如何将这个RED div中心化?

任何人都可以指导如何在灰色(父)"包装"div中水平和垂直居中这个"红色"div(div ="red")?我希望红色div准确定位在包装div的中心(垂直和水平).这是代码:

body {
  height: 100%;
  width: 100%;
  background-color: rgba(255, 249, 249, 1);
  margin: 0px;
  left: 0px;
  top: 0px;
  right: 0px;
  bottom: 0px;
}
.wrapper {
  background-color: rgba(204, 204, 204, 1);
  height: 600px;
  width: 100%;
  margin: auto;
  color: rgba(255, 255, 255, 1);
  text-align: center;
  font-weight: bold;
  display: block;
  position: relative;
  top: 0px;
  bottom: 0px;
  left: 0px;
  right: 0px;
}
.red {
  background-color: rgba(255, 0, 0, 1);
  height: 50%;
  width: 600px;
  position: absolute;
  font-weight: normal;
  text-align: left;
  /* [disabled]line-height: 100px; */ …
Run Code Online (Sandbox Code Playgroud)

html css

1
推荐指数
1
解决办法
44
查看次数

标签 统计

css ×1

html ×1