Blabla
  • Layout1

    Text-align: right on the span inside the li tag

    my structure is as follows:

    <ul class="grupa-playerow">Blabla
        <li class="player-li">Layout1<span class="player-godziny">15.00-17.00</span></li>
        <li class="player-li">Layout2<span class="player-godziny">17.00-22.00</span></li>
        <li class="player-li">Layout3<span class="player-godziny">22.00-24.00</span></li>
    </ul>
    

    and here comes the style:

    .grupa-playerow {
    position: relative;
    width: 300px;
    list-style-type: none;
    padding: 7px 0 7px 0;
    border-bottom: 1px solid #CDCDCD;
    font-size: 11px;
    cursor: pointer;
    }
    
    
    .player-li {
    padding: 2px 0 2px 20px;
    width: 100%;
    text-align: left;
    }
    
    .player-godziny {
    text-align: right !important;
    color: #5ACFC9;
    }
    

    I would like the .player-godziny span to align to the right. Why doesn't it work?

    Here's the script: http://jsfiddle.net/wL2SF/

    +4
    source share
    3 answers

    Try:

    float: right;
    

    instead:

    text-align: right;
    

    Jsfiddle

    If you notice alignment problems, they will most likely be caused by your fill settings.

    +7
    source

    you need to add float:right;

    Demo

    <ul class="grupa-playerow">Blabla
        <li class="player-li">Layout1<span class="player-godziny">15.00-17.00</span></li>
        <li class="player-li">Layout2<span class="player-godziny">17.00-22.00</span></li>
        <li class="player-li">Layout3<span class="player-godziny">22.00-24.00</span></li>
    </ul>
    
    .grupa-playerow {
    position: relative;
    width: 300px;
    list-style-type: none;
    padding: 7px 0 7px 0;
    border-bottom: 1px solid #CDCDCD;
    font-size: 11px;
    cursor: pointer;
    }
    
    
    .player-li {
    padding: 2px 0 2px 20px;
    width: 100%;
    text-align: left;
    }
    
    .player-godziny {
    text-align: right !important;
    color: #5ACFC9;
      float:right;/*ADD*/
    }
    
    +3
    source

    Try:

    .player-godziny {
    float: right;
    color: #5ACFC9;
    }
    
    +2
    source

    All Articles