我的网站标题(见图片)
基本上是<td><a href>
用css设计的。现在我的问题是如果想在同一行中添加一个或多个按钮但是将它们对齐到右边我该怎么办?
它不一定是css解决方案,我正在寻找一种方法在html的<table>
或<td>
标签中执行此操作。
感谢。
编辑:这是生成标题的php的一部分:
echo<<<TOPBARHEREDOC2
<link rel="stylesheet" href="/css/horizontal_navbar.css" type="text/css" media="screen">
<table border="auto" id="topbar" >
<td><a class="topbarlink" href="index.php">Ana Sayfa</a></td>
<td><a class="topbarlink" href="userstats.php?category=$category">İstatistik</a></td>
<td><a class="topbarlink" href="contact.php">İletişim</a></td>
<td><a class="topbarlink" href="useful_links.php">Linkler</a></td>
<td><a class="topbarlink" href=$lastlink_address>$lastlink_name</a></td>
</table>
<hr>
<br>
TOPBARHEREDOC2;
这是css:
table a.topbarlink{
/*TOP, RIGHT, BOTTOM, & LEFT*/
margin:0px 0px 0px 0px;
font-family: Futura, "Trebuchet MS", Arial, sans-serif;
font-weight:bold;
color:#069;
background-color: #f2f2f2;
text-decoration: none;
border-bottom: 2px solid #ccc;
border-top: 2px #ccc;
border-right: 2px solid #ccc;
border-left: 2px #ccc;
/*padding (ordered)*/
padding-top:0.2em;
padding-right: 1em;
padding-bottom:0.2em;
padding-left: 1em;
}
答案 0 :(得分:3)
首先,除了表格数据之外,你真的不应该使用表格。语义标记总是更好,所以在你的情况下,最好为你的菜单使用一个未编号的列表。
无论如何,让我们说这是你的表:
<table>
<tr>
<th><a href="#">Item 1</a></th>
<th><a href="#">Item 2</a></th>
<th><a href="#">Item 3</a></th>
<th class="right"><a href="#">Item 4</a></th>
</tr>
</table>
然后你可以使用这个CSS将一个项目对齐到右边:
table { width: 100%; }
th { float: left; }
th.right { float: right; }
答案 1 :(得分:1)