【发布时间】:2021-11-13 01:52:09
【问题描述】:
我刚开始做一个网站,我不明白为什么我不能把它的一部分放在右边。代码如下。
代码:
<!DOCTYPE html>
<html style="background-color: black;">
<head>
<title>My Portfolio</title>
<style>
#navigation-bar {
background-color: black;
color: grey;
font-weight: bold;
font-family: Script;
font-size: 25px;
}
</style>
</head>
<body>
<div id="navigation-bar">
<table>
<tr>
<th><img src="https://previews.123rf.com/images/fordzolo/fordzolo1506/fordzolo150600296/41026708-example-white-stamp-text-on-red-backgroud.jpg" height="50px" width="50px"></th>
<th><a href="/home" title="Home">Home</a></th>
<th><a href="/about" title="About Me">About Me</a></th>
<th><a href="/languages" title="Languages">Languages</a></th>
<th><a href="/work" title="Previous Work">Previous Work</a></th>
<th><a style="text-align: right;" href="https://puginarug.com" title="Beautiful Website">An Amazing Website</a></th>
</tr>
</table>
</div>
</body>
</html>
很明显,我刚刚开始编写此代码,但我正试图让最后一个表头标记与右侧对齐。但输出只是显示在第 5 个表头标记旁边。如何使这个特定的表头标签向右?
【问题讨论】:
-
我可以看到这是一个导航栏,所以您可以将它用作
- 元素的集合而不是使用 table,然后根据您的需要设置它的样式吗?这是制作导航栏的更好方法。
-
我已将这种方法粘贴到解决方案中。
标签: html css html-table navbar