Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS style first column different than other columns

I need to make the first column look different than the other columns. The following style selector does not do what I want. Can someone show me how I can get my first column inside milestoneRow to be different from the other columns?

CSS

.milestoneRow {
    line-height: 55px;
}

.milestoneRow:first-child {
    line-height: 16px;
    margin-left: 10px;
    margin-right: -10px;
}

.milestoneRow:not(:first-child) {
    color: white;
    font-weight: bold;
}

HTML

<div class="row milestoneRow">
    <div class="col-md-1">
        1st Column <br />
        3 Lines <br />
        Closer Together
    </div>
    <div class="col-md-2">
        2nd Column
    </div>
    <div class="col-md-1">
        3rd Column
    </div>
    <div class="col-md-3">
        4th Column
    </div>
    <div class="col-md-3">
        5th Column
    </div>
    <div class="col-md-2">
        6th Column
    </div>
</div>
like image 379
Wannabe Avatar asked Dec 27 '25 18:12

Wannabe


1 Answers

This code

.milestoneRow:first-child {
    line-height: 16px;
    margin-left: 10px;
    margin-right: -10px;
}

only applies if .milestoneRow is the first child.

You need to select the actual first child of milestoneRow using a descendant selector like so:

 .milestoneRow div:first-child {
        line-height: 16px;
        margin-left: 10px;
        margin-right: -10px;
    }
like image 151
Paulie_D Avatar answered Dec 30 '25 10:12

Paulie_D