How to make a
    display in a horizontal row

后端 未结 7 1475
-上瘾入骨i
-上瘾入骨i 2020-11-28 05:29

How can I make my list items appear horizontally in a row using CSS?

相关标签:
7条回答
  • 2020-11-28 06:24

    As others have mentioned, you can set the li to display:inline;, or float the li left or right. Additionally, you can also use display:flex; on the ul. In the snippet below I also added justify-content:space-around to give it more spacing.

    For more information on flexbox, checkout this complete guide.

    #div_top_hypers {
        background-color:#eeeeee;
        display:inline;      
    }
    #ul_top_hypers {
        display: flex;
        justify-content:space-around;
        list-style-type:none;
    }
    <div id="div_top_hypers">
        <ul id="ul_top_hypers">
            <li>&#8227; <a href="" class="a_top_hypers"> Inbox</a></li>
            <li>&#8227; <a href="" class="a_top_hypers"> Compose</a></li>
            <li>&#8227; <a href="" class="a_top_hypers"> Reports</a></li>
            <li>&#8227; <a href="" class="a_top_hypers"> Preferences</a></li>
            <li>&#8227; <a href="" class="a_top_hypers"> logout</a></li>
        </ul>
    </div>

    0 讨论(0)
提交回复
热议问题