开发者

Why are my list items displayed above their parent <div>?

开发者 https://www.devze.com 2023-04-12 04:34 出处:网络
This is happening in both Safari and Firefox. My navigation bar looks like this: <div> <ul>

This is happening in both Safari and Firefox. My navigation bar looks like this:

<div>
  <ul>
    <li><a href=开发者_JAVA百科"#">Test</a></li>
  </ul>
</div>

The relevant CSS looks like:

li {
  float: left
}

a:hover {
  background-color: blue;
}

For some reason, the list items are floating above the <div> they're inside (#navBar). I can't figure out why this seemingly simple design is causing problems.

Why are my list items displayed above their parent <div>?

Thanks for the advice.


Add display: block to #navBar a.

Why are my list items displayed above their parent <div>?

0

精彩评论

暂无评论...
验证码 换一张
取 消