I have the following CSS I need to apply to only a particular div (because of conflicts):
The div in question has the class name datepicker-days. Do I declare the below table
as .datepicker-days.table
? But then how do I declare the .table
class below that?
CSS
table {
max-width: 100%;
border-collapse: collapse;
border-spacing: 0;
}
.table {
width: 100%;
margin-bottom: 18px;
}
.table th, .table td {
padding: 8px;
line-height: 18px;
text-align: left;
border-top: 1px solid #ddd;
}
HTML
<div class="datepicker-days" style="display: block; ">
<table class=" table-condensed">
<thead>
<tr>
<th class="prev">
....
Sorry if this wasn't clear, the CSS rules are from Bootstrap. I'm just using a few of the rules because the datepicker plugin I am using depends on those particular rules. So where I have other instances of <tables>
in my code, I don't want these rules to apply.
Just use the descendant selector:
.datepicker-days table {
/* this rule will only apply to `<table>` elements that are descendents of any element with class "datepicker-days" */
}
.datepicker-days { /* Targets the div */ }
.datepicker-days table { /* targets all tables nested in the div */ }
.datepicker-days > table { /*targets only tables that are direct children on the div */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With