How to make a
    display in a horizontal row

后端 未结 7 1434
-上瘾入骨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:01
    #ul_top_hypers li {
      display: flex;
    }
    
    0 讨论(0)
  • 2020-11-28 06:02

    It will work for you:

    #ul_top_hypers li {
        display: inline-block;
    }
    
    0 讨论(0)
  • 2020-11-28 06:12

    You could also set them to float to the right.

    #ul_top_hypers li {
        float: right;
    }
    

    This allows them to still be block level, but will appear on the same line.

    0 讨论(0)
  • 2020-11-28 06:14

    Set the display property to inline for the list you want this to apply to. There's a good explanation of displaying lists on A List Apart.

    0 讨论(0)
  • 2020-11-28 06:19

    As @alex said, you could float it right, but if you wanted to keep the markup the same, float it to the left!

    #ul_top_hypers li {
        float: left;
    }
    
    0 讨论(0)
  • 2020-11-28 06:24

    List items are normally block elements. Turn them into inline elements via the display property.

    In the code you gave, you need to use a context selector to make the display: inline property apply to the list items, instead of the list itself (applying display: inline to the overall list will have no effect):

    #ul_top_hypers li {
        display: inline;
    }
    

    Here is the working example:

    #div_top_hypers {
        background-color:#eeeeee;
        display:inline;      
    }
    #ul_top_hypers li{
        display: inline;
    }
    <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)
提交回复
热议问题