Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Change background color of CSS tab label

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #240495
    henryvuong
    Participant

    I want to change background color of the selected tab label in this script:

    http://codepen.io/henryvuong/pen/ONvJej

    When users click on one of the tab labels, the background color of the selected tab label should change to white to match the content’s background, and the label text should be white. I thought the last selector should do the job but it does not.

    #240499
    Beverleyh
    Participant

    There is no parent, or previous sibling selector in CSS.

    The general sibling selector (~) matches elements that are siblings of a given element, that come after it in the markup. It can’t go backwards/up the DOM.

    To achieve what you’re describing you would either need to change the markup so that the label comes after the radio, or use JavaScript.

    #240501
    Atelierbram
    Participant
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.