Basically, I am trying to create my own radio button component for react and reuse over again, but I am struggling to get the buttons to work correctly with the styling. If you select a button in the second set it doesn't react properly even though each set has a different name property. If I get rid of the custom style it works fine.
I think it has something to do with this, but haven't found a solution:
.radio-custom {
opacity: 0;
position: absolute;
}
Here is my codepen:
https://codepen.io/Sbphillips19/pen/XLyzzN
HTML:
<form>
<h2>Radio Button Prompt 1</h2>
<div>
<input id="radio-1" class="radio-custom" name="radio-group" type="radio">
<label for="radio-1" class="radio-custom-label">First Choice</label>
</div>
<div>
<input id="radio-2" class="radio-custom"name="radio-group" type="radio">
<label for="radio-2" class="radio-custom-label">Second Choice</label>
</div>
<div>
<input id="radio-3" class="radio-custom" name="radio-group" type="radio">
<label for="radio-3" class="radio-custom-label">Third Choice</label>
</div>
</div>
<h2>Radio Button Prompt 2</h2>
<div>
<input id="radio-1" class="radio-custom" name="radio-group-2" type="radio">
<label for="radio-1" class="radio-custom-label">First Choice</label>
</div>
<div>
<input id="radio-2" class="radio-custom"name="radio-group-2" type="radio">
<label for="radio-2" class="radio-custom-label">Second Choice</label>
</div>
<div>
<input id="radio-3" class="radio-custom" name="radio-group-2" type="radio">
<label for="radio-3" class="radio-custom-label">Third Choice</label>
</div>
</div>
</form>
and CSS:
.radio-custom {
opacity: 0;
position: absolute;
}
.radio-custom, .radio-custom-label {
display: inline-block;
vertical-align: middle;
margin: 5px;
cursor: pointer;
}
.checkbox-custom-label, .radio-custom-label {
position: relative;
}
.radio-custom + .radio-custom-label:before {
content: '';
background: white;
border: 2px solid #888888;
display: inline-block;
vertical-align: middle;
width: 44px;
height: 44px;
padding: 2px;
margin-right: 10px;
text-align: center;
border-radius: 50%;
}
.radio-custom:checked + .radio-custom-label:before {
background: #444444;
box-shadow: inset 0px 0px 0px 6px #fff;
}
The problem is with the attr id that should be unique!
Change the following second part of the html to this and it will work:
Working example:https://codepen.io/jo-o-teixeira-the-sasster/pen/agQErM
Radio Button Prompt 2
<div>
<input id="radio-4" class="radio-custom" name="radio-group-2" type="radio">
<label for="radio-4" class="radio-custom-label">First Choice</label>
</div>
<div>
<input id="radio-5" class="radio-custom"name="radio-group-2" type="radio">
<label for="radio-5" class="radio-custom-label">Second Choice</label>
</div>
<div>
<input id="radio-6" class="radio-custom" name="radio-group-2" type="radio">
<label for="radio-6" class="radio-custom-label">Third Choice</label>
</div>
</div>
Related
So I have created a form with different type of elements (including radio, checkbox, text input etc.) and I cannot figure out how to make the whole form look neat. Ideally I want all labels aligned on the left side, except labels for radio buttons which should be aligned with the input fields.
My pen:
https://codepen.io/andreas-soteriou/pen/NWwEywR?editors=1100
I coloured the labels and inputs, for me to visualise as I am fairly new to this!
<header>
<h1 id="title">Print selection</h1>
<p id="description">Tailor your prints</p>
</header>
<body>
<main>
<form id="survey-form">
<h2 class="selection">start your selection here</h2>
<label id="label-input" for="name">Name:</label>
<input class="input" id="name" type="text" name="name" placeholder="First Last" required>
<br>
<label id="email-input" for="email">E-mail:</label>
<input id="email" type="text" name="email" placeholder="first.last#gmail.com" required>
<br>
<label id="number-input" for="number">Age:</label>
<input id="number" type="number" name="number" min="18" max="99" required>
<br>
<label for="dropdown">Select frame:</label>
<select id="dropdown" name="frames">
<option value="gold frame">Gold</option>
<option value="metallic frame">Metallic</option>
<option value="wooden frame">Wooden</option>
</select>
<br>
<!--RADIO--->
<label>Size of print:</label>
<br>
<input id="print_size" type="radio" name="print_size" value="10x10">
<label for="print_size">10x10 199:-</label>
<input id="print_size" type="radio" name="print_size" value="20x20">
<label for="print_size">20x20 299:-</label>
<input id="print_size" type="radio" name="print_size" value="40x40">
<label for="print_size">40x40 399:-</label>
<input id="print_size" type="radio" name="print_size" value="80x80">
<label for="print_size">80x80 599:-</label>
<!--CHECKBOX--->
<div>
<label>Additional features:</label>
<br>
<input id="feature1" type="checkbox" name="feature1" value="polished_glass">
<label for="feature1">Polished glass +100:-</label>
<br>
<input id="feature2" type="checkbox" name="feature2" value="3d_print">
<label for="feature2">3D-print +500:-</label>
</div>
<!--TEXTAREA--->
<div>
<label for="final_inputs">Additional input:</label>
<textarea id="final_inputs" name="final_inputs" rows="5" cols="20"></textarea>
</div>
<!--SUBMIT--->
<div>
<button type"submit" id="submit" value="submit">Submit order</button>
</div>
</form>
</main>
</body>
header, body {
color: black;
font-family: copperplate, sans-serif;
}
header {
text-align: center;
background-color: #C0C0C080;
margin: auto;
padding: 10px;
text-transform: uppercase;
}
body {
background-image: url("https://images.unsplash.com/photo-1504870712357-65ea720d6078?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1528&q=80");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
#survey-form {
text-align: center;
color: dark-grey;
font-size: 12px;
padding: 10px;
width: 80%;
background-color: #C0C0C099;
margin: auto;
margin-top: 80px;
border-radius: 25px;
}
.selection {
margin-top: 1px;
margin-bottom: 15px;
}
label,input, select {
display: inline-block;
}
label {
width: 20%;
text-align: right;
background-color:red;
margin-right: 2px;
}
input {
width: 40%;
text-align: left;
background-color:blue;
margin-top: 2px;
}
header,
body {
color: black;
font-family: copperplate, sans-serif;
}
header {
text-align: center;
background-color: #C0C0C080;
margin: auto;
padding: 10px;
text-transform: uppercase;
}
body {
background-image: url("https://images.unsplash.com/photo-1504870712357-65ea720d6078?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1528&q=80");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
#survey-form {
text-align: center;
color: dark-grey;
font-size: 12px;
padding: 10px;
width: 80%;
background-color: #C0C0C099;
margin: auto;
margin-top: 80px;
border-radius: 25px;
}
.selection {
margin-top: 1px;
margin-bottom: 15px;
}
label,
input,
select {
display: inline-block;
}
label {
width: 20%;
text-align: right;
background-color: red;
margin-right: 2px;
}
input {
width: 40%;
text-align: left;
background-color: blue;
margin-top: 2px;
}
<header>
<h1 id="title">Print selection</h1>
<p id="description">Tailor your prints</p>
</header>
<body>
<main>
<form id="survey-form">
<h2 class="selection">start your selection here</h2>
<label id="label-input" for="name">Name:</label>
<input class="input" id="name" type="text" name="name" placeholder="First Last" required>
<br>
<label id="email-input" for="email">E-mail:</label>
<input id="email" type="text" name="email" placeholder="first.last#gmail.com" required>
<br>
<label id="number-input" for="number">Age:</label>
<input id="number" type="number" name="number" min="18" max="99" required>
<br>
<label for="dropdown">Select frame:</label>
<select id="dropdown" name="frames">
<option value="gold frame">Gold</option>
<option value="metallic frame">Metallic</option>
<option value="wooden frame">Wooden</option>
</select>
<br>
<!--RADIO--->
<label>Size of print:</label>
<br>
<input id="print_size" type="radio" name="print_size" value="10x10">
<label for="print_size">10x10 199:-</label>
<input id="print_size" type="radio" name="print_size" value="20x20">
<label for="print_size">20x20 299:-</label>
<input id="print_size" type="radio" name="print_size" value="40x40">
<label for="print_size">40x40 399:-</label>
<input id="print_size" type="radio" name="print_size" value="80x80">
<label for="print_size">80x80 599:-</label>
<!--CHECKBOX--->
<div>
<label>Additional features:</label>
<br>
<input id="feature1" type="checkbox" name="feature1" value="polished_glass">
<label for="feature1">Polished glass +100:-</label>
<br>
<input id="feature2" type="checkbox" name="feature2" value="3d_print">
<label for="feature2">3D-print +500:-</label>
</div>
<!--TEXTAREA--->
<div>
<label for="final_inputs">Additional input:</label>
<textarea id="final_inputs" name="final_inputs" rows="5" cols="20"></textarea>
</div>
<!--SUBMIT--->
<div>
<button type "submit" id="submit" value="submit">Submit order</button>
</div>
</form>
</main>
</body>
Here's a simple starting point using CSS Grid
We are going to use two different grid layouts using the fieldset element and our grid container.
For simple Label | Input pairs the grid's first column will be the label taking 25% of the available space with the input occupying the rest.
For the radio button or check box groups, we will add a class to the fieldset then use three columns with 25% for the group label, auto for the input width, with the input label occupying the rest
fieldset {
border: none;
/*Set up base grid*/
display: grid;
/*Set Columns, first column is 25% the second takes up the rest*/
grid-template-columns: 25% 1fr;
row-gap: 0.5em;
}
/*Label styling*/
fieldset label {
text-align: right;
padding-right: 0.25em;
}
/*Additional set up for button group*/
fieldset.button-group {
/*For out button group rows we want the first col 25% ,
control minimum space, then next col take the rest*/
grid-template-columns: 25% auto 1fr;
}
/*Addditional stylings for the button/checkbox labels*/
fieldset.button-group label:not(:first-of-type) {
text-align: left;
}
/*Bump the buttons & check boxes to second column*/
fieldset.button-group input {
grid-column-start: 2;
}
<header>
<h1 id="title">Print selection</h1>
<p id="description">Tailor your prints</p>
</header>
<main>
<form id="survey-form">
<h2 class="selection">start your selection here</h2>
<fieldset>
<label id="label-input" for="name">Name:</label>
<input class="input" id="name" type="text" name="name" placeholder="First Last" required>
<label id="email-input" for="email">E-mail:</label>
<input id="email" type="text" name="email" placeholder="first.last#gmail.com" required>
<label id="number-input" for="number">Age:</label>
<input id="number" type="number" name="number" min="18" max="99" required>
<label for="dropdown">Select frame:</label>
<select id="dropdown" name="frames">
<option value="gold frame">Gold</option>
<option value="metallic frame">Metallic</option>
<option value="wooden frame">Wooden</option>
</select>
</fieldset>
<!--RADIO--->
<fieldset class="button-group">
<label>Size of print:</label>
<input id="print_size_199" type="radio" name="print_size" value="10x10">
<label for="print_size_199">10x10 199:-</label>
<input id="print_size_299" type="radio" name="print_size" value="20x20">
<label for="print_size_299">20x20 299:-</label>
<input id="print_size_399" type="radio" name="print_size" value="40x40">
<label for="print_size_399">40x40 399:-</label>
<input id="print_size_599" type="radio" name="print_size" value="80x80">
<label for="print_size_599">80x80 599:-</label>
</fieldset>
<!--CHECKBOX--->
<fieldset class="button-group">
<label>Additional features:</label>
<input id="feature1" type="checkbox" name="feature1" value="polished_glass">
<label for="feature1">Polished glass +100:-</label>
<input id="feature2" type="checkbox" name="feature2" value="3d_print">
<label for="feature2">3D-print +500:-</label>
</fieldset>
<!--TEXTAREA--->
<fieldset>
<label for="final_inputs">Additional input:</label>
<textarea id="final_inputs" name="final_inputs" rows="5" cols="20"></textarea>
</fieldset>
<!--SUBMIT--->
<div>
<button type "submit" id="submit" value="submit">Submit order</button>
</div>
</form>
</main>
I am trying to get my form to center on desktop. It's currently to the left side.
I tried doing display: block and margin-left: auto and margin-right: auto and it is still being fussy.
The picture below shows the issue and I'll add a snippet and a fiddle to help. Thanks in advance.
Jsfiddle: https://jsfiddle.net/r87h2L6n/
/*********FORMS CSS*************/
form {
display: block;
margin-left: auto;
margin-right: auto;
}
form.contact label {
display: block;
}
span {
display: block;
border: none;
color: white;
}
.clearfix:after {
content: " ";
display: block;
clear: both;
}
fieldset {
width: 45%;
float: left;
border: none;
}
input.checks {
width: auto;
}
.left {
width: 45%;
float: left;
}
.right {
width: 45%;
float: right;
}
input {
border: none;
border-bottom: 2px solid #959595;
width: 300px;
margin: 3px;
color: #6C6A6A;
padding-top: 10px;
padding-bottom: 10px;
}
.bottom {
border: none;
margin: 3px;
color: #6C6A6A;
padding-top: 10px;
padding-bottom: 10px;
width: 300px;
}
.fa {
margin-right: 10px;
}
legend {
color: white;
}
.button {
display: inline-block;
padding: 15px 25px;
font-size: 14px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #595959;
border: none;
border-radius: 15px;
box-shadow: 0 9px #999;
width: 150px;
}
.button:hover {
background-color: #670809
}
.button:active {
background-color: #670809;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
<section class="clearfix" id="fourthpara">
<div class="imgbox5">
<img id="pic5" class="adjustable float move" src="http://weknowyourdreams.com/images/kitten/kitten-08.jpg" alt="example web page">
</div>
<h2>Student Review 3</h2>
<p class="side">
“This class is up to date on the latest techniques, the instructor is willing to go the extra mile, and the class is well structured” -Papa Smurf
</p>
</section>
</div>
</section>
<div class="center clearfix">
<h1 id="fourth">Contact</h1>
<form action="FormToEmail.php" method="POST" enctype="multipart/form-data" autocomplete="on" class="contact clearfix ">
<section class="clearfix">
<fieldset>
<legend>
<i class="fa fa-user" aria-hidden="true"></i>Personal Information
<hr class="style2">
</legend>
<label><span></span>
<input name="first_name" type="text" value="" placeholder="First Name" required/>
</label>
<label><span>
</span>
<input name="last_name" type="text" value="" placeholder="Last Name" required/>
</label>
<label><span> </span>
<input name="date_of_birth" type="date" value="" placeholder="Date of Birth" required/>
</label>
<label><span>
</span>
<input type="number" name="quantity" min="1" max="6" placeholder="number of years until next degree">
</label>
<label><span></span>
<input name="level_of_education" type="hidden" value="" placeholder="level of education" required/>
</label>
<select class="bottom" name="education_level">
<option value="High School">High School</option>
<option value="Undergraduate">Undergradute</option>
<option value="Graduate">Graduate</option>
</select>
</fieldset>
<fieldset>
<legend><i class="fa fa-envelope-o" aria-hidden="true"></i>
Contact Information
<hr class="style2">
</legend>
<label><span>
</span>
<input class="ghost-input" name="email" value="" type="email" placeholder="youremail#email.com" autocomplete="off" />
</label>
<label><span></span>
<input name="phonenumber" value="" type="tel" placeholder="763-858-9564" />
</label>
<label><span></span>
<input name="website" value="" type="url" placeholder="https://yourwebsite.com" />
</label>
</fieldset>
</section>
<section class="clearfix column">
<fieldset>
<legend><i class="fa fa-laptop" aria-hidden="true"></i>
What are your Interests
<hr class="style2">
</legend>
<section class="clearfix column left">
<label class="bottom span"><span><input name="webdesign" value="web_design" type="checkbox" class="checks"/>Web Design</span>
</label>
<label class="bottom"><span><input name="webdevelopment" value="web_development" type="checkbox" class="checks" />Web Development</span>
</label>
<label class="bottom"><span><input name="computerscience" value="computer_science" type="checkbox"class="checks" />Computer Science</span>
</label>
</section>
<section class="clearfix column left">
<label class="bottom"><span><input name="graphicdesign" value="graphic_design" type="checkbox" class="checks"/>Graphic Design</span>
</label>
<label class="bottom"><span><input name="userexperience" value="user_experience" type="checkbox" class="checks" />User Experience</span>
</label>
<label class="bottom"><span><input class="checks" name="appdevelopment" value="app_development" type="checkbox" />App Development</span>
</label>
</section>
</fieldset>
<fieldset>
<legend><i class="fa fa-volume-control-phone" aria-hidden="true">
</i>
Follow Up
<hr class="style2 toosmall">
</legend>
<section class="clearfix column left">
<legend class="smaller">You can contact me by:</legend>
<br>
<div class="squish">
<label class="bottom"><span><input class="checks" name="contact_me" type="radio" value="phone" checked/>Contact me by phone</span>
</label>
<label class="bottom"><span><input class="checks" name="contact_me" type="radio" value="email" checked/>Contact me by email</span>
</label>
<label class="bottom"><span><input class="checks" name="contact_me" type="radio" value="text"/>Contact me by text</span>
</label>
<br>
</div>
</section>
<section class="clearfix column left">
<legend class="smaller">I'm interested in:</legend>
<br>
<label class="bottom"><span><input class="checks" name="interest" type="radio" value="text"/>Undergraduate</span>
</label>
<label class="bottom"><span><input class="checks" name="interest" type="radio" value="text"/>Graduate</span>
</label>
<label class="bottom"><span><input class="checks" name="interest" type="radio" value="text"/>Online</span>
</label>
</section>
</fieldset>
</section>
<input class="button" name="submit_to_programmer" type="submit" value="Submit" />
<input type="hidden" value="Message from Car Website" name="subject">
<input name="redirect" type="hidden" value="thanks.html">
</form>
To add to Michael_B`s answer your form is set to take up the full width of the page as its a block element by default and you have set it as well. Margin auto only works for elements that are block or inline-block elements and they width of either must be set to a specified value for it to work.
To address your problem now, looking at your source code, you can get the result you expect by removing the float set on your fieldset element in your CSS and setting Margin to auto in that element. I am not sure what the purpose of the float in that CSS rule but you cannot center something that you have set to float. Hope this helps
The reason it's not centering is that your form element is a block level container and, therefore, it's occupying 100% width of the page. As a result, there no space left for centering.
As you wrote:
I tried doing display: block and margin-left: auto and margin-right: auto and it is still being fussy.
Well, if you give an element display: block it consumes all available horizontal space. Hence, margin-left: auto and margin-right: auto have no effect.
Try defining a width for the form (e.g. width: 30em), removing float rules and/or giving the form text-align: center, which centers the child elements.
It's not your form that is the issue here, it is your fieldset...again. Give this a whirl.
fieldset {
width: 45%;
margin: 0 auto;
/* float: left; -- DELETE float: left if you want this centered */
border: none;
}
UPDATE:
If you also want that submit button to be centered, here is the css for that.
.button {
margin: 0 auto; /* ADDED THIS */
display: block; /* Took inline-block out, just use block */
padding: 15px 25px;
font-size: 14px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #595959;
border: none;
border-radius: 15px;
box-shadow: 0 9px #999;
width: 150px;
}
LIVE DEMO
Could anyone give new ideas how to realize the following? If it generally possible).
The content of Left panel will be changed dynamically with Angular. So, we can have several items or, for example, 50 items on the panel. In accordance with that, the height of panel will be shorter or overflow hidden will be displayed.
Here is fiddle draft https://jsfiddle.net/b9on9gup/7/
First of all the div class="filter-title" should fill 100% height.
The second, title container shouldn't be in scrolling area. Scroll should be inside div class="radio-container". You could add class .shown on
div class="main-container" to display bottom panel.
Additional condition is good displaying with and without scroll (different quantity of items, different screen resolutions etc).
in fiddle I was trying different ways, so some css properties can be odd.
<body>
<div class = "main-container">
<div class="left-panel">
<div class="filter-container">
<div class="table">
<div class="table-row">
<div class="radio-container">
<div class="overflow">
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm" />
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm" />
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm" />
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm" />
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
<div>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button
</label>
</div>
</div>
</div>
<div class="filter-title">
<span>
Filter title
</span>
</div>
</div>
</div>
</div>
</div>
<div class="bottom-panel"></div>
</div>
</body>
html, body {
height: 100%;
padding: 0;
position: relative;
margin: 0;
}
.main-container {
position: relative;
overflow: hidden;
height: 100%;
width: 100%;
.left-panel {
top: 0;
left: 0;
bottom: 0;
width: 300px;
background: #fff;
position: absolute;
transition: bottom 0.5s ease;
.filter-container {
position: absolute;
background: #F6F6F6;
top: 50%;
transform: translateY(-50%);
width: 100%;
.table {
display: table;
width: 100%;
.table-row {
display: table-row;
height: 100%;
.radio-container {
display: table-cell;
padding: 25px 25px;
display: table-cell;
vertical-align: middle;
.overflow {
overflow-y: scroll;
max-height: 100%;
}
}
}
.filter-title {
display: table-cell;
width: 20px;
background: #539ACC;
vertical-align: middle;
span {
-webkit-writing-mode: vertical-lr;
white-space: nowrap;
}
}
}
}
}
.bottom-panel {
height: 200px;
position: absolute;
bottom: -200px;
background: #F6F6F1;
width: 80%;
left: 0;
right: 0;
margin: auto;
transition: bottom 0.5s ease;
}
&.shown {
.left-panel {
bottom: 200px;
}
.bottom-panel {
bottom: 0;
}
}
}
UPDATE
It's a simple piece of javascript that you can edit to better fill your needs...
it changes the title height if necessary (it actually changes the element's width since the it's rotated 90deg)
var ftitle = document.querySelector('.filter-title');
var radiocont = document.querySelector('.radio-container');
var w = ftitle.clientWidth;
var h = radiocont.clientHeight;
if (h > w) { ftitle.style.width = h + 'px';}
.left-panel {
position: relative;
width: 150px;
}
/*
.radio-container {
height: 100px;
overflow: auto;
}
*/
.radio-container label {
display: block;
}
.filter-title {
background: #ddd;
text-align: center;
position: absolute;
top: 0; left: 0;
transform: translateX(170px) rotate(90deg);
transform-origin: 0 0;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div class = "main-container">
<div class="left-panel">
<div class="radio-container">
<label>
<input type="radio" name="filterFieldsForm"/>
radio button1
</label>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button2
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button3
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button4
</label>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button5
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button6
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button7
</label>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button8
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button9
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button10
</label>
<label>
<input type="radio" name="filterFieldsForm"/>
radio button11
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button12
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button13
</label>
<label>
<input type="radio" name="filterFieldsForm" />
radio button14
</label>
</div>
<div class="filter-title">
<span>Filter title</span>
</div>
</div>
</div>
</body>
</html>
http://jsbin.com/wiyuhu/edit?css,js,output
The best decision I've found in my case is using max-height for div class= "overflow" and media-queries min-height.
I noticed scroll is displayed if to set max-height for div class= "overflow". But max-height should be at least in 'px', not in '%'.
Also max-height should be different for different resolutions. I set some breakpoints for max-height using media queries. Something like this:
#media(min-height:520px) {
max-height: 170px;
}
#media(min-height:600px) {
max-height: 250px;
}
#media(min-height:768px) {
max-height: 400px;
}
#media(min-height:900px) {
max-height: 500px;
}
.....
It allows me having panel's height shorter than browser view's height in any resolutions and having or not having scroll inside panel (depends on quantity of items)
The same approach is applied to filter title + text-overflow
Here is video - http://take.ms/WBDcy
and here is code - http://plnkr.co/edit/SbMa9Ece2eOPJ2C0Lt5U?p=preview
When I was writing this post I've understood that using of max-height: 80vh maybe was even better than media queries. It should be tested.
I'm using the following mark up and styles (Bootstrap). It shows my checkbox but it is paralysed, that is, it cannot be checked. here is my mark up:
I want something more Bootstrap-ish. I know there are other options to make the checkbox look fancy but that do not solve the problem.
<div class="form-group">
<div class="checkbox">
1.
<input type="checkbox" name="options" id="chk2" />
<label class="checkbox-label">Option 2</label>
</div>
</div>
Here is how it looks.
What exactly is the issue?
If I put the input element inside label I get this ugly thing:
<input type="checkbox" name="options" id="chk2" />
<label class="checkbox-label">Option 2</label>
The problem is with your label. The for attribute must match with the name attribute of your label
Looks need to tweak bootstrap styling for custom checkbox.
Check this
HTML
<div class="form-group">
<div class="checkbox">
<label for="check">
<input type="checkbox" id="check"/>
<span class="fake-input"></span>
<span class="fake-label">Option 2</span>
</label>
</div>
</div
CSS
.fake-input {
float: left;
width: 20px;
height: 20px;
border: 1px solid #9f9f9f;
background: #fff;
vertical-align: middle;
position: relative;
margin-right: 10px;
border-radius: 4px;
}
input[type="checkbox"] {
position: fixed;
top: -9999px;
left: -9999px;
}
input[type="checkbox"]:checked + .fake-input:before {
content:"\2713";
position: absolute;
color: #000;
text-align: center;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
Check in Fiddle
Reading around it looks like you have to style the checked version and the unchecked version.
input[type=checkbox]:checked {
}
Styling with this tag should solve your problems.
Use "for" attribute to solve this issue.
<div class="form-group">
<div class="checkbox">
1.
<input type="checkbox" name="options" id="chk2" />
<label for="chk2" class="checkbox-label">Option 2</label>
</div>
</div>
<div class="col-md-3">
<input class="form-check-input" type="checkbox" id="" asp-for="">
<label class="form-check-label" for="" asp-for="">
</label>
</div>
It's not due to Bootstrap but to Wordpress. The checkboxes became visible after I added "display:block;" to the css of the checkbox input tag.
<input class="form-check-input" type="checkbox" id="">
input.form-check-input {
display:block;
}
I am trying to get my checkboxes and labels aligned (into two a column), but it isn't working. Any idea what I can do to get it fixed?
Jsfiddle here: http://jsfiddle.net/wfju61oq/1/
.option label {
display: block;
padding-left: 15px;
text-indent: -15px;
}
.option input {
width: 13px;
height: 13px;
padding: 0;
margin:0;
vertical-align: bottom;
position: relative;
top: -1px;
*overflow: hidden;
}
Try this:
.option label {
display: block;
width: 220px;
}
.option input {
float:right;
}
Working fiddle here.
label {
display: block;
width: 300px;
text-align: right;
margin-right: 10px;
}
Here is a working JSFiddle:
http://jsfiddle.net/wfju61oq/8/
Warning: you have a &character in one of your id: this is incorrect.
demo - http://jsfiddle.net/victor_007/wfju61oq/10/
remove margin:0 for label and position:relative; top:-1px;
added border for better view of vertical alignment
.option label {
display: block;
padding-left: 15px;
text-indent: -15px;
width: 150px;
border: 1px solid red;
}
.option input {
width: 13px;
height: 13px;
vertical-align: bottom;
*overflow: hidden;
float: right;
}
<div class="option">
<fieldset>
<legend>Which Service Do You Require?</legend>
<label for="Hostess">Hostess
<input type="checkbox" id="Hostess" value="Hostess" />
</label>
<label for="usher">Usher
<input type="checkbox" id="usher" value="usher" />
</label>
<label for="welcomeguests">Welcome Guests
<input type="checkbox" id="welcomeguests" value="welcomeguests" />
</label>
<label for="guestlists">Guest Lists
<input type="checkbox" id="guestlists" value="guestlists" />
</label>
<label for="seatguests">Seat Guests
<input type="checkbox" id="seatguests" value="seatguests" />
</label>
<label for="servebuffmeal">Serve Buffet Meal
<input type="checkbox" id="servebuffmeal" value="servebuffmeal" />
</label>
<label for="servesitmeal">Serve Sit-Down Meal
<input type="checkbox" id="servesitmeal" value="servesitmeal" />
</label>
<label for="clearplates">Clear Plates
<input type="checkbox" id="clearplates" value="clearplates" />
</label>
<label for="cleartables">Clear Tables
<input type="checkbox" id="cleartables" value="cleartables" />
</label>
<label for="returnhplates">Return Hired Plates
<input type="checkbox" id="returnhplates" value="returnhplates" />
</label>
<label for="refilljuggs">Refill Jugs
<input type="checkbox" id="refilljugs" value="refilljuggs" />
</label>
<label for="">Serve V.I.P Guests
<input type="checkbox" id="servevipguests" value="servevipguests" />
</label>
<label for="">Cross-Check Invite List
<input type="checkbox" id="crosscheckivlist" value="crosscheckivlist" />
</label>
<label for="">Meet & Greet Guests
<input type="checkbox" id="Meet&GreetGuests" value="Meet&GreetGuests" />
</label>
<div style="clear: both"></div>
<label>Other
<input id="other" name="other" type="text" placeholder="Other" />
</label>
</fieldset>
</div>