text align right in a span

前端 未结 3 1166
南旧
南旧 2021-02-08 12:53

I am a little bit in doubt how I solve this the best way. In the footer of this page: Portfolio , there is the following:

04-11-2016 : Design In Portfolio

相关标签:
3条回答
  • 2021-02-08 13:07
    1. Put your span outside the link
    2. Make sure your li is in display block (or inline-block with defined width)
    3. float right your span

    CSS

    span { float: right; }
    

    HTML

        <li>
            <a href="#" target="_blank">
                Hvad er Mautic? &emsp;&emsp;&emsp;
            </a>
            <span class="newsDate">06-11-2016</span>
        </li>
    
    0 讨论(0)
  • 2021-02-08 13:14

    You can try this:-

     float:right;
    
    0 讨论(0)
  • 2021-02-08 13:17

    Its contained inside a block element so add "float: right" to those spans to get your right alignment =).

    Edit. Someone shot down the float idea in a now deleted comment. Floating does present some layout ugliness for when your text on the left becomes too large. You could instead use a fancy flex solution that will hold up across different context a bit better.

    For flex, set the anchor to "display: flex" and the span to "flex: 1; text-align: right; white-space: nowrap;".

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