Reputation: 4978
I am using angularjs and following is my css
table {
border: 1px solid black;
padding: 0.5em;
}
td {
padding: 1em;
border: 2px solid gray;
}
td:hover {
cursor: default;
background-color: gray;
}
.active {
border: 2px solid lightgreen;
border-radius: 5px;
}
.booked {
background-color: lightgray;
}
.no_seat {
padding: 0em;
border: 2px white;
background-color: white;
}
.filled {
background-color: teal;
}
I want to remove td:hover effect if it is no_seat I removed the border for the cells if no_seat by resetting padding and border but dont know how to remove the hover effect.
following is my index.html
<div ng-app="bookYourSeatApp" ng-controller="mainCtrl as ctrl">
<label>Persons <select ng-model="ctrl.selectedCount" ng-change="ctrl.seats.setAvailCount(ctrl.selectedCount)" ng-options="count as count.val for count in ctrl.selectionCount"></select></label>
Seats left: {{ctrl.seats.availCount}}<br/>
Seats selected: {{ctrl.seats.checkedSeats}}<br/>
<table ng-repeat="(key, rang) in ctrl.seats.map">
<tr ng-repeat="row in rang.seats">
<td ng-repeat="seat in row" ng-class="{'active': seat.checked, 'booked': seat.status == 'UNAVAILABLE', 'no_seat': seat.status == 'NO_SEAT', 'filled': seat.status == 'FILLED'}" ng-click="ctrl.seats.select({rang:key, row:row, seat: seat}, ctrl.selectedCount)">
{{seat.caption}}
</td>
</tr>
</table>
</div>
Upvotes: 4
Views: 1990
Reputation: 26751
You are looking for the :not
pseudo-class.
The negation CSS pseudo-class, :not(X), is a functional notation taking a simple selector X as an argument. It matches an element that is not represented by the argument. X must not contain another negation selector.
Change this:
td:hover {
cursor: default;
background-color: gray;
}
To this:
td:not(.no_seat):hover {
cursor: default;
background-color: gray;
}
Upvotes: 4
Reputation: 26160
If I understand your question properly, this can be done simply with pure css.
Combine your css selectors:
td:hover {
cursor: default;
background-color: gray;
}
.no_seat {
padding: 0em;
border: 2px white;
background-color: white;
}
/* this will control the "no_seat" hovered styles */
td.no_seat:hover {
background-color: white;
/* any other styles you want here */
}
As @ricky_ruiz points out in his answer, you could also use the :not()
pseudo-selector, but IMO that could get complicated if you had other classes you wanted it to not affect...
Upvotes: 4