字体真棒图标无法在页脚中正确显示

时间:2016-04-15 18:05:45

标签: html css font-awesome

HTML:

<div id="container">
  <h1>This website is currently getting a makeover.</h1>
  <p>It will be back shortly with updated portofolio, revamped          (custom) design, and new pricing.</p>
  <footer>
    <p class="left copyright">Copyright &copy; 2016 Patrick Black</p>
    <a class="social right" href="#"><i class="fa fa-twitter fa-2x"></i></a>
  </footer>
</div>

CSS(使用预处理器; Stylus;如果想要完整代码请注释:

html {
  position relative
  min-height 100%
}
body {
  font-family: 'Roboto', sans-serif;
  text-align center
  height 100%
  margin 0 0 50px
}
h1 {
  margin-top: 30vh;
}
footer {
  background black
  color white
  height 50px
  position absolute
  bottom 0
  left 0
  width 100%
}
.left {
  text-align left
}
.right {
  float right
}
.copyright {
  margin-left 10px
}
.social {
  display inline-block
}

这里是完整代码:: http://codepen.io/Mortiferr/pen/pyLYqa 如您所见,Twitter图标显示在页脚下方。

4 个答案:

答案 0 :(得分:2)

 <p class="left copyright">Copyright &copy; 2016 Patrick Black</p>

是页面的全宽,因此强制推文部分到下一行。

您可以通过浮动该段来解决此问题。

.left {
  text-align: left;
  float: left;
}

Codepen Demo

答案 1 :(得分:0)

你应该在页脚中使用这个css for twitter字体图标。

.social {
 display inline-block;
 position:absolute;
 bottom:0;
 right:0;
 padding:6px
}   

答案 2 :(得分:0)

添加.copyright规则:

display inline-block
float left

&#13;
&#13;
html {
  position: relative;
  min-height: 100%;
}
body {
  font-family: 'Roboto', sans-serif;
  text-align: center;
  height: 100%;
  margin: 0 0 50px;
}
h1 {
  margin-top: 30vh;
}
footer {
  background: black;
  color: white;
  height: 50px;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}
.left {
  text-align: left;
}
.right {
  float: right;
}
.copyright {
  display: inline-block;
  float: left;
  margin-left: 10px;
}
.social {
  display: inline-block;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet"/>
<div id="container">
  <h1>This website is currently getting a makeover.</h1>
  <p>It will be back shortly with updated portofolio, revamped (custom) design, and new pricing.</p>
  <footer>
    <p class="left copyright">Copyright &copy; 2016 Patrick Black</p>
    <a class="social right" href="#"><i class="fa fa-twitter fa-2x"></i></a>
  </footer>
</div>
&#13;
&#13;
&#13;

答案 3 :(得分:0)

你只需要添加

.left{
  float:left;
  text-align left;
}

i{
  line-height: 50px;
}

工作示例:http://codepen.io/anon/pen/aNGOKy

相关问题