简体   繁体   中英

Float middle list item right

I'm trying to float the middle list item right. So the red item with job title should apear next to the blue item. But when I float it right it puts it right of the blue one instead of left.

So this is what I have now

所以这就是我现在拥有的

When I float it right I get this.

当我向右漂浮时,我得到了这个。

So how can I now correctly display it?

My SCSS

  .credit-list-main{
    list-style:none;
    padding:0;
    font-size:13px;

    >li.credit-list-company{
        list-style:none;

        >h3{
            font-weight:bold;
            font-size:13px;
        }

        >ul.credit-list-person{

            list-style:none;
            padding:0;
            padding-left:5px;

            >li{
                display:inline;
            }
            /*Person name*/
            >li:nth-child(1){
                background:green;
            }
            /*Job title*/
            >li:nth-child(2){
                background:red;
                float:right;
            }
            /*Person nav*/
            >li:nth-child(3){
                background:blue;
                float:right;
            }
        }
    }

}

HTML

<ul class="credit-list-main">
                        <li class="credit-list-company">
                            <h3>Management</h3>
                            <ul class="credit-list-person">
                                <li>Cevat Yerli</li>
                                <li>CEO & President</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Avni Yerli</li>
                                <li>Managing Director</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Faruk Yerli</li>
                                <li>Managing Director</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                        </li>
                        <li class="credit-list-company">
                            <h3>Programming Team</h3>
                            <ul class="credit-list-person">
                                <li>Filipe Amim</li>
                                <li>Game Programmer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Sandy Brand</li>
                                <li>Senior AI / Game Programmer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Dean Claassen</li>
                                <li>Senior Interface Programmer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Fernando Colomer</li>
                                <li>Senior Game Programmer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Sandy Brand</li>
                                <li>Senior AI / Game Programmer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                        </li>
                        <li class="credit-list-company">
                            <h3>Research & Development</h3>
                            <ul class="credit-list-person">
                                <li>Christopher Balte</li>
                                <li>Software Engineer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Iva Zoltan Frey</li>
                                <li>Lead Animation Engineer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Iva Herzeg</li>
                                <li>Lead Animation Engineer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                            <ul class="credit-list-person">
                                <li>Christopher Balte</li>
                                <li>Software Engineer</li>
                                <li><a href="#"><i class="icon-edit"></i></a></li>
                            </ul>
                        </li>
                    </ul>

Simply revert your two last columns :

<ul class="credit-list-person">
    <li>Cevat Yerli</li>
    <li><a href="#"><i class="icon-edit"></i></a></li>
    <li>CEO & President</li>
</ul>

You can also manage like this :

<ul class="credit-list-person">
<li>Cevat Yerli</li>
<span>
<li>CEO & President</li>
<li><a href="#"><i class="icon-edit"></i></a></li>
</span>
</ul>

then give float: right to span and after then apply float: left for first li and float: right for second li

Update

Without changing the markup you could do this by setting right value as this fiddle but better would be changing its order as answered by @zessx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM