如何将LI元素定位到UL列表的底部

PaN*_*1Me 10 html css positioning html-lists

我有菜单项,如:Row1 Row2 .. RowN,我希望它们不要那么宽 - 这就是为什么包括休息(最大宽度)

我有这个HTML:

<div>
 <ul>
  <li>Row1</li>
  <li>Row1 Row2 Row3</li>
  <li>Row1</li>
  <li>Row1 Row 2</li>
 </ul>
</div>
Run Code Online (Sandbox Code Playgroud)

用这个CSS:

/* MENU */

.menudiv {padding-left:10px; border-bottom: 1px solid #d0db88;}

ul.menu
{                 
    list-style-type: none;
    min-width: 1050px;
    position: relative;
    left:10px;
    display: block;
    height: 45px;       
    margin: 0;
    padding: 0;
}

ul.menu li
{    
    float: left;
    margin: 0;
    padding: 0;
}

ul.menu li a
{    
    float: left;    
    text-decoration: none;
    padding: 9px 12px 0;
    font-weight: bold;
    max-width:130px;
}
Run Code Online (Sandbox Code Playgroud)

实际:

+--------------------+
|Row1 Row1 Row1 Row1 |
|     Row2      Row2 |
|     Row3           |
+--------------------+
Run Code Online (Sandbox Code Playgroud)

我需要的:

+--------------------+
|     Row1           |
|     Row2      Row1 |
|Row1 Row3 Row1 Row2 |
+--------------------+
Run Code Online (Sandbox Code Playgroud)

RoT*_*oRa 4

使用display: inline-block而不是float

ul.menu
{                 
   vertical-align: bottom;
}

ul.menu li
{    
   display: inline-block;
   text-align: center;
}
Run Code Online (Sandbox Code Playgroud)

编辑:添加了text-align: center;. 如果我正确理解你的评论,那就是你想要的。如果没有,您需要更具体。