CSS-powered tabs which necessitate the conventional display of radio buttons and labels inside each tab

Creating CSS-only tabs involves hiding the radio button and styling the tab label accordingly.

.tabs input[type="radio"] {
  position: absolute;
  top: -9999px;
  left: -9999px;
}
.tabs label {
  display: block;
  min-height: 150px;
  padding: 4px 4px;
  [...]
  }
.tabs label:hover {
  background: #E0F8E0;
}
.tabs .tab-content {
  z-index: 2;
  display: none;
  overflow: hidden;
  width: 100%;
  font-size: 1.08em;
  line-height: 1.1em;
  padding: 22px;
  position: absolute;
  top: 53px;
  left: 0;
  background: #ffffff;
}
.tabs [id^="tab"]:checked + label {
  top: 0;
  padding-top: 3px;
  border-top: 3px solid #E0F8E0;
}
.tabs [id^="tab"]:checked ~ [id^="tab-content"] {
  display: block;
}

However, when it comes to the visible div content, the inner radio buttons and labels should revert back to a standard style.

<ul class='tabs'>
  <li>
    <input type='radio' name='tabs' id='tab_101' checked />
  <label for='tab_101'>
    <img id='101' name='masteroption %>' src='/masters/101.jpg' />
  </label>
  <div id='tab-content_101' class='tab-content'>
    <input type="radio" id="432432" name="depth" value="432" checked="checked" class='tabs-inner'>
    <label class='tabs-inner-label'>432mm</label>

I have assigned specific classes to the inner radio buttons and labels,

.tabs-inner[type='radio'] + label {
    display: inline-block;
    margin-left: 0.5rem;
    margin-right: 1rem;
    margin-bottom: 0;
    vertical-align: baseline;
}
.tabs-inner-label {
    display: block;
    margin: 0;
    font-size: 0.875rem;
    font-weight: normal;
    line-height: 1.8;
    color: #0a0a0a;
}

but the browser developer tool indicates that the applied class is still coming from the parent element instead of the directly assigned one https://i.sstatic.net/32wxg.png

How can I apply different styles to these nested elements?

Answer №1

give this a shot

.navigation .nav-list .nav-item-label{
    display: inline-block;
    margin: 0 auto;
    font-size: 1rem;
    font-weight: bold;
    line-height: 2;
    color: #333333;
}

Avoid using !important unless necessary.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Wordpress and JavaScript to dynamically hide a button if a product in the online store does not have an SKU

I'm encountering an issue on my Wordpress site where products with variations are not displaying the inner text on a certain element, despite the fact that the text is present when I inspect the element. Here's the code: const makerBtn = document ...

Mastering the art of incorporating background image transitions and creating a seamless slider for navigation

Is there a way to create a navigation menu like the one on this theme? On this theme, when you hover over a menu item, the background image smoothly moves left or right to the item you are hovering on. If anyone knows of plugins that can achieve this eff ...

What is the NOT selector used with the CSS contains function for?

I have a question regarding my Selenium code. I am currently using the following snippet: WaitForElement(By.CssSelector("#document-count:contains(<number greater than 0>)")); The part where I'm stuck is specifying number greater than 0. Is the ...

What is the best way to resize an HTML element to fill the remaining height?

I'm struggling with adjusting the height of a node-webkit app to fit the current window size. See below for an image depicting what I am aiming for. Intended Goal : HTML Markup : <body> <div class="header"> THIS IS A HEADER W ...

What is the best way to create a gap between two Bootstrap buttons?

I'm attempting to create two buttons in the same line in this code, but it's not working as I want. Take a look below: <div class="w3-show-inline-block"> <div class="w3-bar"> <button class="btn btn-s ...

How to Remove a CSS Class from an <li> Tag in ASP.net Using Code Behind

Currently, I am adding a CSS class to my li tag using the following code snippet: liComPapers.Attributes.Add("class", "NoDisplay"); Is there a way to remove this specific class (NoDisplay) from the li tag at a different location in my code? I have attem ...

How can I insert an image into a circular shape using HTML and CSS?

To achieve the desired effect, the image should be placed inside a circle with a white background. The image size should be smaller than the circle and centered within it. One possible way to accomplish this is: .icon i { color: #fff; width: 40px; ...

Strategies for styling the contents within <details> while excluding <summary> in CSS

I'm attempting to apply a 10px padding to the Story box using CSS, without introducing any additional HTML elements into the website code. Is there a way to include the padding in the Story box without incorporating a new HTML element? To clarify: H ...

Tips for aligning multiple columns within a Bootstrap 3 carousel

For quite some time, I have been trying to solve this puzzle. My goal is to have the featured image displayed to the left of the carousel, with its associated text to the right. I've created a mockup to illustrate exactly what I mean. I can achieve t ...

Clickable regions in Internet Explorer 7 that lack a specific width

Is there a way to make the clickable area of links always stretch to the parents container when the parent container does not have a fixed width? For example, check out this JSFiddle. In Firefox, the link stretches with the text and the li tag, but in IE ...

Could we incorporate a backwards typewriter animation?

Is there a way to delay this animation for 2 seconds before playing in reverse? I came across this online and made some edits, but I'm still new to this (early stages). Can this be achieved using CSS, HTML, and JavaScript? I plan to use this as an ale ...

The webpage appears fine on the local server, but displays incorrectly on IIS (Internet Explorer 11)

My project looks great when I run it locally on my computer and open the page in Internet Explorer 11: https://i.stack.imgur.com/yZvo2.png However, when I deploy the page to an IIS server and navigate to the page, it appears differently in Internet Explo ...

Turn an entire div into a clickable element with a functional :active CSS rule that is compatible with IE10

I am currently working on designing a clickable panel for an html app that will include multiple text elements and images. Based on my understanding, this is typically achieved using a div. An example of this would be: <div class="myButton"> &l ...

Bootstrap mobile menu logo design

Currently, I am working on a bootstrap template where I have created a div class containing a logo. However, I have noticed that when I resize the Chrome window, the logo overlaps with the mobile menu. Here is the mobile version of my site: https://i.sst ...

Struggling to design a responsive layout as the div on the right keeps overlapping the div on the left

I recently built a React component that consists of two columns. In the left column, there's a calendar while the right column contains some text along with an input and select field. However, I noticed that when I resize the window, the elements on ...

When I click on .toggle-menu, I want the data-target to have a toggled class and the other divs to expand

Looking to achieve a functionality where clicking on .toggle-menu will toggle a class on the specified data-target element and expand other divs accordingly. jQuery(document).ready(function() { var windowWidth = jQuery(window).width(); if (win ...

Display elements on the side of the page using jQuery as the user scrolls

I'm in search of a helpful jQuery plugin that I can't quite put a name to! Can anyone point me in the right direction? Take a look at this website for inspiration: On that page, you'll notice that as you scroll down, elements smoothly appe ...

Enhanced Bootstrap Carousel with White Background Transitions

Having trouble articulating my issue, so here's a video that should clarify: https://example.com/video I'm using a bootstrap carousel template for a full-width slider. Despite my efforts to remove the white-space transitions, they persist. Am I ...

Change the css code to override the color of the background material

Hey there, I'm facing an issue with overriding the background color of a material element. I've tried several methods but can't seem to get it to change. After inspecting the element on the web browser, I found the CSS code that controls th ...

Issues with jQuery causing responsive CSS triangles to fail implementations

Recently, I stumbled upon the interesting concept of CSS triangles created using element borders. I decided to incorporate this design into one of my custom Wordpress themes, but I encountered a problem. I wanted to add a triangle at the bottom of a div, l ...