Hint "required" is not shown - css

What piece of code "deleted" the hint about required field?
https://jsfiddle.net/venntr/qegxnjm2/
<div class="switch-field">
<input type="radio" id="onlinetak" name="online" required/>
<label for="onlinetak">Online</label>
<input type="radio" id="onlinenie" name="online" required />
<label for="onlinenie">Offline</label>
</div>

The first thing to fix is that it is not in a form tag, as was pointed out by Leon.
What's happening is that your CSS is styling your HTML labels, not your radio inputs, to be selected. You set the inputs to be display: none, so the associated errors with there being no input do not display. You need to show the inputs and edit the styling of the inputs themselves so that the error properly appears if there is no input.
EDIT: Here's an example of your code that will work with what I said.
body {
background-color: #F7FCFF;
}
.QA radio {
-webkit-appearance: none;
background-color: #e1e1e1;
border: 4px solid #e1e1e1;
border-radius: 10px;
width: 100%;
display: inline-block;
position: relative;
width: 20px;
height: 20px;
}
.QA radio:checked {
background: grey;
border: 4px solid #e1e1e1;
}
input[type=text], textarea {
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
-o-transition: all 0.30s ease-in-out;
outline: none;
padding: 3px 0px 3px 3px;
margin: 5px 1px 3px 0px;
border: 1px solid #DDDDDD;
}
input[type=text]:focus, textarea:focus {
box-shadow: 0 0 5px rgba(81, 203, 238, 1);
padding: 3px 0px 3px 3px;
margin: 5px 1px 3px 0px;
border: 1px solid rgba(81, 203, 238, 1);
}
.QA {
font: normal normal 14px/1 Helvetica;
margin: 1px;
border-radius:10px;
text-align:center;
}
.QA1 {
font: normal normal 14px/1 Helvetica;
border-radius:10px;
text-align:left;
}
.QA h2{
font: normal normal 16px/1 Helvetica;
font-weight: bold;
color:#004E97;
}
.QA button{
text-align:center;
width: auto;
background: #E2F4FE;
font-weight: bold;
font-size: 14px;
text-shadow: none;
color: rgba(0, 0, 0, 0.6);
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 5px;
cursor: pointer;
padding: 6px 14px;
margin: 2px;
outline: 0;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.QA1 button{
text-align:left;
width: auto;
background: #E2F4FE;
font-weight: bold;
font-size: 14px;
text-shadow: none;
color: rgba(0, 0, 0, 0.6);
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 5px;
cursor: pointer;
padding: 6px 14px;
margin: 2px;
outline: 0;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.QA button:hover{
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60; background: #C1EEFE;
}
.QA1 button:hover{
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60; background: #C1EEFE;
}
textarea {
background-color: #FFFFFF;
}
.index {
z-index: 55;
}
.switch-field {
font-family: Helvetica;
padding: 10px;
overflow: hidden;
font-size:0px;
}
.switch-title {
margin-bottom: 6px;
}
.switch-field .input-field {
text-align:center;
display: inline;
width: auto;
background-color: #F2F0F0;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
font-weight: bold;
text-shadow: none;
padding: 6px 14px;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.switch-field label:hover {
cursor: pointer;
}
.switch-field input:checked + label {
background-color: #5EA8EE;
-webkit-box-shadow: none;
box-shadow: none;
}
.switch-field .input-field:first-of-type {
border-radius: 4px 0 0 4px;
}
.switch-field .input-field:last-of-type {
border-radius: 0 4px 4px 0;
}
#onlinetak:checked + label:first-of-type { background-color:#5EA8EE; }
#onlinenie:checked + label:last-of-type { background-color:#EE5B5B; }
<form>
<div class="switch-field">
<div class="input-field">
<input type="radio" id="onlinetak" name="online" required/>
<label for="onlinetak">Online</label>
</div>
<div class="input-field">
<input type="radio" id="onlinenie" name="online" required/>
<label for="onlinenie">Offline</label>
</div>
</div>
<button type="submit">Submit</button>
</form>
EDIT 2: Another (admittedly hacky) way of doing it is to set a negative z-index on the inputs themselves so that they don't appear to be inside the labels themselves. The error still shows near the input group, but the inputs are "under" the labels (and not set to display: none), so the error displays where the inputs are.
.switch-field input {
position: absolute;
z-index: -10000;
}

Your code may need to be in a form in order for your required to work.
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="switch-field">
<form>
<input id="onlinetak" name="online" type="radio"> <label for="onlinetak">Online</label> <input id="onlinenie" name="online" type="radio"> <label for="onlinenie">Offline</label> <button type="submit">Submit</button>
</form>
</div>
</body>
</html>
Jsfiddle - https://jsfiddle.net/qegxnjm2/1/

enter code here
Online
Offline

Related

How to get absolute element appearing outside of container with overflow set?

I have a very small container which has a custom dropdown element inside of it.
#main {
height: 90px;
width: 400px;
overflow-y: auto;
}
.wrapper-dropdown {
text-transform: uppercase;
letter-spacing: .08em;
font-size: 12px;
position: relative;
width: 200px;
padding: 12px 15px;
background: #fff;
border-radius: 6px;
border: 1px solid #d9e2f6;
cursor: pointer;
outline: none;
-webkit-transition: all .3s ease-out;
-moz-transition: all .3s ease-out;
-o-transition: all .3s ease-out;
transition: all .3s ease-out;
}
.wrapper-dropdown .dropdown {
position: absolute;
top: 100%;
left: -1px;
right: -1px;
background: #fff;
border-radius: 0 0 5px 5px;
border: 1px solid #d9e2f6;
border-top: none;
border-bottom: none;
list-style: none;
padding: 0 5px;
-webkit-transition: all .3s ease-out;
-moz-transition: all .3s ease-out;
-o-transition: all .3s ease-out;
transition: all .3s ease-out;
max-height: 0;
overflow: hidden;
margin: 0;
z-index: 5;
}
.wrapper-dropdown .dropdown li {
padding: 0 10px;
width: 100%;
}
.wrapper-dropdown .dropdown li a {
display: block;
text-decoration: none;
color: #6a759e;
padding: 15px 0;
transition: all .3s ease-out;
border-bottom: 1px solid #d9e2f6;
margin-right: 20px;
}
.wrapper-dropdown.active .dropdown {
-webkit-box-shadow: 0 10px 20px 0 rgba(217, 226, 246, .8);
-moz-box-shadow: 0 10px 20px 0 rgba(217, 226, 246, .8);
box-shadow: 0 10px 20px 0 rgba(217, 226, 246, .8);
max-height: 400px;
}
<div id="main">
CLICK OPTION 1 TO SHOW LIST
<div class="wrapper-dropdown">
<span class="selectedtext">Option1</span>
<ul class="dropdown">
<li>Option1</li>
<li>Option2</li>
<li>Option3</li>
</ul>
</div>
</div>
I'm trying to get the absolute positioned element (which is the list of options) to appear outside of the bounds of the main container which has overflow-y set.
I understand why this happening this due to this answer.
But am simply asking if anyone has any insights/tips/suggestions on a way to get around this or if it's generally not possible without moving the dropdown items outside of the container with the overflow set.
My example is here

Password input field displays wrong on safari 9.1

Basic input fields of type Password display badly on safari 9.1
The problem is the 'Key' in safari. This is my html:
<div class="form-group">
<input type="password" class="form-control" placeholder="Wachtwoord *" name="password" required="">
</div>
<div class="form-group">
<input type="password" class="form-control" placeholder="Bevestig wachtwoord *" name="password_confirmation" required="">
</div>
Chrome:
Safari
Setting height:100%'; will fix the problem but this obviously changes the height of the field, which is not what i want.
Css:
input[type="text"], input[type="email"], input[type="password"] {
display: block;
width: 100%;
vertical-align: middle;
border: 1px solid #cbcbcb;
outline: 0;
box-shadow: none;
padding: 12px;
-webkit-transition: all .35s;
-moz-transition: all .35s;
-ms-transition: all .35s;
-o-transition: all .35s;
transition: all .35s;
}
.form-control {
border: 1px solid #cbcbcb;
border-radius: 0;
}
.form-control {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}
Removing the padding from the input object was the solution.
input[type="password"] {
padding: 12px;
}
I had exactly the same problem and searched high and low for a solution which in the end turned out to be as easy as: line-height: normal;
This seems to work across browsers for me .. hope you get the same result!

Top part of box shadow clipped in IE only

On my site I have links with a box shadow that appears when hovering. You can see it on http://www.lorteau.fr . That works just fine on Chrome, Opera and Firefox. IE however clips the top of it.
Chrome, Opera, Firefox:
IE:
HTML defining the links and all the containers around it:
<body>
<div class="main m-scene" id="page">
<div id="menu">
<a class="menu_link" id="wphone_link" href="wphone.html">Windows Phone</a>
<a class="menu_link" id="wmetro_link" href="wmetro.html">Windows Metro</a>
<a class="menu_link" id="wdesktop_link" href="wdesktop.html">Windows Desktop</a>
<a class="menu_link" id="linux_link" href="linux.html">Linux</a>
<a class="menu_link" id="other_link" href="other.html">Other</a>
</div>
</div>
</body>
CSS3 defining the hovering effect and the containers around it:
.html
{
background-color: #464646;
}
body
{
margin: 0;
}
#page
{
width: 900px;
min-width: 800px;
min-height: 100%;
-pie-box-shadow: 0px 0px 3px 1px #FFFFFF;
-moz-box-shadow: 0px 0px 3px 1px rgba(255, 255, 255, 0.5);
-webkit-box-shadow: 0px 0px 3px 1px rgba(255, 255, 255, 0.5);
box-shadow: 0px 0px 3px 1px rgba(255, 255, 255, 0.5);
background-image: none;
border-width: 1px;
border-style: solid;
border-color: #000000;
background-color: #3C3C3C;
margin-left: auto;
margin-right: auto;
margin-top: 0px;
margin-bottom: 0px;
padding: 7px 5px 6px 32px;
}
#menu
{
height: 57px;
display: block;
width: 85%;
margin-left: auto;
margin-right: auto;
margin-top: 5px;
text-align: center;
}
.menu_link, .menu_link:hover
{
font-family: 'Electrolize', Arial, sans-serif;
font-size: 18px;
text-align: left;
color: white;
display: inline;
text-decoration: none;
border-style: solid;
border-width: 1px;
border-color: #777777;
border-radius: 5px;
background-color: #777777;
padding: 5px;
margin-right: 5px;
-webkit-transition: 250ms linear 0s;
-moz-transition: 250ms linear 0s;
-o-transition: 250ms linear 0s;
transition: 250ms linear 0s;
}
.menu_link:hover
{
color: #FFBE5B;
box-shadow: 0px 0px 5px 5px rgba(255, 190, 91, 0.5);
}
.menu_link:active
{
color: #FFBE5B;
}
.m-scene .scene_element
{
animation-duration: 0.25s;
-webkit-animation-duration: 0.25s;
animation-fill-mode: both;
-webkit-animation-fill-mode: both;
transition-timing-function: ease-out;
}
I tried all the padding, margin and height combinations I could think of but that didn't change anything. Would some have an idea as to what I could modify so that the shadow isn't clipped on any browser?
Pff never mind. Removed "margin-top: 5px;" from #menu and added "padding-top: 15px;" and that did it.
Spelling out the question clearly always helps!

How set the style of the content to default

I am using Zurb foundation 3 custom for layout(Grid) and style. Based on the user who is logged in, I need to remove the Zurb styling for some content. But I would like to still keep using the zurb layout.
How can I reset all properties of an element to default value.
Only for the main content of the page I want to set it to default, other part should still use zurb styling.
CSS:
input[type="text"], input[type="password"], input[type="date"], input[type="datetime"], input[type="email"], input[type="number"], input[type="search"], input[type="tel"], input[type="time"], input[type="url"], textarea {
background-color: #eeeeee;
font-family: inherit;
border: 1px solid #cccccc;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
-ms-border-radius: 2px;
-o-border-radius: 2px;
border-radius: 2px;
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
-moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
color: rgba(0, 0, 0, 0.75);
display: block;
font-size: 14px;
margin: 0 0 12px 0;
padding: 6px;
height: 32px;
width: 100%;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
}
input[type="text"].oversize, input[type="password"].oversize, input[type="date"].oversize, input[type="datetime"].oversize, input[type="email"].oversize, input[type="number"].oversize, input[type="search"].oversize, input[type="tel"].oversize, input[type="time"].oversize, input[type="url"].oversize, textarea.oversize {
font-size: 17px;
padding: 4px 6px;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="date"]:focus, input[type="datetime"]:focus, input[type="email"]:focus, input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="time"]:focus, input[type="url"]:focus, textarea:focus {
background: #fafafa;
outline: none !important;
border-color: #b3b3b3;
}
input[type="text"][disabled], input[type="password"][disabled], input[type="date"][disabled], input[type="datetime"][disabled], input[type="email"][disabled], input[type="number"][disabled], input[type="search"][disabled], input[type="tel"][disabled], input[type="time"][disabled], input[type="url"][disabled], textarea[disabled] {
background-color: #ddd;
}
HTML:
<div class="row">
<div class="four columns">
<label for="txtName">* First Name:</label>
</div>
<div class="fourteen columns ">
<input name="ctl00$ContentPlaceHolder1$txtName" type="text" maxlength="25" id="ContentPlaceHolder1_txtName" class="eight" />
</div>
</div>
I have to do this for all controls not just input.
Rendered HTML(View source):

CSS element pushes content down

I have 3 elements on my site that starts with an icon, which I have animated with CSS on hover. But when I hover, the whole section is pushed down. I do only wish to affect the icon. This is probably a positioning thing, but I have tried several things that I know of, but nothing seem to work the way I wish. The site is build with Bootstrap by the way, but that is probably not part of my problem.
The site can be seen here: http://www.vielendank.dk/bootstrap
(halfway down - the blue section)
The html look like this:
<div class="span4 text-center">
<div class="komp"><div class="komp-ikon">
<i class="icon-pencil"></i></div>
<h4>Grafisk design</br>og rentegning</h4></br>
Vi elsker design! Grafisk design og rentegning er vielen danks absolutte
spidskompetence – vi vil gå så vidt som at kalde os selv for nørder.
</div></div>
The CSS look like this:
.komp{
display: block;
}
.komp-ikon{
font-size: 40px;
color:#007fa7;
padding-top: 20px;
background-color: white;
width: 80px;
height: 60px;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
-moz-border-radius: 6%;-khtml-border-radius: 6%;-webkit-border-radius: 6%;border-radius: 6%;
-moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-moz-transition: all 0.2s ease-in;
-webkit-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
-ms-transition: all 0.2s ease-in;}
.komp:hover .komp-ikon{
color: #41ab29;
font-size: 60px;
padding-top: 20px;
background-color: white;
width: 100px;
height: 80px;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
-moz-border-radius: 4%;-khtml-border-radius: 4%;-webkit-border-radius: 4%;border-radius: 4%;
-moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);}
.komp:hover h4{
color:#41ab29;
font-family: 'Montserrat Alternates', sans-serif;
font-weight: 400;
margin-bottom: 0px;
padding-bottom: 0px;}
Thanks guys...
Simply give that div a fixed height:
.section.blue {
height: 350px;
}
Or if you want the selector to be more specific:
.section.blue .container .row {
height: 270px;
}
Try this:
CSS
.komp {
display: block;
padding: 100px 0 0;
}
.komp-ikon {
font-size: 40px;
color:#007fa7;
padding-top: 20px;
background-color: white;
width: 80px;
height: 60px;
margin: 0 0 0 -40px;
-moz-border-radius: 6%;
-khtml-border-radius: 6%;
-webkit-border-radius: 6%;
border-radius: 6%;
position: absolute;
top: 20px;
left: 50%;
-moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-moz-transition: all 0.2s ease-in;
-webkit-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
-ms-transition: all 0.2s ease-in;
}
.komp:hover .komp-ikon {
color: #41ab29;
font-size: 60px;
padding-top: 20px;
background-color: white;
width: 100px;
height: 80px;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
-moz-border-radius: 4%;-khtml-border-radius: 4%;-webkit-border-radius: 4%;border-radius: 4%;
-moz-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);}
.komp:hover h4{
color:#41ab29;
font-family: 'Montserrat Alternates', sans-serif;
font-weight: 400;
margin-bottom: 0px;
padding-bottom: 0px;
}
HTML
<div class="span4 text-center">
<div class="komp">
<div class="komp-ikon">
<i class="icon-pencil"></i>
</div>
<h4>Grafisk design</br>og rentegning</h4></br>
Vi elsker design! Grafisk design og rentegning er vielen danks absolutte
spidskompetence – vi vil gå så vidt som at kalde os selv for nørder.
</div>
</div>
I positioned it absolutely and then padded the content container so that it wont fall behind the button.
Not sure where you are going to use this, but it might be worth checking into creating a holding container for the button only, to make it more flexible :)
I solved the problem
I addede a
.komp{postition: absolute;}
For some reason you need this to position elements within this element. The only thing now is centering af the icons which does not work with margin-left/right: auto, but I will figure that one out hopefully.
Thanks for the advice...

Resources