ata
ata

Reputation: 3648

Assign one property to child of a class

I've a class named entry that contains different parts of post article of my web site. Something like below:

<div class="entry">
 <div id="author-box-single">
  <div class="author-box">
   <div class="at-img">
   </div>
  </div>
 </div>

 <h1></h1>
 <p></p>
 <h2></h2>
</div> <!-- End of entry -->

As you see it contains many divs and headlines and etc. How can I assign one property, for example padding-right: 10px to all childs of entry?

Upvotes: 4

Views: 684

Answers (2)

Rahul Arora
Rahul Arora

Reputation: 4543

For direct child for div having class entry, you can use CSS combinators

CSS combinators

div.entry > div{
    padding-right: 10px;
}

For all the divs (even nested) under div having class entry

div.entry div{
    padding-right: 10px;
}

Upvotes: 2

Begmuhammet Kakabayev
Begmuhammet Kakabayev

Reputation: 310

* sign means everything. > means direct children. For example:

.entry > * {
    padding-right: 10px;
}

will assign property to every direct child.

.entry  * {
   padding-right: 10px;
}

will assign property to everything inside it.

You can use div instead of *

.entry > div {
 padding-right: 10px;
}

will assign to all direct <div> children.

Upvotes: 5

Related Questions