I'd appreciate some help with formatting these radio buttons:
.frm_radio div {
display:flex!important;
align-items: center!important;
justify-content: center!important;
width:100%!important;
height:400px!important;
background:white!important;
border-radius:50%!important;
border:3px black solid!important;;
}
.frm_radio label {
width:80%!important;
font-size:30px!important;
color:black!important;
line-height:1.2!important;
margin:auto!important;
}
.frm_radio input:checked + div {
background:#FFC5FF!important;
}
.frm_radio input {
display:none!important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="frm_radio" id="frm_radio_15-0"> <input type="radio" name="item_meta[15]" id="field_2ycsr-0" value="0.65" data-frmval="1" data-invmsg="Watcha normally eat? is invalid"><div>
<label for="field_2ycsr-0"> <3 plants (vegan or vegetarian)</label></div></div>
The whole thing is wrapped up in a CSS-Grid that makes everything square (so they're circles instead of ovals). I've emulated that in this CSS just by adding a height.
My issue is that I want the entire circle to be clickable; now only the text is clickable. How should I lay this out to make it work that way?
Reason for all the !important tags: I'm using Formidable Forms plugin to make the form. I realise it's messy, but it works just fine for this!
To make the whole circle clickable, move <input> into <label> tag (in this case, you can also remove id and for attributes). So, the resulted solution should be:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="frm_radio" id="frm_radio_15-0">
<label>
<input type="radio" name="item_meta[15]" value="0.65" data-frmval="1" data-invmsg="Watcha normally eat? is invalid">
<div>
<3 plants (vegan or vegetarian)
</div>
</label>
</div>
Related
This question already has an answer here:
List of HTML5 elements that can be nested inside P element?
(1 answer)
Closed 2 years ago.
I want to offer a selection by radio buttons. Upon hovering over the label for the button, I want there to appear an explanation for that option.
I can achieve this by putting the explanation text into a span-element, but not in a p-element...and I fail to understand the difference:
<fieldset>
<h2>Select player</h2>
<div clas="radios">
<legend>Select character class:</legend>
<p class="row">
<input type="radio" id="character-ninja" name="character" value="ninja">
<label for="character-ninja" class="show">Ninja</label>
<p class="hidden">The ninja class....</p>
</p>
</div>
</fieldset>
with the style sheet
.hidden{
display: none;
}
.show:hover + .hidden{
display: block;
}
The text in the p-element is hidden by "display:none", but it does not appear upon hovering over the text in the label-element.
If I change the p-element into a span-element, the text is also hidden by "display:none", but it does appear upon hovering over the text in the label-element.
I think that the different behavior might be the result of nesting a p-element within a p-element...but even so I don't quite understand why it is "partially working", as I would call it.
You should use div as a row element:
<div class="row">
The reason why nested p tags does not work in your code is that it is not valid HTML. It is corrected by the browser. So the sibling of label is no longer p then.
.hidden{
display: none;
}
.show:hover + .hidden{
display: block;
}
<fieldset>
<h2>Select player</h2>
<div clas="radios">
<legend>Select character class:</legend>
<div class="row">
<input type="radio" id="character-ninja" name="character" value="ninja">
<label for="character-ninja" class="show">Ninja</label>
<p class="hidden">The ninja class....</p>
</div>
</div>
</fieldset>
I want to exclude materialize css for some items in my view. Eg: i dont want to display materialize styles to check box under table. It causes problems with my internal jquery library. Please check attached image. I gave below html content in my table > td. I want to display this as browser default checkbox.
In my application i am using http://materializecss.com
<div class="checkbox">
<input type="checkbox" class="filled-in dt-checkboxes">
<label></label>
</div>
To remove the Materialize styles from the checkboxes, you first need to understand how the Materialize checkboxes are created:
The "real" checkbox is removed with opacity: 0; and some positioning
A "fake" checkbox is created with the help of the pseudo elements ::before and ::after on the <span> element
So all you need to do is hide the pseudo elements and make the real checkbox visible again. I created a class .reset-checkbox to demonstrate the effect:
[type="checkbox"].reset-checkbox,
[type="checkbox"].reset-checkbox:checked,
[type="checkbox"].reset-checkbox:not(checked) {
opacity: 1;
position: relative;
}
[type="checkbox"].reset-checkbox+span::before,
[type="checkbox"].reset-checkbox+span::after,
[type="checkbox"].reset-checkbox:checked+span::before,
[type="checkbox"].reset-checkbox:checked+span::after {
display: none;
}
[type="checkbox"].reset-checkbox+span:not(.lever) {
padding-left: 10px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css" rel="stylesheet" />
<form action="#">
<div>
<label>
<input type="checkbox" class="filled-in" />
<span>Test with Materialize</span>
</label>
</div>
<div>
<label>
<input type="checkbox" class="filled-in reset-checkbox" />
<span>Test with removed styles</span>
</label>
</div>
</form>
Pay attention to a higher specificity of the selectors here, to make sure that the Materialize styles are overwritten.
I have to create a navigation menu using HTML and CSS without Javascript for my eBay store. What I want to do is to create many radio buttons with many labels and clicking on a label make label bold and make appear a text.
First effect on JSFiddle: https://jsfiddle.net/fb2yn5ts/
(click on label make a text appears)
My Label
<div id="descrizione">
This is some text
</div>
css
#descrizione{
display: none;
}
#descrizione:target{
display: block;
}
Second effect on JSFiddle: https://jsfiddle.net/cv83q9ow/
(Click on label make label bold)
<div>
<input type="radio" id="check" class="check-with-label" />
<label for="check" class="label-for-check">My Label</label>
<div>
css:
.check-with-label:checked + .label-for-check {
font-weight: bold;
}
I can't merge these effects into one, do you know why and how can I solve this?
Thank you very very much!
OK guys I solved this problem by doing this:
HTML:
<input type="radio" name="navbar_menu_store" id="input_description" class="radio_item_menu">
<label for="input_description" class="label_item_menu">Description</label>
<input type="radio" name="navbar_menu_store" id="input_shipping" class="radio_item_menu">
<label for="input_shipping" class="label_item_menu">Shipping</label>
<div id="contentDescription"><p class="testo_scheda">
This is some text</p>
</div>
<div id="contentShipping"><p class="testo_scheda">
This is some other text</p>
</div>
css:
#input_description:checked ~ #contentDescription, #input_shipping:checked ~ #contentShipping {
display: block;
}
#contentDescription, #contentShipping{
display: none;
}
.radio_item_menu:checked + .label_item_menu {
font-weight: bold;
}
Preview: https://jsfiddle.net/LLornfn8/
Thank you very much anyway!
span{
text-align: justify;
}
<input type="checkbox" name="type"><span>Excessive Reinforcement</span><br>
I want to align the label for excessive reinforcement checkbox like image2
For example
Thanks in advance
First of all use <label> instead of <span>.
If we use bootstrap we generally manage this with classes but here if we talk about custom css this can be a solution.
label{
text-align: justify;
float: left;
line-height: 20px;
}
input{
float:left;
}
<input type="checkbox" id="check" name="type"><label for="check">Excessive<br>Reinforcement</label><br>
Above i added id in checkbox and for in label so that checkbox will be selected on click of label also.
If you can change the HTML
The best and new method to use checkbox is
<label><input type="checkbox" name="type">Excessive Reinforcement</label>
span {
text-align: justify;
}
.make-table {
display: table-cell;
/* make it behave like table-cell. so that they fall beside each other. */
}
<div class="any-class">
<label><span class="make-table"><input type="checkbox" name="type"></span>
<span class="make-table">Excessive<br> Reinforcement</span>
</label>
</div>
<hr>
<div style="color:red">Wrap it inside any-class and align as you want.
<br>I added LABEL tag, so that, even if your user clicks on the text, the checkbox will work.</div>
Make this simple change!
This is one way of doing it:
<label for="type-1">
<input id="type=1" type="checkbox" name="type"> Excessive Reinforcement
</label><br>
When using input elements, you should always provide a label with the for attribute assigned the id of the input element. And also make sure the input element ids are unique.
I have created a "CSS-only" Website that uses only CSS/HTML/PHP, with a CSS Menu, dynamic loading content (images) and a CSS Magnifier. I don´t want to use Javascript/jQuery or Cookies and the Website works perfectly so far. The layout was really hard to adjust to fit correctly to all browsers but finally I got the Apple-InternetExplorer (Safari) working too.
For the menu I used the "Checkbox Hack". But instead of checkboxes I´m using radio-buttons to display only one content-page. That looks like this:
<!--
We need these input-fields to trigger display:block on another element
The radio-buttons must use the same "name" to jump between different content-pages.
(only 1 Radio-Button can be active)
-->
<input type="radio" id="radioactive-1" name="radioactive">
<input type="radio" id="radioactive-2" name="radioactive">
<!-- This simple menu triggers the radio-button with the id (for=id) -->
<label for="radioactive-1">Menu-Entry 1</label>
<label for="radioactive-2">Menu-Entry 2</label>
<!-- Heres the content to display, but it is set to display: none;
so the content only gets displayed if the correct radio-button is active -->
<div id='content-wrapper'>
<div id='not-radioactive-1' style='display:none;'></div>
<div id='not-radioactive-2' style='display:none;'></div>
</div>
That markup was shortened, but I think its clear enough. Now we need the CSS which is important to get this to work:
input[id="radioactive-1"]:checked ~ #content-wrapper #not-radioactive-1 {
display:block!important;
}
input[id="radioactive-2"]:checked ~ #content-wrapper #not-radioactive-2 {
display:block!important;
}
You can see that these CSS-Declarations can get very long and I´m triggering multiple styles to different elements with one click. The code for the menu is ~20 KB and thats massive.(50% the size of my CSS-File)
Now my question: Is there any way to get the number of the class for the input field to use it for the content class?
Example:
input[id="radioactive-$value"]:checked ~ #not-radioactive-$value
I know one way to ignore the number and use all id´s including a defined string.
Example:
input[id^="radioactive-"]:checked
I also know that I can use PHP and just do a loop but in the end the CSS have the same size, because the whole code gets echoed. I´m searching for a CSS-only solution if this is possible. I only want to shorten my code and speed up page-loading.
You can do that without relying on those numbers by inserting the radio buttons directly before each section:
HTML:
<div id="content-wrapper">
<input type="radio" id="radioactive-1" name="radioactive">
<div class="content"></div>
<input type="radio" id="radioactive-2" name="radioactive">
<div class="content"></div>
</div>
CSS:
.content {
display: none;
}
input[name="radioactive"]:checked + .content {
display: block;
}
It doesn't matter where the labels are, as long as the for attributes matches to some input.
One solution is that you can use the PHP loop in the HTML file and using the loop, print following piece of code,
<div id='content-wrapper'>
<input type="radio" id="radioactive-1" name="radioactive">
<label for="radioactive-1">Menu-Entry 1</label>
<div id='not-radioactive-1' style='display:none;'></div>
<input type="radio" id="radioactive-2" name="radioactive">
<label for="radioactive-2">Menu-Entry 2</label>
<div id='not-radioactive-2' style='display:none;'></div>
</div>
And the CSS file would have the following,
input[type="radio"]:checked ~ div {
display:block!important;
}