I’m working on modifying a large project that uses HTML and CSS, among other things.
I need to re-style just one radio button group – so it has buttons and labels, not just labels. I specifically don’t want to re-style the whole project’s buttons – it’s too big to wade through all that and risk messing up other parts of it.
Right now, the buttons look like:
But I want them to look more like (with Preserved and Unpreserved):
I’ve tried more things than I can count, but most recently…
I tried the following CSS (minified):
.un_preserve_radio{all:initial;visibility:visible;appearance:radio;opacity:1;position:fixed;width:100%;-webkit-appearance:radio;-moz-appearance:radio;-O-appearance:radio}
With the following HTML:
<label>
<input type="radio" name="un_preserved" onclick="preserved_button_click()" class="un_preserve_radio" />
Preserved
</label>
<label>
<input type="radio" name="un_preserved" onclick="unpreserved_button_click()" class="un_preserve_radio" />
Unpreserved
</label>
Update: I just tried this HTML, which gave me black text (or blue text if I eliminate the "all: initial"):
<div style="color:blue; all: initial; visibility: visible;">
<label>
<input type="radio" name="un_preserved" onclick="preserved_button_click()" class="un_preserve_radio" />
Preserved
</label>
<label>
<input type="radio" name="un_preserved" onclick="unpreserved_button_click()" class="un_preserve_radio" />
Unpreserved
</label>
<br />
</div>
This is almost a duplicate of reset the css of a input[radio] – but I really do want to reset just one radio button group to CSS defaults.
2
Answers
I needed (for example):
That !important was needed to override 4 global settings.
I also needed to move a
<br />
, but the!important
was the.... most important part.Since you haven’t posted the current CSS that is changing the radio/labels, I have a quick sample here.
First, I gave the wrapping div a class called "radio-override".
Then in CSS, I set the radio children of that class to have the visibility of visible. Then I also gave the label children a color of black and display of block to force each label/radio to a new line.