css – 并排对齐元素

前端之家收集整理的这篇文章主要介绍了css – 并排对齐元素前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道这是一个很简单的问题,但我不能为我的生活弄明白。我有两个链接,我应用了一个背景图片。这里是它目前的样子(为阴影道歉,只是一个粗略的按钮草图):

但是,我想要这两个按钮并排。我不能真正弄清楚需要做什么对齐。

这里是HTML

@H_403_6@<div id="dB"}> <a href="http://notareallink.com" title="Download" id="buyButton">Download</a> </div> <div id="gB"> <a href="#" title="Gallery" onclick="$j('#galleryDiv').toggle('slow');return false;" id="galleryButton">Gallery</a> </div>

这里是CSS

@H_403_6@#buyButton { background: url("assets/buy.png") 0 0 no-repeat; display:block; height:80px; width:232px; text-indent:-9999px; } #buyButton:hover{ width: 232px; height: 80px; background-position: -232px 0; } #buyButton:active { width: 232px; height: 80px; background-position: -464px 0; } #galleryButton { background: url("images/galleryButton.png") 0 0 no-repeat; display:block; height:80px; width:230px; text-indent:-9999px; } #galleryButton:hover{ width: 230px; height: 80px; background-position: -230px 0; } #galleryButton:active { width: 230px; height: 80px; background-position: -460px 0; }

解决方法

应用float:left;到你的两个divs应该让他们并列。
原文链接:https://www.f2er.com/css/223069.html

猜你在找的CSS相关文章