user4393948
user4393948

Reputation:

Select a special div with CSS

If I have this HTML code:

<div class="profile-header col-sm-4">
    <div class="profile-cover">
        <h1>01</h1>
        <div class="row">
            <div class="col-sm-6">
                <div class="checkbox checkbox-primary">
                    ...
                </div>
            </div>
            <div class="col-sm-6">
                <div class="btn-group">
                    ...
                </div>
            </div>
        </div>
    </div>
</div>

How can I select the div.checkbox in CSS ?

I tried:

.profile-cover > .checkbox

I do not want to be too large by selecting .checkbox.

Thanks.

Upvotes: 1

Views: 64

Answers (2)

aleha_84
aleha_84

Reputation: 8539

sorted in descending order of accuracy (all will hit your targeted element):

.profile-header>.profile-cover>.row>.col-sm-6>div.checkbox,
.profile-header>.profile-cover>.row div.checkbox,
.profile-header>.profile-cover div.checkbox,
.profile-header div.checkbox,
.profile-cover div.checkbox

Upvotes: 0

cmbuckley
cmbuckley

Reputation: 42547

A > B only selects a child (direct descendant), so it sounds like you just need:

.profile-cover .checkbox

Which means .checkbox anywhere inside .profile-cover.

Upvotes: 2

Related Questions