【发布时间】:2015-02-14 03:04:59
【问题描述】:
我对 Web 开发还很陌生,并且一直在研究页面页脚中的一些社交按钮。我设法使它们具有悬停效果,并且我想要,它们现在只是没有在正确的位置彼此相邻显示。我希望它们彼此相邻,我知道这是通过 div 和包装完成的,只是不确定如何在我的代码中实现它。这是我的代码:
<style>
.facebook {
width: 64px;
height: 64px;
float: left;
background-image: url('http://pccb.org.au/wp-content/uploads/2014/12/facebook-5-512.png');
background-repeat: no-repeat;
background-size: 64px 64px;
text-indent: -500px;
}
.facebook:hover {
background-image: url('http://pccb.org.au/wp-content/uploads/2014/12/facebook-hover.png');
}
li {
list-style: none;
}
</style>
<ul>
<li>
<a href="https://www.facebook.com/pages/Payneham-City-Concert-Band/1383434338547917?fref=ts" target="FB Page">
<div class="facebook">Facebook
</div>
</a>
</li>
</ul>
<style>
.twitter {
width: 64px;
height: 64px;
float: right;
background-image: url('http://pccb.org.au/wp-content/uploads/2014/12/twitter-5-512.png');
background-repeat: no-repeat;
background-size: 64px 64px;
text-indent: -250px;
}
.twitter:hover {
background-image: url('http://pccb.org.au/wp-content/uploads/2014/12/twitter-hover.png');
}
li {
list-style: none;
}
</style>
<ul>
<li>
<a href="https://twitter.com/PaynehamBand" target="Twitter Page">
<div class="twitter">
</div>
</a>
</li>
</ul>
如您所见,代码有效,但图像位于页面的两端,我需要它们在左侧并排显示。非常感谢任何帮助。
【问题讨论】:
-
为什么不把
.twitter浮动到左边而不是右边?