LI子元素位于LI父级的一侧

时间:2016-05-30 10:50:37

标签: html css

我有这个结构:

<div style="position: relative" id="i1">
  <ul style="display: block" id="i2">
    <li style="display: inline-block; position: relative;" id="i3">
      <ul style="display: block;position: absolute; left: -??px; right: ??px" id="i4"> // visible on parent elm:hover
        <li>..</li>
        <li>..</li>
        <li>..</li>
      </ul>
    </li>
  </ul>
</div>

我确实需要在DIV id = i1的整个宽度上显示悬停元素id = i4,但是当我的父元素是元素id = i3,并且此元素是相对内联时,我如何达到左边的值和正确的属性?我可以通过CSS清理它吗?

1 个答案:

答案 0 :(得分:0)

解决了,(我的愚蠢):

<div style="position: relative" id="i1"> /// only relative parent element
      <ul style="display: block" id="i2">
        <li style="display: inline-block; /*position: relative;*/" id="i3"> // removed position: relative;
          <ul style="display: block;position: absolute; left: 0px; right: 0px" id="i4"> // visible on parent elm:hover
            <li>..</li>
            <li>..</li>
            <li>..</li>
          </ul>
        </li>
      </ul>
    </div>