KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a question about the priority of CSS classes after encountering a problem today. The situation is as follows: I have an unordered list which has a class associated with it. The LI tags have some styles defined too. I want to change the styling of the LI s after a click (via an added "selected" class), but the added class's styles are never applied. Is this normal behavior or should this code work? CSS: .dynamicList { list-style: none; } .dynamicList li { display: block; width: 400px; height: 55px; padding: 10px 10px 10px 10px; border: 1px solid #000; background-color: #ff0000; } .selectedItem { background-color: #0000ff; } HTML: <ul class="dynamicList"> <li>First Item</li> <li class="selectedItem">Second (Selected) Item</li> </ul> The background color of the "selected" list item isn't changed. This is also the case if I don't apply the style to the LI element, but create another class and apply that to all the list items so it reads.. <li class="listitem selectedItem">xxxx</li>
Tags (comma-separated)
Save Edits
Cancel