div inside ul causing problems in IE7

末鹿安然 提交于 2019-12-14 03:45:39

问题


I have a <ul> which contains many lis and divs. The li's are autogenerated from inputs and labels, and the divs are floated right and serve as tooltips to explain each input.

The code is something as follows:

<ul>
  <div>tooltip</div>
  <li>input</li>
  <div>tooltip</div>
  <li>input</li>
  <div>tooltip</div>
  <li>input</li>
</ul>

This works fine in firefox and IE8, but in IE7, it assumes that each div is part of the previous <li>, and completely drops the </li> tags from the interpreted source code (found out from IEtester's View Source Code dev tool). Anyone know why this is happening and how to ammend it?

CSS:

.tooltip { float: right; width: 140px; font-size: 0.9em; padding: 9px 9px 9px 15px; margin-top: 15px; }

回答1:


You can't have div inside the <ul> directly. They can go inside the <li> elements though. This may or may not help with the problem you're having but should be fixed to make sure it isn't the cause.

<ul>
  <li>input<div>tooltip</div></li>
  <li>input<div>tooltip</div></li>
  <li>input<div>tooltip</div></li>
</ul>


来源:https://stackoverflow.com/questions/5103793/div-inside-ul-causing-problems-in-ie7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!