将节和导航元素在主节中彼此相邻放置

时间:2019-01-25 17:05:35

标签: html5 css3

<main style="overflow: hidden;">
    <nav style="width: 25%;height: inherit; display: inline-block; float:left;">
        <li><a href="index.html">Home</a></li><br>
        <li><a href="archive.html">Archives</a></li><br>
        <li><a href="about.html">About</a></li>
    </nav>
    <section>
        <p style="padding: 10px;">hi</p>      
    </section>        
</main>

如何在nav元素旁边启动section元素?

1 个答案:

答案 0 :(得分:0)

将显示{:inline-block;添加到您的section元素:

<main style="overflow: hidden;">
    <nav style="width: 25%;height: inherit; display: inline-block; float:left;">
        <li><a href="index.html">Home</a></li><br>
        <li><a href="archive.html">Archives</a></li><br>
        <li><a href="about.html">About</a></li>
    </nav>
    <section style="display: inline-block;">
        <p style="padding: 10px;">hi</p>      
    </section>        
</main>