html - 我的 Div 不响应位置:绝对容器 Div 设置为位置:相对
问题描述
这应该相当简单,但是我很难理解为什么它不起作用。容器(logo-wrapper)内的 div(logo-and-text)不想使用绝对位置,而父级作为相对位置。如果我在 div 或文本中制作单个图像,它会起作用。
我试过设置容器的高度,将边距设置为零,在 chrome 开发工具中检查。
<section id="contact-me-section">
<div id="contact-me-section-wrapper">
<div id="have-a-question-wrapper">
<h2 class="contact-h2">HAVE A QUESTION?</h2>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/location.png" alt="">
<p class="contact-p">Dayton, Ohio</p>
</div>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/phone.png" alt="">
<p class="contact-p">( 937 ) 336-9359</p>
</div>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/email.png" alt="">
<p class="contact-p">contact@ryanjthacker.com</p>
</div>
</div>
<div id="logo-wrapper">
<div id="logo-and-text">
<img src="images/logo.png" alt="">
<p>Copyright © 2019 Ryan Thacker - All rights reserved</p>
</div>
</div>
<div id="connect-with-me-wrapper">
<h2 class="contact-h2">CONNECT WITH ME</h2>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/facebook_white.png" alt="">
<p class="contact-p">Facebook</p>
</div>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/linkedin_white.png" alt="">
<p class="contact-p">LinkedIn</p>
</div>
<div class="connect-with-me-image-wrapper">
<img class="contact-img" src="images/github_white.png" alt="">
<p class="contact-p">GitHub</p>
</div>
</div>
</div>
</section>
#contact-me-section {
color: white;
background-color: black;
height: auto;
width:100%;
}
#contact-me-section-wrapper {
display: flex;
text-align: center;
justify-content: center;
}
#have-a-question-wrapper {
display: flex;
flex-direction: column;
margin-bottom: 100px;
}
#logo-wrapper {
margin-left: 150px;
margin-right: 150px;
position: relative;
height: 100%;
}
#logo-and-text {
position: absolute;
bottom: 0;
}
#logo-wrapper img {
width: 116px;
margin: 10px;
}
#connect-with-me-wrapper {
display: flex;
flex-direction: column;
margin-bottom: 100px;
}
.contact-h2 {
font-size: 17px;
margin: 20px;
padding-top: 60px;
padding-bottom: 30px;
text-align: left;
}
.contact-p {
color: #989898;
margin-top:auto;
margin-bottom:auto;
font-size: 15px;
}
.contact-img {
width: 60px;
margin: 20px;
}
.connect-with-me-image-wrapper {
display: flex;
flex-direction: row;
}
解决方案
我相信我已经解决了,这是由于使用了弹性盒子。该解决方案是一种更简单灵活的方法。
相反,我只使用了 align-self: flex-end; 到容器。
推荐阅读
- javascript - 如何隐藏“类型”元素
- r - 使用 ggplot 重现绘图
- xcode - 为什么我的 NSSplitViewItem 在折叠完成之前隐藏它的子视图
- javascript - 为什么在安装 npm i typescript 后,`npx tsc --init` 使用旧版本(V1.5.3)但更新(V4.1.3)?
- java - 在调用外部 API 之前过滤 Camel 标头
- powershell - 为什么故障转移集群管理器 GUI 不反映我们的 Powershell 输入?
- javascript - 检查是否在对象数组中找到数组项作为某个属性值
- javascript - Sequelize - 开发/构建模式之间的不同包含表名称
- python-3.x - 在 django 中删除问题时出现 FieldError,django-hitcount
- tensorflow - model = hub.load(module_handle) 抛出错误