按顺序左右浮动 4 个元素

我在订单中设置导航时遇到问题。我有 4 个 div 标签,它的顺序应该是左、右、右、左。所以我希望我的导航应该是这样的

https://img1.mukewang.com/651d13fd0001709f25600401.jpg

我的浮动权有问题。我试过这个


.footer {


}


li {

  background-color: yellow;

  display: inline-block;

}


.one {

  background-color: orange;

}


.two {


}


.copy {

  background-color: blue;

}


.two, .three {

  float: right;

  background-color: aqua;

  clear: right;

}

<html>

  <body>

    <footer class="footer">

      <div class="one" >

        <img src="https://via.placeholder.com/250x100" alt="footer" />

      </div>

      <div class="two">

        <ul>

          <li>privacy</li>

          <li>terms and conditions</li>

          <li>contact us</li>

        </ul>

      </div>

      <div class="three">

        <ul>

          <li>instagram</li>

          <li>facebook</li>

          <li>twitter</li>

      </div>

      <div class="clear"></div>

      <div class="copy">

        &copy; 2020 mysite.com

      </div>

    </footer>

  </body>

</html>

不知何故,浮动并没有将我的无序列表保持在顶部。我已经通过 stackoverflow 进行了搜索。但我找不到任何答案。如果我得到这份工作将会更有帮助。



www说
浏览 87回答 1
1回答

神不在的星期二

如果不改变div结构,只需使用display:gird.footer {&nbsp; &nbsp; display: grid;&nbsp; &nbsp; grid-template-columns: 1fr auto;}li {&nbsp; background-color: yellow;&nbsp; display: inline-block;}.one {&nbsp; grid-area: 1 / 1 / 3 / 2;&nbsp; background-color: orange;}.two {&nbsp; grid-area: 1 / 2 / 2 / 3;}.three {&nbsp; grid-area: 2 / 2 / 3 / 3;}.two, .three {&nbsp; background-color: aqua;&nbsp; text-align: right;}.copy {&nbsp; grid-area: 3 / 1 / 4 / 2;&nbsp; background-color: blue;}<html>&nbsp; <body>&nbsp; &nbsp; <footer class="footer">&nbsp; &nbsp; &nbsp; <div class="one" >&nbsp; &nbsp; &nbsp; &nbsp; <img src="https://via.placeholder.com/250x100" alt="footer" />&nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; <div class="two">&nbsp; &nbsp; &nbsp; &nbsp; <ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>privacy</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>terms and conditions</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>contact us</li>&nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; <div class="three">&nbsp; &nbsp; &nbsp; &nbsp; <ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>instagram</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>facebook</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>twitter</li>&nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; <div class="copy">&nbsp; &nbsp; &nbsp; &nbsp; &copy; 2020 mysite.com&nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; </footer>&nbsp; </body></html>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5