Radio buttons display incorrectly on iPad - html

A couple of radio buttons display all messed up on iPad (Safari) running latest IOS 8....
This is how the buttons look in all other browsers (PCs and Android phones):
http://dotwdesign.com/right/right.png
This is how it displays on the iPad (see buttons on the left, misplaced and squared):
http://dotwdesign.com/wrong/wrong.jpg
Here is my HTML (the two containing divs are because I have some additional unrelated code embedded [hidden here] - pls don't pay attention to that:))
<div id= "contactform">
<div id="theform">
<form method="post" action="php/webmailer.php" name="form" id="message_form">
<ol>
<li>
<label for="full_name">First Name</label>
<input type="text" name="fname" />
</li>
<li>
<label for="lname">Last Name</label>
<input type="text" name="lname" />
</li>
<li>
<label for="email">Email</label>
<input type="text" name="email" />
</li>
<li>
<label for="phone">Phone</label>
<input type="text" name="phone" />
</li>
<li>
<label for="method">Preferred contact method</label>
<label for="Email">
<input type="radio" name="method" value="Email" checked />
Email</label>
<label for="Phone">
<input type="radio" name="method" value="Phone" />
Phone</label><br>
</li>
<li>
<label for="comments">Your Message</label>
<textarea name="message"></textarea>
</li>
<input type="submit" name="submit" value="Submit" />
</form>
</ol>
</div><!--end of theform div-->
</div><!--end of contactform div-->
And this is my CSS...
#contactform {
position: relative;
float: left;
margin: 50px 0 50px 80px;
width: auto;
}
#contactform ol li {
list-style-type:none;
}
#contactform input{
display:block;
width:300px;
margin-left: 0;
border:1px #000 solid;
border-radius: 3px;
padding: 5px;
}
#contactform textarea{
height:150px;
display:block;
width:300px;
margin-top: 3px;
border:1px #000 solid;
border-radius: 3px;
padding: 5px;
}
#contactform input:hover, textarea:hover {
background-color:#E0E0E0;
}
#contactform input:focus, textarea:focus{
background-color:#E0E0E0;
}
#contactform label{
display:block;
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
margin-top:10px;
font-size: 14px;
font-style: italic;
font-weight: bold;
width: 330px;
}
#contactform input[type="radio"]{
display: inline-block !important;
margin-top: 5px !important;
margin-left: -90px !important;
margin-right: -80px !important;
width: 200px !important;
}
#contactform input[type="submit"] {
margin: 30px 0 0 120px;
width: 70px;
font-size: 15.5px;
}
#contactform input[type="submit"]:hover{
cursor: pointer;
cursor: hand;
}
#theform{
float: left;
border-radius: 6px;
background-color: #558ED5;
padding: 25px 0;
width:400px;
box-shadow: 10px 10px 3px rgba(12, 3, 25, 0.8);
}
After some online research I came across of a -webkit-appearance option that allows you to retain your native UI settings on Safari but it did not work (I tried options such as .... -webkit-appearance: default-button or -webkit-appearance: radio). ALSO tried adding onclick="" to my HTML labels and inputs as per another thread on this site. Still no luck.
It would be highly appreciated if someone can provide some guidance on how to fix this issue. Some other threads on this site address this issue but under a scripting approach (as opposed to a CSS one)

The positioning first gets changed because of the width: 300px; you have for all inputs. So instead of adding a new magic number for the radio buttons you can set it back to auto. Also the style for the radio buttons is more specific than the general input one so you don't need the !important. So this should work:
#contactform input[type="radio"] {
display: inline-block;
margin-top: 5px;
width: auto;
}
And if you want some more space between radio buttons and text again you can of course add it back with something like this: margin-right: 10px;

Related

Why does the writable part of the form start from the middle?

Basically I tried to make a form for the first time, but I can't manage to understand why the writable area doesn't start from the beginning. I think it might have something to do with the padding, but I'm not sure. I know that the answer will probably be obvious, but I'm pretty new to this enviroment and to be honest I can't figure it out. Obviously there isn't all of the code of the website, I just posted the interested part.Thank you in advance.
label{
font-size: 30px;
font-family: 'Raleway', sans-serif;
margin-left: -390px;
margin-right: 100px;
display: block;
margin-top: 70px;
}
input[type=text],
input[type=email],
textarea{
padding: 12px 200px;
box-sizing: border-box;
background-color: #222326;
border: none;
border-bottom: 1px solid #D9D9D9;
text-align: left;
}
.msg-label{
margin-left: -345px;
}
.email-label{
margin-left: -398px;
}
textarea{
margin-bottom: 100px;
padding-right: 300px 220px;
overflow:hidden;
margin-right: -50px;
}
<div id="contact-me">
<div id="center">
<h2>CONTACT ME</h2>
</div>
<div id="center">
<form action="action-page.php">
<label for="name" class="name-label">Name</label>
<input type="text" id="name" name="full-name" >
<label for="email" class="email-label">Email</label>
<input type="email" id="email" name="email">
<label for="message" class="msg-label">Message</label>
<textarea id="msg" name="message"></textarea>
<input type="submit" value="Submit">
</form>
</div>
</div>
input[type=text],
input[type=email],
textarea{
padding: 12px 200px;
box-sizing: border-box;
background-color: #222326;
border: none;
border-bottom: 1px solid #D9D9D9;
text-align: left;
}
its the padding that you have added in the snippet above. padding adds space within the element as such you are pushing everything inside.

Unwanted white space in html to the right of search bar

I am trying to make a search bar, with an anchor containing an icon. I'm trying to directly connect the two (button fixed to the right of searchbar) but there is white space not wanting to leave.
.search input [type="search"] {
margin-right: 0;
white-space: nowrap;
}
.search a {
padding: 5px;
border-top-right-radius: 7px;
border-bottom-right-radius: 7px;
margin-left: 0;
}
.search i {
padding: 5px;
}
<div class="search">
<form action="" method="post">
<b>Search by</b>
<input type="checkbox" value="">Male</input>
<input type="checkbox" value="">Female</input>
<input type="search" placeholder="Searchtext">
<i>placeholder</i>
</form>
</div>
The duplicate does apply to your question as inputs are inline-block.
One thing to consider is that your "search" and "button" could be considered a single element. You could group them as such and then apply a float to the elements.
.searchBox {
/*Floats will be relative to this*/
position: relative;
display: inline-block;
}
.searchBox input {
/*Float the input*/
float: left;
}
.search input[type="search"] {
margin-right: 0;
white-space: nowrap;
}
.search a {
padding: 5px;
border-top-right-radius: 7px;
border-bottom-right-radius: 7px;
margin-left: 0;
/*Purely to demonstrate*/
border: solid 1px black;
}
.search i {
padding: 5px;
}
<div class="search">
<form action="" method="post">
<b>Search by</b>
<input type="checkbox" value="" />Male
<input type="checkbox" value="" />Female
<div class="searchBox">
<input type="search" placeholder="Searchtext">
<i>placeholder</i>
</div>
</form>
</div>
You also have a couple of other issues with your code:
input is self closing and shouldn't have a closing tag, note Permitted Content in the docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
You have an unwanted space between input and [type="search"]. This would attempt to match an element with an attribute of search that is a descendant of an input element.
I have addressed these in my code.
I think below code might serve your purpose.
.blockTitle{
padding-right:1em;
font-weight:bold;
}
.search{
display:block;
width:auto;
}
.search form{
display:block;
width:100%;
margin:0;
padding:0;
}
.checkbox + label{
display:inline-block;
padding:0 0.25em;
line-height:1.4em;
}
.searchBoxContainer{
display:block;
width:80%;
position:relative;
padding:0.2em;
}
.searchBoxContainer input[type="search"]{
width:100%;
display:block;
position:relative;
z-index:0;
padding:0 2.5em 0 0;
line-height:inherit;
margin:0;
}
.searchCustomBtn{
position:absolute;
top:0.75em;
right:-2em;
z-index:1;
line-height: 1.5em;
}
<div class="search">
<form action="" method="post">
<span class="blockTitle">Search by</span>
<input type="checkbox" value="" class="checkbox" id="maleChkBx" /><label for="maleChkBx">Male</label>
<input type="checkbox" value="" class="checkbox" id="femaleChkBx" /><label for="femaleChkBx">Female</label>
<div class="searchBoxContainer">
<input type="search" id="searchBox" placeholder="Searchtext">
Search-Icon
</div>
</form>
</div>

Align Class containing a class

image 1
I want to set the class first to the right of the class second containing form . I want to keep the class first inside the form that is below Please share your experience. I can do that be using margin left and margin right. How to achieve this using floats or any other way.
body, select, input, textarea, button, h1, h2, h3, h4, h5, h6 {
font-family: Hind;
line-height: 1.2;
}
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="tel"], input[type="date"], textarea {
margin-left: 0px;
}
input:focus {
outline: none !important;
border:1px solid green;
box-shadow: 0 0 10px #719ECE;
}
textarea:focus {
outline: none !important;
border:1px solid red;
box-shadow: 0 0 10px #719ECE;
}
#exitpopup-modal .modal-body {
padding:0px;
}
.modal-body {
padding: 0px;
}
.first
{
margin-left:12%;}
.second img {
width: 369px;
height: 404.6px;
margin-top: -1%;
}
.second form{
display:table;
margin-left: 37px;
margin-top: 29px;
}
.row1{
font-size: 10px;
font-family: inherit;
display: table-row;
border: 2px solid red;
}
.row1 #name,#mail,#contact{
color:black;
width: 260px;
height: 34px;
padding: 6px 12px;
border-radius:3.9px;
border-color: #777;
display:table-cell;
}
.row1 textarea{
width: 260px;
height: 110px;
color:black;
border-color: #777;
display:table-cell;
}
.row1 #submit{
width:152px;
height: 44px;
margin-left:15%;
background-color:#337ab7;
color:white;
border-color:none;
}
.row1 #submit:hover{
width:152px;
height: 44px;
margin-left:15%;
background-color:white;
color:#337ab7;
border-color:none;
}
.second,.first{
float: left;
}
.clearfix{
clear:both
}
.titan{
text-align:center;
font-family: inherit;
font-size: 20px;
padding-top: 38px;
}
<div class="second">
<form id="form" name="theform" action="javascript:myformsubmit()">
<div class="row1">
<input id="name" type="text" placeholder="Your name *" required><br><br>
</div>
<div class="row1">
<input type="email" id="mail" placeholder="Your email *" required><br><br>
</div>
<div class="row1">
<input id="contact" type="number" placeholder="Your phonenumber*" required><br><br>
</div>
<div class="row1">
<textarea id="reason" rows="5" placeholder="Any reason to leave ?*" required></textarea><br><br>
</div>
<div class="first">
<input type="radio" name="experience" value="I am happy and purchased/will purchase" checked> I am happy and purchased/will purchase<br>
<input type="radio" name="experience" value="You are not selling in my city"> You are not selling in my city<br>
<input type="radio" name="experience" value="You do not have the product i am looking for"> You do not have the product i am looking for<br>
<input type="radio" name="experience" value="I find your prices higher than market"> I find your prices higher than market<br>
</div>
<div class="row1">
<input id="submit" type="submit" value="Submit" >
</div>
</form>
</div>
<div class="titan">Please share your experience </div>
<div class="clearfix"></div>
Updated jsfiddle. When you are in small screens you should use #media queries to change your input width and it will work even in mobile screen.
#form , .first{
display:inline-block;
}
.first{
float:right;
margin:25px;
}

Align labels to left on form using CSS

I have a login form with labels and input, i can not get the labels to go on the left and input on the right. Currently they are sitting on top of each other.
Here is the HTML:
<div class="login">
<form name="login" action="submit" method="get" accept- charset="utf-8">
<label for="usermail">Username</label>
<input type="email" name="usermail" placeholder="yourname#email.com" required>
<label for="password">Password</label>
<input type="password" name="password" placeholder="password" required>
<input type="submit" value="Login">
</form>
</div>
Here is the CSS:
form {
margin:auto;
position:relative;
width:375px;
height:250px;
font-family: Lucida Sans, Geneva, sans-serif;
font-size: 14px;
font-style: italic;
line-height: 24px;
font-weight: bold;
text-decoration: none;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding:10px;
border: 1px solid #999;
border: inset 1px solid #333;
}
input { float:right;
width:350px;
display:block;
border: 1px solid #999;
height: 25px;
}
Here is the JSFiddle https://jsfiddle.net/ojz87d0x/
On input, change display:block; to display:inline-block;, and add the following:
label {
display: inline-block;
float:left;
clear:both;
}
input[type="submit"] {
clear: both;
}
You'll also need to make sure that the width of the input and the width of the form are different enough to allow space for the label. In this example [in the fiddle]. I set input to 275px and form to 375px.
Here's a newer update to your fiddle.
First of all, the inputs are too wide for both the labels and inputs to be next to each other inside the form. So either widen the form or shorten the inputs.
Next, add float: left to the labels.
form {
margin: auto;
position: relative;
width: 375px;
height: 250px;
font-family: Lucida Sans, Geneva, sans-serif;
font-size: 14px;
font-style: italic;
line-height: 24px;
font-weight: bold;
text-decoration: none;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding: 10px;
border: 1px solid #999;
border: inset 1px solid #333;
}
input {
float: right;
width: 300px; /*smaller width*/
display: block;
border: 1px solid #999;
height: 25px;
}
label {
float: left;
margin-top: 3px;
<div class="login">
<form name="login" action="submit" method="get" accept- charset="utf-8">
<label for="usermail">Username</label>
<input type="email" name="usermail" placeholder="yourname#email.com" required>
<label for="password">Password</label>
<input type="password" name="password" placeholder="password" required>
<input type="submit" value="Login">
</form>
</div>

Align checkbox and label

I have a form which code looks like this:
<div id="right_sidebar">
<form id="your_name" name="your_name" action="#" method="post" style="display: block; ">
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" id="name" value="">
<label for="lastname">Last Name</label>
<input type="text" name="lastname" id="lastname">
<label for="msg">Comment <span class="sp"></span></label>
<textarea name="msg" id="msg" rows="7"></textarea>
<input type="checkbox" name="agree">
<label for="agree">Accept the terms</label>
<button class="blue_button" type="submit">Send</button>
</fieldset>
</form>
</div>​
And which is styled with the following CSS:
body {
color: #333;
font: 12px Arial,Helvetica Neue,Helvetica,sans-serif;
}
#right_sidebar {
padding-top: 12px;
width: 190px;
position:relative;
}
form {
background: #EEF4F7;
border: solid red;
border-width: 1px 0;
display: block;
margin-top: 10px;
padding: 10px;
}
form label {
color: #435E66;
display:block;
font-size: 12px;
}
form textarea {
border: 1px solid #ABBBBE;
margin-bottom: 10px;
padding: 4px 3px;
width: 160px;
-moz-border-radius: 3px;
border-radius: 3px;
}
form label a {
display: block;
padding-left: 10px;
position: relative;
text-decoration: underline;
}
form label a .sp {
background: #EEF4F7;
height: 0;
left: 0;
position: absolute;
top: 2px;
width: 0;
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 4px solid #333;
}
form button.blue_button {
margin-top: 10px;
vertical-align: top;
}
button.blue_button{
color: white;
font-size: 12px;
height: 22px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
button.blue_button {
background-color: #76C8C6;
border: 1px solid #7798B7;
text-shadow: 1px 1px 0px #567C9E;
}
​As you can see the checkbox is on top of the label. I would like both to be "on the same line". So, it would look like "[ ] Accept the terms". And how would I make that the text is vertically aligned to the checkbox.
How could I do both?
You can see it live here: form, checkbox failing
One option is to amend the style of the label element that follows the checkbox:
​input[type=checkbox] + label {
display: inline-block;
margin-left: 0.5em;
margin-right: 2em;
line-height: 1em;
}
JS Fiddle demo.
This is, however, somewhat fragile as the margins are a little arbitrary (and the margin-right is purely to force the following button to the next line). Also the attribute-equals selector may cause problems in older browsers.
As implied, in comments, by Mr. Alien it is actually easier to target the checkbox itself with this selector-notation:
input[type=checkbox] {
float: left;
margin-right: 0.4em;
}
JS Fiddle demo.
It is because the label has display: block on it. It means that (without a float or hack) it will claim it's own line.
Change it to display: inline-block or leave the display rule away and you're done.
Seeing you did this intentionally for the first two labels, you should give the accept the terms label an id and use form #accepttermslabel {display: inline-block}. This will override the other rules et because it is more specific.
Wrap your checkbox and text within the <label> tag. Works with your current CSS as seen here in this jsFiddle Demo.
<label for="checkbox">
​<input id="checkbox" type="checkbox"> My Label
</label>​​​​​​​​​​​​​​​​​​​​​​​​​​
Forked your fiddle here with one small change. I nested the checkbox inside the label.
<label for="agree"><input type="checkbox" name="agree">Accept the terms</label>
Hope it helps.
All you need to do is add display: inline to the label. Like this:
label[for="agree"] {
display: inline;
}
You may also have to add the following to get the Send button to stay on its own line:
button[type="submit"] {
display: block;
}
That is enough to make it work, but you could also nest the input inside the label, like this:
<label for="agree">
<input type="checkbox" name="agree" />
Accept the terms
</label>
However, most people avoid doing this because it is semantically constricting. I would go with the first method.
Set a class on the checkbox list as follows:
<asp:CheckBoxList ID="chkProject" runat="server" RepeatLayout="Table" RepeatColumns="3" CssClass="FilterCheck"></asp:CheckBoxList>
Then add the following CSS:
.FilterCheck td {
white-space:nowrap !important;
}
This ensures the label stays on the same line as the checkbox.
I had the same problem with bootstrap 3 horizontal-form, and finally found a try-error solution and works with plain html-css too.
Check my Js Fiddle Demo
.remember {
display: inline-block;
}
.remember input {
position: relative;
top: 2px;
}
<div>
<label class="remember" for="remember_check">
<input type="checkbox" id="remember_check" /> Remember me
</label>
</div>
Tried the flex attribute?
Here's your example with flex added:
HTML
<div id="right_sidebar">
<form id="send_friend" name="send_friend" action="#" method="post" style="display: block; ">
<fieldset>
<label for="from">From</label>
<input type="text" name="from" id="from" value="">
<label for="to">To</label>
<input type="text" name="to" id="to">
<label for="msg">Comment <span class="sp"></span>
</label>
<textarea name="msg" id="msg" rows="7"></textarea>
<div class="row">
<div class="cell" float="left">
<input type="checkbox" name="agree">
</div>
<div class="cell" float="right" text-align="left">
<label for="agree">Accept the terms</label>
</div>
</div>
<button class="blue_button" type="submit">Send</button>
</fieldset>
</form>
</div>
CSS
body {
color: #333;
font: 12px Arial, Helvetica Neue, Helvetica, sans-serif;
}
[class="row"] {
display: flex;
flex-flow: row wrap;
margin: 2 auto;
}
[class="cell"] {
padding: 0 2px;
}
#right_sidebar {
padding-top: 12px;
width: 190px;
position:relative;
}
form {
background: #EEF4F7;
border: solid red;
border-width: 1px 0;
display: block;
margin-top: 10px;
padding: 10px;
}
form label {
color: #435E66;
display:block;
font-size: 12px;
}
form textarea {
border: 1px solid #ABBBBE;
margin-bottom: 10px;
padding: 4px 3px;
width: 160px;
-moz-border-radius: 3px;
border-radius: 3px;
}
form label a {
display: block;
padding-left: 10px;
position: relative;
text-decoration: underline;
}
form label a .sp {
background: #EEF4F7;
height: 0;
left: 0;
position: absolute;
top: 2px;
width: 0;
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 4px solid #333;
}
form button.blue_button {
margin-top: 10px;
vertical-align: top;
}
button.blue_button {
color: white;
font-size: 12px;
height: 22px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
button.blue_button {
background-color: #76C8C6;
border: 1px solid #7798B7;
text-shadow: 1px 1px 0px #567C9E;
}
Flex allows for table style control with the use of divs for example.
The simplest way I found to have the checkbox and the label aligned is :
.aligned {
vertical-align: middle;
}
<div>
<label for="check">
<input class="aligned" type="checkbox" id="check" /> align me
</label>
</div>
<div>
<input class="aligned" type="checkbox" />
<label>align me too</label>
</div>
<div>
<input type="checkbox" />
<label>dont align me</label>
</div>
I know this post is old, but I'd like to help those who will see this in the future. The answer is pretty simple.
<input type="checkbox" name="accept_terms_and_conditions" value="true" />
<label id="margin-bottom:8px;vertical-align:middle;">I Agree</label>