I'm having a bit of a problem here. I read a ton of topics on this subject, but in won't work for me...
I'm making a theme for wp atm but I'm stuck on CSS checkbox styling, This is my CSS:
input[type=checkbox] {
opacity: 0;
}
input[type=checkbox] + label
{
background-image: url('images/main-sprite.png') no-repeat 0 -311px;
height: 20px;
width: 20px;
display:inline-block;
padding: 0 0 0 0px;
}
input[type=checkbox]:checked + label
{
background-image: url('images/main-sprite.png') no-repeat 0 -357px;
height: 20px;
width: 20px;
width: 16px;
display:inline-block;
padding: 0 0 0 0px;
}
.lcheckbox {
position: relative;
top: 43px;
right: 200px;
}
And ofcourse my HTML:
<input class='lcheckbox' type="checkbox" /><label for="checkbox">Remember me</label>
So, is there anybody who can help me?
Thanks
Okay, I've got the first thing fixed, but now wheb I click nothing happens, and the label text is like:
Remember *Here's a enter, so we continue on the next line*
Me
<label for="checkbox"> works on an input that has the id checkbox.
Since your input doesn't have an id, it won't work.
Solution: give the input an id.
<input class='lcheckbox' type="checkbox" id="checkbox" />
^^^^^^^^^^^^^
(or any other id, as long as it matches the label's for attribute.)
Related
I was trying to perfect my form layouts.
For some reason the labels on my checkbox won't line each other on each checkboxes.
I am trying my best to make each checkbox label sit to its checkbox using the ff codes:
<div class="form-input-group">
<i class="fa fa-book"></i>
<div class="checkbox-style">
<input type="checkbox" value=""> Math
<input type="checkbox" value=""> Science
<input type="checkbox" value=""> English
</div>
</div>
Any idea what went wrong and how I can fix this issue?
You can check the actual site here: http://americanbitcoinacademy.com/test/student-registration.html via Chrome's inspector tools.
Update this css , this will fix your issue , style.css , line number 1163
.sign-up .signup-form .form-input-group input[type="checkbox"] {
height: 27px;
margin-top: 0;
position: relative;
top: 8px;
width: 20px;
}
In styles.css on like 1166 (for .sign-up .signup-form .form-input-group input[type="checkbox"]), change margin-top:15px; to margin:0;
Then in style.css on like 1168, for .checkbox-style add display: flex; align-items: center; height: 100%;
There are lots of ways to get what you want. My approach would be to use padding on the parent instead of margin on the child elements.
On line 1163, remove margin-top and add vertical-align and margin:
.sign-up .signup-form .form-input-group input[type="checkbox"] {
width: 20px;
height: 27px;
vertical-align: middle;
margin: 0;
}
then on line 1170 add padding to replace margin-top rule:
.checkbox-style {
font-size: 15px;
margin-left: 70px;
padding-top: 15px;
}
Those changes get you this:
I am using Custom Radio Button. Also added required attribute to it.
Required is working but ERROR not shown....
Form not get submitted without selecting radio....
But
"Please Select One of These Options"
error is not shown.
code is :
<form>
<div class="form-field-label">Change In Weight :</div>
<div class="form-field-input">
<input type="radio" name="change_in_weight" id="change_in_weight1" required value="Maintained" class='radiobutton'><label for="change_in_weight1" class='radiobutton-label'>Maintained</label><br>
<input type="radio" name="change_in_weight" id="change_in_weight2" value="Increasing abnormally since last one year" class='radiobutton'><label for="change_in_weight2" class='radiobutton-label'>Increasing abnormally since last one year</label><br>
<input type="radio" name="change_in_weight" id="change_in_weight3" value="Decreasing abnormally since last one year" class='radiobutton'><label for="change_in_weight3" class='radiobutton-label'>Decreasing abnormally since last one year</label><br>
</div>
<br>
<input type="submit" value="send">
</form>
CSS :
.radiobutton-label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 15px;
}
input[type="radio"] {
display:none;
margin: 10px;
}
.radiobutton-label:before {
content:"";
display: inline-block;
width: 24px;
height: 24px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
}
input[type=radio] + label:before {
background: url('http://drdilipgadgil.com/img/vlad.png') 2px 4px no-repeat;
}
input[type=radio]:checked + label:before {
background: url('http://drdilipgadgil.com/img/vlad.png') 2px -18px no-repeat;
}
:required:focus {
box-shadow: 0 0 6px rgba(255,0,0,1);
}
Here is JSFIDDLE
I know I'm late But since I had the same problem and I've looked it up and stumbeled on this thread, I would like to say that THERE IS A WAY.
1- don't hide your actual radio button (DON'T set display :hidden;
2- set it's opactity to 0 and position to absolute
----it worked fine for me
opacity: 0;
position: absolute;
Here is JSFIDDLE
In the case of custom radio buttons, you have to handle error cases separately. Error is not showing because radio buttons are hidden. If you give 'display:block' for radio buttons, you can see the error after submitting. So you can go for two solutions.
Keep default radio buttons
OR
Handle error case via JS, and show custom message.
Just try to make some function in javascript when the button is clicked and the radio button is empty (nothing selected) just display the error in any div or whatever you want. (for example just use alert to simply test it)
Currently I am using an image for checked and unchecked checkboxes the html and css is below.
<div class="text-field-box text-field-box-mobile radio-button-box small">
<asp:CheckBox ID="ChkOffer1" text=" " runat="server" class="checkbox checkbox-mobile radio" Visible="true" EnableViewState="true"></asp:CheckBox>
<% Response.Write(Session("Offer1"))%>
</div>
and css
input[type=checkbox] {
display:none;
}
input[type=checkbox] + label
{
background-image: url("checkbox-default.png");
background-repeat: no-repeat;
height: 25px;
width: 25px;
padding: 0 0 0 0px;
padding-left:30px;
}
input[type=checkbox]:checked + label
{
background-image: url("checkbox-checked.png");
background-repeat: no-repeat;
height: 25px;
width: 25px;
padding: 0 0 0 0px;
padding-left:30px;
}
What I would like to do is find a way I can uniquely identify each checkbox so that I can have two checkbox fields with two different images.
These are my failed attempts I tried adding a extra class called radio
like this. input.radio[type=checkbox]
I also tried adding the radio class to the label like this input[type=checkbox] + label.radio
And tried the same with the ID's and I failed each time. Does anyone have a solution to my issue?
Here is an example of what I meant:
(Oh and, forgive the images please :) )
#field1,#field2{
display:none;
}
#field1 + label {
padding:40px;
padding-left:100px;
background:url(http://www.clker.com/cliparts/M/F/B/9/z/O/nxt-checkbox-unchecked-md.png) no-repeat left center;
background-size: 80px 80px;
}
#field1:checked + label {
background:url(http://www.clker.com/cliparts/B/2/v/i/n/T/tick-check-box-md.png) no-repeat left center;
background-size: 80px 80px;
}
#field2 + label {
padding:40px;
padding-left:100px;
background:url(http://www.adventureswithwords.com/wp-content/uploads/2014/11/unhappy_face_sticker-p217427116611791537qjcl_400-390x390.jpg) no-repeat left center;
background-size: 80px 80px;
}
#field2:checked + label {
background:url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRXWLioYfp2eZyyJ2g2VQM2YJd_PwFxrB-DDbZx1WwM8wXo20STCcDung) no-repeat left center;
background-size: 80px 80px;
}
<input type="checkbox" id="field1"/>
<label for="field1">Label</label>
<input type="checkbox" id="field2"/>
<label for="field2">Label</label>
Here's what I currently have:
<input type="text" name="amount" style="height:40px;width:200px;font-size:23px;text-align:center;" value="${$amount}" />
This is the part I'm specifically talking about:
value="${$amount}"
By default that shows $10.00 which is what I want. However, I don't want users to be able to edit the $ symbol. It should always remain there AND I don't want the dollar symbol submitted with the form. It's simply there for appearance so that users know the currency.
You can put the dollar sign as a background image for the input and leave some padding-left so that the text doesn't go over the background image.
You could use a pseudo element.
DEMO
<label>Label</label>
<span><input type="text" placeholder="Placeholder"></span>
input {
padding: 10px;
padding-left: 15px;
margin-left: 10px;
}
span:before {
content: "$";
position: relative;
left:10px;
margin-right: -15px;
}
Requires a wrapper element around your input as you cant generate a pseudo element on an input
Your best option is to put the sign outside the input element.
Try this: http://jsfiddle.net/mgmBE/45/
HTML:
<div class="input-container">
<input type="text" value="amount" name="" />
<span class="unit">$</span>
</div>
CSS:
.input-container {
position: relative;
width: 100px;
}
.input-container input {
width: 100%;
}
.input-container .unit {
position: absolute;
top: 3px;
right: -3px;
background-color: grey;
color: #ffffff;
padding-left: 5px;
width:20px;
}
Pseudo Element is the best option as very easy to place.
<label>Input:</label><span><input type="text" placeholder="Placeholder"></span>
CSS
input {
padding: 10px;
margin-left:15px;
}
span:before {
content: "$";
margin-right:-15px;
position: relative;
left:10px;
}
I want to create an error box for a form like the one below.
I already themed the input box and am using jQuery validation to display errors. However I can't get that error box right. I think I'll need to put that together with three tags, but I don't know what tags to use (jQuery validation uses a label tag to display the error).
My current code for the error is:
<label for="email">
<span>Email:</span>
<input type="text" id="email" name="email" class="error">
<label for="email" class="error" style="">Az e-mail címet kötelező megadni</label>
</label>
I must make this IE7 compatible.
I made the following changes:
<div class="dataline">
<div class="label">Label:</div>
<div class="field"><input type="text" id="name" name="name" /></div>
<div class="arrow"></div>
<label class="error">Error text</label>
<div class="ender"></div>
</div>
I set the arrowhead as an image for the class arrow so now it looks perfect. Basicly I used 4 left floated block elements (label, input, arrowhead and bubble body). Now I only have two problems: the arrowhead is displayed even when there's no error. How can I hide it when the label is not after it? My other problem is that the container div is 800px wide and if the error text is long, it wraps around to the next line. How can I avoid it?
My css is:
div.dataline {
margin: 10px 0 0 0;
white-space: nowrap;
width: 3000px;
owerflow: visible;
height: 60px;
}
div.field {
float: left;
}
div.label {
float: left;
width: 120px;
margin: 20px 0 0 0;
}
div.arrow {
background-image: url('gfx/redarrow.png');
margin: 7px 0 0 10px;
background-repeat: no-repeat;
width: 20px;
height: 45px;
float: left;
}
div.ender {
background-image: url('gfx/bubbleend.png');
margin: 7px 0 0 0px;
background-repeat: no-repeat;
width: 3px;
height: 45px;
float: left;
}
label.error {
height: 27px;
background-image: url('gfx/bubblemiddle.png');
float: left;
padding: 9px;
margin: 7px 0 0 0;
}
the following fiddle is a good start for your implementation:
http://jsbin.com/aReQUgay/1/edit
#email.error
{
border-color: red;
}
#email.error + label
{
background-color: red;
}