html - 菜单栏中的菜单宽度不合适
问题描述
我已将菜单中每个元素的宽度设置为 25%(总计 100%)。请参见下面的代码:
<html>
<head>
<title>Epsilon Eridani Project</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!--page header-->
<h1>Epsilon Eridani Project</h1>
<!--menu-->
<table width="100%" bgcolor="white" cellpadding="4" cellspacing="4">
<tr>
<td width="25%">
<img src="images/s-logo.jpg" alt=" " height="40" width="60"/>
<span class="menu">Home</span></td>
<td width="25%">
<td width="25%">
<img src="images/s-logo.jpg" alt=" " height="40" width="60"/>
<span class="menu">Eridanus</span></td>
<td width="25%">
<td width="25%">
<img src="images/s-logo.jpg" alt=" " height="40" width="60"/>
<span class="menu">Latest News</span></td>
<td width="25%">
<td width="25%">
<img src="images/s-logo.jpg" alt=" " height="40" width="60"/>
<span class="menu">Community</span></td>
<td width="25%">
</tr>
</table>
</html>
但是,在输出中,它看起来非常混乱。请参阅此图像中的输出
我很困惑为什么会这样?感谢您的时间。
解决方案
你有几个
<td width="25%">
没有结束</td>
缩进代码也是一种很好的做法,这样可以更容易地找到问题。
<table width="100%" bgcolor="white" cellpadding="4" cellspacing="4">
<tr>
<td width="25%">
<img src="images/s-logo.jpg" alt=" " height="40" width="60"/>
<span class="menu">Home</span>
</td>
<td width="25%"></td> <!-- Should this be here?? -->
<td width="25%">
<img src="images/s-logo.jpg" alt=" " height="40" width="60"/>
<span class="menu">Eridanus</span>
</td>
<td width="25%"></td> <!-- Should this be here?? -->
<td width="25%">
<img src="images/s-logo.jpg" alt=" " height="40" width="60"/>
<span class="menu">Latest News</span>
</td>
<td width="25%"></td> <!-- Should this be here?? -->
<td width="25%">
<img src="images/s-logo.jpg" alt=" " height="40" width="60"/>
<span class="menu">Community</span>
</td>
<td width="25%"></td> <!-- Should this be here?? -->
</tr>
</table>
我希望这能让你走上正确的轨道来解决你的问题。:)
推荐阅读
- python - 在匹配之前选择第一个日期,直到找到另一个匹配
- mysql - 如何加入没有记录的表?
- c++ - 如何使 cmake 支持 gcov
- machine-learning - (交叉)CNN 模型验证——何时引入测试数据?
- intellij-idea - 如何将 Emmet 片段导入 IntelliJ?
- javascript - 使搜索框不区分大小写
- reactjs - Facebook 登录重定向 uri 错误:url 被阻止,重定向失败
- graphql - graphQLErrors 未定义,如何从 apollo 响应中提取错误
- javascript - 在现有项目中配置 jest 和酶会引发错误
- java - 在 Java 代码中使用纯文本凭据的替代策略