I am trying to change the border and label color of the form input in materialize css. I followed the documentation but only the first instance of the .input-field div is being changed, the rest are still using the default style.
Codepen
HTML
<div class="input-field">
<input id="account_name" type="text" class="validate">
<label for="account_name">Account Name</label>
</div>
<div class="input-field">
<input id="email" type="email" class="validate">
<label for="email">Email</label>
</div>
<div class="input-field">
<input id="password" type="password" class="validate">
<label for="password">Password</label>
</div>
CSS
/* label color */
.input-field label {
color: #000;
}
/* label focus color */
.input-field input[type=text]:focus + label {
color: purple !important;
}
/* label underline focus color */
.input-field input[type=text]:focus {
border-bottom: 1px solid purple !important;
box-shadow: 0 1px 0 0 purple !important;
}
/* valid color */
.input-field input[type=text].valid {
border-bottom: 1px solid purple !important;
box-shadow: 0 1px 0 0 purple !important;
}
/* invalid color */
.input-field input[type=text].invalid {
border-bottom: 1px solid #000;
box-shadow: 0 1px 0 0 #000;
}
/* icon prefix focus color */
.input-field .prefix.active {
color: #000;
}
EDIT: typo on title
Your CSS is pseudo-selecting inputs with [type=text]. Don't you want to get the ones with type="email" and type="password" too?
Example: https://codepen.io/anon/pen/MOBWeR
HTML:
<input type="checkbox">
<input type="radio">
CSS:
input {
outline: 1px solid;
padding: 0;
margin: 0;
border: none;
}
I want to make layout of div inside which there are 3 captions fitting into same size!
I am using angular materialise - Normal html / css also works for me.
I have tried
<div>
<label> Label 1 </label>
<label> Label 2 </label>
<label> Label 3 </label>
</div>
I have attached an image of what I need.
Should I use same 3 divs inside? or span / labels?
Here is what u needed.
.tabs label {
padding: 10px 20px;
border-left: 1px solid #ccc;
border-right: 0;
float: left;
}
label.selected {
background: #ccc;
}
.tabs label:first-child {
border-left: 0;
}
.tabs {
margin: 10px;
display: inline-block;
border: 1px solid #ccc;
border-radius: 20px;
overflow:hidden;
}
<div class="tabs">
<label class="selected"> Label 1 </label>
<label> Label 2 </label>
<label> Label 3 </label>
</div>
I tried to make a custom radio button, but I can't understand why box-sizing doesn't work.
Chrome:
FireFox:
What am I missing?
HTML:
<input class="radio-btn" type="radio" name="a"/>
<input class="radio-btn" type="radio" name="a"/>
<input class="radio-btn" type="radio" name="a"/>
<input class="radio-btn" type="radio" name="a"/>
<input class="radio-btn" type="radio" name="a"/>
CSS:
.radio-btn {
appearance: none;
box-sizing: border-box;
width: 0;
height: 0;
border-radius: 50%;
border: 6px solid #fff;
box-shadow: 0 0 0 2px #000;
transition: .2s border-color;
cursor: pointer;
}
.radio-btn:checked {
width: 12px;
height: 12px;
border: 3px solid #000;
box-shadow: 0 0 1px 2px #000;
}
.radio-btn:hover {
box-shadow: 0 0 1px 2px #000;
}
.radio-btn:focus {
outline: 0;
}
http://jsfiddle.net/u86xboqd/
You set your width and height in your .radio-btn css to 0. If you set each to 12px (to match your other styles) I think it will look the way you want it to.
.radio-btn {
width: 12px;
height: 12px;
}
Hard to determine without seeing code (not everyone can access codepen) but it may be because you also need to set display on the element to a block calculable value (so it respects height/width), e.g:
input{
display:inline-block;
}
You may also wish to check the relevant compatability
What I need to do is to replace the look of the radio button with image. That can be easily achieved with jQuery, but it this case I need to do it with CSS only. Is there any way to do that? Here is my HTML:
<div class="radio-buttons">
<div class="holder">
<span></span>
<input type="radio" class="radio" id="cheetah" value="" />
</div>
<div class="holder">
<span></span>
<input type="radio" class="radio" id="horse" value="" />
</div>
<div class="holder">
<span></span>
<input type="radio" class="radio" id="lion" value="" />
</div>
</div>
I've tried to apply a style background-image: on the radio button, but of course it didn't work. Then I added the <span>'s and I am wonderig if I can set style to the buttons display: none , and somehow on input:checked to display the <span> which will be styled with background-image: ? Is this the right way or I am on completely wrong direction? And can it be achieved with CSS only at all ?
Edit: the radio buttons might be changed to checkboxes if needed.
As Dominik said that is almost the way to achieve this. May be his code is for a specific case, and I found something similar but much simple than that. I had to make list of photos, and on click of a photo, it must display the clicked photo, but larger and in section after the list. That's why it didn't work with me. But I will first explain everything and then I will paste my code.
The Dominic code will work only if the label is next to the radio-button. It didn't work for me because I have my <label>'s separated from the radio-buttons. Labels are in <ul> and the radio-buttons are in <div> after the <ul>. That way it doesn't work and that's why I needed to add another same <label> next to each radio-button. Now I had two labels for 1 radio button. So here is my entire code. I had styled the ul labels inline just to save some space in the css. I made it with bg-color so if someone want to try ... it works fine with bg-image too
HTML:
<div class="shell">
<form>
<ul>
<li><label class="label" for="cheetah" style="background-color: white"></label></li>
<li><label class="label" for="horse" style="background-color: yellow"></label></li>
<li><label class="label" for="lion" style="background-color: green"></label></li>
<li><label class="label" for="squirrel" style="background-color: red"></label></li>
<li><label class="label" for="tiger" style="background-color: purple"></label></li>
<li><label class="label" for="bear" style="background-color: black"></label></li>
</ul>
<div class="radio-buttons">
<div class="wrapper">
<input type="radio" name="radio" class="radio" id="cheetah" value="" />
<label class="label" for="cheetah" ></label>
</div>
<div class="wrapper">
<input type="radio" name="radio" class="radio" id="horse" value="" />
<label class="label" for="horse" ></label>
</div>
<div class="wrapper">
<input type="radio" name="radio" class="radio" id="lion" value="" />
<label class="label" for="lion" ></label>
</div>
<div class="wrapper">
<input type="radio" name="radio" class="radio" id="squirrel" value="" />
<label class="label" for="squirrel"></label>
</div>
<div class="wrapper">
<input type="radio" name="radio" class="radio" id="tiger" value="" />
<label class="label" for="tiger"></label>
</div>
<div class="wrapper">
<input type="radio" name="radio" class="radio" id="bear" value="" />
<label class="label" for="bear" ></label>
</div>
</div>
</form>
</div>
CSS:
*{ margin: 0; padding: 0; }
.shell { width: 1000px; margin: 0 auto; }
ul { height: 150px; list-style: none; padding-bottom: 50px; }
ul li {
float: left;
border: 1px solid #666;
margin-right: 14px;
}
ul li label {
display: block;
width: 150px;
height: 150px;
cursor: pointer;
}
ul label {
display: inline;
}
input[type="radio"] {
display: none;
}
input[type="radio"]:checked + label.label {
border: 1px solid red;
background-repeat: no-repeat;
display: inline-block;
height: 500px;
width: 500px;
}
input[type="radio"]:checked + label[for="cheetah"] {
background-color: white
}
input[type="radio"]:checked + label[for="horse"] {
background-color: yellow
}
input[type="radio"]:checked + label[for="lion"] {
background-color: green
}
input[type="radio"]:checked + label[for="squirrel"] {
background-color: blue
}
input[type="radio"]:checked + label[for="tiger"] {
background-color: purple
}
input[type="radio"]:checked + label[for="bear"] {
background-color: black
}
As described in the Link I provided in the comment, you can use the following html:
<input type="radio" id="radio-2-1" name="radio-2-set" class="regular-radio big-radio" /><label for="radio-2-1"></label><br />
<input type="radio" id="radio-2-2" name="radio-2-set" class="regular-radio big-radio" /><label for="radio-2-2"></label><br />
together with the css similar to:
.regular-radio {
display: none;
}
.regular-radio + label {
-webkit-appearance: none;
background-image: url("unchecked.png");
padding: 9px;
border-radius: 50px;
display: inline-block;
position: relative;
}
.regular-radio:checked + label:after {
content: ' ';
width: 12px;
height: 12px;
border-radius: 50px;
position: absolute;
top: 3px;
background-image: url("checked.png");
box-shadow: inset 0px 0px 10px rgba(0,0,0,0.3);
text-shadow: 0px;
left: 3px;
font-size: 32px;
}
.regular-radio:checked + label {
background-image: url("checked.png");
border: 1px solid #adb8c0;
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05), inset 15px 10px -12px rgba(255,255,255,0.1), inset 0px 0px 10px rgba(0,0,0,0.1);
}
Block-level HTML elements have a few restrictions:
They must be separated from surrounding text by blank lines.
The begin and end tags of the outermost block element must not be indented.
Markdown can't be used within HTML blocks.