【问题标题】:Purposely making two flex container overlap at the same exact specific position故意使两个 flex 容器在相同的特定位置重叠
【发布时间】:2019-09-15 14:12:42
【问题描述】:

我需要让“flex-container > div4”与“flex-container > div2”垂直重叠和/或水平对齐。

需要 div2 和 div4 完全居中。

我使用 text-align 使 div2 居中,但 div4 是图像。

.flex-container {
  display: flex;
  flex-wrap: wrap;
  background-color: blue;
}

.flex-container > div {
  background-color: #ffffff;
  	margin-top: auto;
    margin-right: auto;
  flex-shrink: 0;
  height: 35px;
 min-width: 150px;
 max-width: 150px;
  text-align: left;
  line-height: 50px;
  font-size: 30px;
}
.flex-container > div2 {
background-color: #ffffff;
flex-shrink: 0;
margin-top: auto;
height: 50px;
  width: 250px;
  text-align: center;
  line-height: 50px;
  font-size: 12px;
  }
  .flex-container > div3 {
	margin-top: auto;
    margin-left: auto;
  	width: 150px;
    height: 35px;
 	text-align: center;
  	line-height: 50px;
  	font-size: 15px;
    position: -webkit-sticky;
  position: sticky;
  top: 0;
  align-self: flex-start;
  background-color: white;
  }
  .flex-container > divspacer {
  	background-color: #ffffff;
  	width: 33%;
    height: 35px;
 	margin: 1px;
 	text-align: center;
  	line-height: 50px;
  	font-size: 12px;
    }
    .flex-container > div4 {
    margin-left: auto;
    background-color: #ffffff;
    text-align: center;
    }
<div class="flex-container">

  	<div><img src="https://oakandrocks.com/wp-content/uploads/2019/04/perfootersmol.png"></div>  
    <div2>
    <a class="inline" style="text-decoration: none" href="https://oakandrocks.com/onr"> Webmasters |</a>
	<a class="inline" style="text-decoration: none" href="https://oakandrocks.com/terms"> Terms & Conditions |	  </a>
	<a class="inline" style="text-decoration: none" href="https://oakandrocks.com/privacy"> Privacy Policy 		</a>
    </div2>
	<div3><a style="text-decoration: none" href="https://oakandrocks.com/">© 2019 Oak & Rocks</a></div3>
</div>
<div class="flex-container"><div4><img src="https://oakandrocks.com/wp-content/uploads/2019/04/footertxt.png"></div4></div>

所以,总而言之,也许不是重叠,但我需要 div4(网站解决方案 png)完全居中并位于页面底部(可能是 ~1px 垂直边距)

固定:

.flexcontainer > div4 {
display: block;
margin-left: auto;
margin-right: auto;
}

【问题讨论】:

  • 不要将修复/答案添加到问题中。写一个答案或删除问题

标签: html css flexbox


【解决方案1】:

在发布问题后,像往常一样,我想出了一个解决办法。

添加:

.flexcontainer > div4 {
display: block;
margin-left: auto;
margin-right: auto;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 2018-10-28
    • 1970-01-01
    • 2018-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多