【问题标题】:List item with two spans align left and right具有两个跨度的列表项左右对齐
【发布时间】:2013-11-25 03:17:27
【问题描述】:

我目前有一个类似这样的列表。

<li><a href="#"><span class="short">SHORT</span> <span class="long">LONG</span></a></li>

我想让短跨度向右对齐,长跨度向左对齐。

我目前有一个宽度为 350 像素的列表,并且长期使用它。

.long {

   width: 300px;
   position: absolute;
   right: 0px;
}

似乎无法找到使短跨度向右对齐的方法。

【问题讨论】:

    标签: html css alignment


    【解决方案1】:

    您是否尝试过使用float

    ul {
        margin: 0;
        padding: 0;
        list-style: none;
        width: 500px;
    }
    
    li {
        list-style-type: none;             
    }
    
    .long {
        width: 300px;
        float:left;
        background-color: yellow;
    }
    
    .short {
        width: 200px;
        float:right;
        background-color: green;   
    }
    

    【讨论】:

    • 谢谢!最后添加, text-align:right;到 .short 跨度并添加 clearfix 后,它工作得很好。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 2017-03-07
    • 2016-03-04
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 2021-02-21
    相关资源
    最近更新 更多