css - 使用 CSS 进行页脚布局

标签 css

<分区>


这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能在这里出现,但这个问题的解决方式不太可能帮助 future 的读者。

关闭 6 年前

我在设计页脚样式时遇到问题,需要一些指导。名称应该在左边,链接在右边。这些链接已经崩溃了,我想知道是否有更好的方法可以更有效地将它们对齐在一起。我尝试在这里使用 flexbox,但收效甚微。提前谢谢你的帮助。

/* footer styles*/

footer { margin-top:1em; display: block; border-top: solid 2px #456e6e;
margin-bottom: 1em; }

top {

float: right;
text-decoration:none;
color: #456e6e;
margin-top: -2.25em;
}

top:hover{

color:black;
}

footer a { text-decoration: none; color: #456e6e; }

footer a:hover{ color:black; }

wrapper {

min-height: 100vh;
}

/*NAV CSS*/

.tablet-info {

display: none;
} for small screen sizes

for larger screen sizes

.tablet-info {

display: inline-block;
float: right;
margin-top: -2em;
margin-right:.25em;
margin-left:.25em;
}

student-name {

margin-top: 1.8em;
}

.clearfix { content: ""; display: table; clear: both; }

}
  <div id="footer">
        <footer class="clearfix">
            <h3 id="student-name">Tracy Excell</h3>
                <h3><a href="#home" id="top">Back To Top</a></h3>
                <h3><a href="#home" class="tablet-info">Home</a></h3>
                <h3><a href="#portfolio" class="tablet-info">Portfolio</a></h3>
                <h3><a href="#contact" class="tablet-info">Contact</a></h3>

        </footer>
</div>

最佳答案

您可以使用更新的页脚布局并使用 flexbox,如下所示:

footer{
  display: flex;
  justify-content: space-between;
}

footer .nav{
  display: flex;
}

.nav h3{
  margin-left: 15px; 
}
<footer>
  <h3 id="student-name">Tracy Excell</h3>
  <div class="nav">
    <h3><a href="#home" id="top">Back To Top</a></h3>
    <h3><a href="#home" class="tablet-info">Home</a></h3>
    <h3><a href="#portfolio" class="tablet-info">Portfolio</a></h3>
    <h3><a href="#contact" class="tablet-info">Contact</a></h3>
  </div>
</footer>

关于css - 使用 CSS 进行页脚布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38558954/

上一篇:html - & :nth-of-type() selector hover content (1) works for all-of-type

下一篇:html - 移动设备上的 flexbox 溢出

相关文章:

css - 将字母间距作用限制为输入中的某些字符

javascript - 如何改变 native react 下划线的粗细

javascript - jQuery 包装 div

css - 将某人的 CSS 转换为 Xamarin iOS 以获得渐变

javascript - 一个更简单且独立的数字选择器?

html - CSS 宽度无法正常工作

css - 当鼠标悬停在 button1 上时显示 button2

jquery - 更改多个按钮颜色的更好方法

css - 使用 css position 定位一个动态加载的搜索结果框

html - 在 Joomla 中调整头寸大小