我可以帮助您制作一个简单的面板,其中按钮水平排列并靠右对齐。如果需要靠左对齐,只需将代码更改为如下所示:
但是,如果我使用
那么我该怎么做呢?
.button {
float:left;
background-color: #55cc66;
margin-right: 50px;
padding: 5px;
}
//......
<div id="switcher">
<h3>Style Switcher</h3>
<div class="button selected" id="switcher-default">
Default
</div>
<div class="button" id="switcher-narrow">
Narrow Column
</div>
<div class="button" id="switcher-large">
Large Print
</div>
</div>
但是,如果我使用
float:right
,它显然会将其对齐到右侧,但顺序颠倒了。我还尝试过text-align:right
、position:absolute;right:150;
和position:fixed;right:150;
。最后两个可以对齐到右侧,但是它们会尴尬地重叠在“按钮”上。那么我该怎么做呢?