html - Flexbox 内容没有与链接和图像均匀分布
问题描述
我正在使用 flex 来构建页脚。我希望页脚为网站宽度的 60% 并居中,这样效果很好。当我将内容添加到文本、链接和图像链接的页脚并尝试对齐空间时,它无法正常工作,并且页脚右侧有很多额外的空白。如何删除它?
CSS
.site-wide-footer {
display: flex;
flex-wrap: wrap;
width: 60%;
height: auto;
border: 2px solid black;
border-radius: 24px;
color: white;
background-color: black;
margin: auto;
justify-content: space-between;
align-items: center;
}
HTML
<footer>
<div class="site-wide-footer">
<p>© 2018 copyright</p>
<p><a href="store.html" class="button-footer"> ♦STORE</a></p>
<p><a href="about-us.html" class="button-footer">♦ABOUT US</a></p>
<p><a href="sitemap.xml" class="button-footer">♦SITEMAP</a></p>
<div class="social-footer">
<p><a href="discord url">
<img src="images/Discord-Logo-White.png" alt="Discord Logo"
class="discord-footer" onmouseover="hover(this);"
onmouseout="unhover(this);"></a>
<a href="facebook url/"><img
src="images/facebook-icon.png" alt="Facebook Icon" class="facebook-
footer"></a></p>
</div>
</div>
</footer>
解决方案
我认为您可能需要考虑flex
为 flex-box 子项设置规则。我不确定我理解你到底想达到什么目标,但如果你遵循这条flex
规则,你可以取得很多成就。
.site-wide-footer {
display: flex;
flex-wrap: wrap;
width: 60%;
height: auto;
border: 2px solid black;
border-radius: 24px;
color: white;
background-color: black;
margin: auto;
justify-content: space-around; /*you can play with it*/
align-items: center;
padding: 0 15px 0; /*fixed space on left and right of the flex-box*/
}
.site-wide-footer > { /*flex-box children */
flex: 1 0; /*play with this one a bit. you could also give it a minimum width like that: flex: 1 0 100px;*/
}`
当然,您可以在此Flexbox 完整指南中找到所有答案
伊塔马尔
推荐阅读
- php - PHP无法访问开关内的公共变量
- javascript - 在 Polymer 中,我可以在单击时动态创建纸质按钮更改颜色吗?
- postgresql - Adobe Campaign 工作流结果:无法从基础读取数据
- r - 循环两个 R 数据帧以创建第三个数据帧
- jenkins - RTC 的提交后交付钩子
- node.js - 如何手动调用多个 express 中间件
- javascript - 遇到 2 个输出组合在一个输入中
- c# - 如何向网站发送登录请求?
- google-apps-script - 如何使用公式列出或索引 Google 表格中的所有工作表/标签(无脚本)
- c++ - 智能指针对象池测试应用程序在完成/退出时失败