I am doing the following radio button code in a wordpress post loop:
<input id="<?php the_title(); ?>" type="radio" name="phoneSelect" value="test">
<label for="<?php the_title(); ?>">Select</label>
Each generated radio button has a unique id which assigns also a unique label for="". When I do the following styling, the checked element is only working on one radio button. When I select another radio button, the first button changes the style but the next radio button does not apply the css settings
input[type=radio] {
display:none;
}
input[type=radio] + label {
display:inline-block;
margin:-2px;
padding: 4px 12px;
margin-bottom: 0;
font-size: 14px;
line-height: 20px;
color: #333;
text-align: center;
text-shadow: 0 1px 1px rgba(255,255,255,0.75);
vertical-align: middle;
cursor: pointer;
background-color: #f5f5f5;
background-image: -moz-linear-gradient(top,#fff,#e6e6e6);
background-image: -webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));
background-image: -webkit-linear-gradient(top,#fff,#e6e6e6);
background-image: -o-linear-gradient(top,#fff,#e6e6e6);
background-image: linear-gradient(to bottom,#fff,#e6e6e6);
background-repeat: repeat-x;
border: 1px solid #ccc;
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);
border-bottom-color: #b3b3b3;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
}
input[type=radio]:checked + label {
background-image: none;
outline: 0;
-webkit-box-shadow: inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);
-moz-box-shadow: inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);
box-shadow: inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);
background-color:#e0e0e0;
}
The following JSfiddle can replicate the issue (obviously because the php isn't being executed) http://jsfiddle.net/83uc5xy5/
This is a working example:
<div><input type="radio" name ="test" id="test"/>
dasdas
</div>
<input type="radio" name ="test" id="test"/>
CSS:
input[type="radio"]:checked{
margin-top:50px;
}
It moves the selected checkbox with 50px from the top.
Related
I want to modify the slider but I get this error:
Unknown property name
What am I doing wrong?
I am using chrome and my os is windows 7.
<head>
<body>
<div class="gene_controller width" data-original_value="0" data-name="width">
<p class="gene_name">width</p>
<div class="gene_slider">
<div class="gene_input_row"><img class="undo invisible" src="/image/reset.png" style="padding:1px;"><input class="number_input slider-input" type="number" value="0" step="0.1"><img class="x" src="icons/scroll.svg"></div>
<div class="slider"><input type="range" min="-2" max="2" step="any" value="0"></div>
</div>
<!--document.getElementsByClassName("slider")[0].children[0].min
esto es un comentario en html
-->
<style>
input[type="range"] {
-webkit-appearance: none;
width: 100%;
background: transparent;
&:focus {
outline: none;
}
&::-webkit-slider-thumb {
-webkit-appearance: none;
height: 21px;
width: 11px;
background: svg-load(".\icons\indicator-horizontal.svg");
transform: translateY(-8px);
}
&::-moz-range-thumb {
height: 41px;
width: 11px;
border: 0;
border-radius: 0;
background: svg-load(".\icons\indicator-horizontal.svg");
transform: translateY(2px);
}
&::-webkit-slider-runnable-track {
width: 100%;
height: 2px;
box-sizing: border-box;
background: black;
border-right: 1px solid grey;
border-bottom: 1px solid grey;
box-shadow: 1px 0 0 white, 1px 1px 0 white, 0 1px 0 white, -1px 0 0 darkgrey, -1px -1px 0 darkgrey,
0 -1px 0 darkgrey, -1px 1px 0 white, 1px -1px darkgrey;
}
&::-moz-range-track {
width: 100%;
height: 2px;
box-sizing: border-box;
background: black;
border-right: 1px solid grey;
border-bottom: 1px solid grey;
box-shadow: 1px 0 0 white, 1px 1px 0 white, 0 1px 0 white, -1px 0 0 darkgrey, -1px -1px 0 darkgrey,
0 -1px 0 darkgrey, -1px 1px 0 white, 1px -1px darkgrey;
}
}
</style>
</div>
Your path is not correct, use this format:
./icons/indicator-horizontal.svg
for more examples check this link:
https://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/
I believe you are using background: svg-load(".\icons\indicator-horizontal.svg"); property wrongly.
Simply try with background: url(".\icons\indicator-horizontal.svg"); everywhere you using background property.
Make sure you use the correct url relative path w.r.t your CSS file.
convert your scss to css
input[type="range"]{
-webkit-appearance:none;width:100%;background:transparent
}
input[type="range"]:focus{
outline:none
}
input[type="range"]::-webkit-slider-thumb{
-webkit-appearance:none;
height:21px;
width:11px;
background:svg-load(".iconsindicator-horizontal.svg");
-webkit-transform:translateY(-8px);
transform:translateY(-8px)}
input[type="range"]::-moz-range-thumb{
height:41px;
width:11px;
border:0;
border-radius:0;
background:svg-load(".iconsindicator-horizontal.svg");
transform:translateY(2px)}
input[type="range"]::-webkit-slider-runnable-track{
width:100%;
height:2px;
box-sizing:border-box;
background:black;
border-right:1px solid grey;
border-bottom:1px solid grey;
box-shadow:1px 0 0 white, 1px 1px 0 white, 0 1px 0 white, -1px 0 0 darkgrey, -1px -1px 0 darkgrey, 0 -1px 0 darkgrey, -1px 1px 0 white, 1px -1px darkgrey
}
input[type="range"]::-moz-range-track{
width:100%;
height:2px;
box-sizing:border-box;
background:black;
border-right:1px solid grey;
border-bottom:1px solid grey;
box-shadow:1px 0 0 white, 1px 1px 0 white, 0 1px 0 white, -1px 0 0 darkgrey, -1px -1px 0 darkgrey, 0 -1px 0 darkgrey, -1px 1px 0 white, 1px -1px darkgrey
}
<div class="gene_controller width" data-original_value="0" data-name="width">
<p class="gene_name">width</p>
<div class="gene_slider">
<div class="gene_input_row"><img class="undo invisible" src="/image/reset.png" style="padding:1px;"><input class="number_input slider-input" type="number" value="0" step="0.1"><img class="x" src="icons/scroll.svg"></div>
<div class="slider"><input type="range" min="-2" max="2" step="any" value="0"></div>
</div>
<!--document.getElementsByClassName("slider")[0].children[0].min
esto es un comentario en html
-->
</div>
How do i make my checkboxes transparant? It does work with text fields and buttons but it doesnt seem to work with checkboxes.
This is the form of my code.
#checkbox {
width: 20px;
height: 20px;
cursor: pointer;
vertical-align: bottom;
color: black;
background-color: rgba(0, 0, 0, 0.08);
}
<div class="checkbox check-transparent">
<label>
<input type="checkbox" id="checkbox">Onthoud mij
</label>
</div>
The only thing that can be done for a regular checkbox is making it transparent by decreasing its opacity but it also lightens the tick mark inside if checked. A workaround is, having the checkbox wrapped in a div and changing the color of the checkbox when checked like shown in the snippet below:
#checkb {
width: 20px;
height: 20px;
cursor: pointer;
background: rgba(40,40,40,0.2);
color:black;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
position: relative;
left: -5px;
top: -5px;
}
#checkb:checked {
background: rgba(40,40,40,0.7);
}
.checkbox-container {
position: absolute;
display: inline-block;
margin: 20px;
width: 100px;
height: 100px;
overflow: hidden;
}
<div class="checkbox-container">
<input type="checkbox" id="checkb"/> Input
</div>
You can also (classic method that allows to restyle a checkbox crossbrowser following standards)
take input ahead and outside the label
link the label to its input via attribute for
use a pseudo on label to draw a checkbox via css and also apply size and background.
hide the checkbox
label {
display: inline-block;
}
#checkbox {
display: none;
}
label:before {
content: '';
cursor: pointer;
vertical-align: bottom;
color: black;
background-color: rgba(0, 0, 0, 0.1);
/* average checkbox styling */
line-height: 1.1em;
font-weight: bold;
text-align: center;
font-size: 20px;
height: 20px;
width: 20px;
display: inline-block;
box-shadow: inset 0 0 1px 1px rgb(153, 154, 154), inset 0 0 1px 2px white, inset 0 0 1px 2px white, inset 2px 2px 1px 1px rgb(182, 187, 192), inset -1px -1px 2px 1px rgb(182, 187, 192), inset 8px 8px 4px -4px rgb(182, 187, 192);
box-sizing: border-box;
}
:checked+label:before {
content: '\2713';
color: rgb(74, 95, 151);
}
:checked+label {
color: rgb(74, 95, 151);
}
label:hover {
color: rgb(28, 50, 125);
}
label:hover:before {
box-shadow: inset 0 0 1px 1px rgb(95, 133, 156), inset 0 0 1px 2px rgb(198, 237, 252), inset 0 0 1px 2px rgb(198, 237, 252), inset 2px 2px 1px 1px rgb(134, 203, 246), inset -1px -1px 2px 1px rgb(134, 203, 246), inset 8px 8px 4px -4px rgb(134, 203, 246);
}
<div class="checkbox check-transparent">
<input type="checkbox" id="checkbox">
<label for="checkbox"> Onthoud mij
</label>
</div>
I have some CSS that attempts to do a pressed in button effect on either "active" or "hover" events but for some bizarre reason, the CSS from the event also appears to affect other buttons which are not being hovered or active.
See below example - when you hover over any of the three buttons, the others margins get changed and move up/down when they shouldn't be affected at all.
What's going on?
input[type="button"], input[type="reset"], input[type="submit"] {
color: #000000;
cursor: pointer;
overflow: visible;
background-color: #F0F0F0;
border-bottom: none;
border-top: 1px solid #CCCCCC;
/*box-shadow: 0 -4px 0 #CCCCCC inset;*/
box-shadow: 0 -4px 0 0 rgba(204, 204, 204, 1) inset;
border-collapse: separate;
margin-bottom: 0;
padding: 3px 13px 6px 13px;
position: relative;
text-transform: uppercase;
background-clip: padding-box;
border-bottom-right-radius: 4px;
border-right: 1px solid #CCCCCC;
border-top-right-radius: 4px;
border-bottom-left-radius: 4px;
border-left: 1px solid #CCCCCC;
border-top-left-radius: 4px;
background-image: none;
}
input[type="submit"]:hover,
input[type="button"]:hover {
box-shadow: 0 -2px 0 #CCCCCC inset;
margin-top: 4px;
padding-bottom: 4px;
background-image: none;
}
<center>
<input value="Yes, submit now!" name="button" type="submit">
<!-- WARNING: value of button is checked on next page -->
<input value="No, enter more details" name="button" type="submit">
<input value="Exit" name="button" type="submit">
</center>
well they move because one of them get's margin-top:4px , so they all move after that element
i suggest you use transform:translateY(4px) instead of margin-top:4px on :hover
see snippet below
input[type="button"], input[type="reset"], input[type="submit"] {
color: #000000;
cursor: pointer;
overflow: visible;
background-color: #F0F0F0;
border-bottom: none;
border-top: 1px solid #CCCCCC;
/*box-shadow: 0 -4px 0 #CCCCCC inset;*/
box-shadow: 0 -4px 0 0 rgba(204, 204, 204, 1) inset;
border-collapse: separate;
margin-bottom: 0;
padding: 3px 13px 6px 13px;
position: relative;
text-transform: uppercase;
background-clip: padding-box;
border-bottom-right-radius: 4px;
border-right: 1px solid #CCCCCC;
border-top-right-radius: 4px;
border-bottom-left-radius: 4px;
border-left: 1px solid #CCCCCC;
border-top-left-radius: 4px;
background-image: none;
}
input[type="submit"]:hover,
input[type="button"]:hover {
box-shadow: 0 -2px 0 #CCCCCC inset;
transform:translateY(4px);
padding-bottom: 4px;
background-image: none;
}
<center>
<input value="Yes, submit now!" name="button" type="submit">
<!-- WARNING: value of button is checked on next page -->
<input value="No, enter more details" name="button" type="submit">
<input value="Exit" name="button" type="submit">
</center>
How do I style a button, with a shadow, so that it looks like it is pressed in?
I tried using box-shadow: ... ;. But this didn't have any affect.
By creatively styling the :active or :focus pseudo classes using a box-shadow: inset ...;
Using the :active pseudo class:
button {
background: #ededed;
border: 1px solid #ccc;
padding: 10px 30px;
border-radius: 3px;
cursor: pointer;
}
button:active {
background: #e5e5e5;
-webkit-box-shadow: inset 0px 0px 5px #c1c1c1;
-moz-box-shadow: inset 0px 0px 5px #c1c1c1;
box-shadow: inset 0px 0px 5px #c1c1c1;
outline: none;
}
<button>
Click me
</button>
Using the :focus pseudo class:
button {
background: #ededed;
border: 1px solid #ccc;
padding: 10px 30px;
border-radius: 3px;
cursor: pointer;
}
button:focus {
background: #e5e5e5;
outline: none;
-webkit-box-shadow: inset 0px 0px 5px #c1c1c1;
-moz-box-shadow: inset 0px 0px 5px #c1c1c1;
box-shadow: inset 0px 0px 5px #c1c1c1;
}
<button>
Click me
</button>
As an alternative to buttons, there is also a possibility to simply use checkbox with the pseudo-class :checked to toggle between states.
label.label-checkbox {
cursor: pointer;
}
label.label-checkbox input {
position: absolute;
top: 0;
left: 0;
visibility: hidden;
pointer-events: none;
}
label.label-checkbox span {
padding: 11px 21px;
border: 1px solid #ccc;
display: inline-block;
color: #202020;
border-radius: 6px;
margin: 7px;
background: #f5f5f5;
user-select: none;
}
label.label-checkbox input:checked + span {
box-shadow: inset 1px 2px 5px #777;
transform: translateY(1px);
background: #e5e5e5;
}
<h1>Pressed buttons with Checkbox</h1>
<label class="label-checkbox">
<input type="checkbox">
<span>Checkbox</span>
</label>
<label class="label-checkbox">
<input type="checkbox" checked>
<span>Styled</span>
</label>
<label class="label-checkbox">
<input type="checkbox">
<span>As</span>
</label>
<label class="label-checkbox">
<input type="checkbox" checked>
<span>Pressed</span>
</label>
<label class="label-checkbox">
<input type="checkbox">
<span>Buttons</span>
</label>
The best way is to nudge the button lower on the page. Using transformY would be the most straight-forward. However that can mess up the layout of other things in the page. So I think that it is better to use margin to temporarily lower the button, such as,
button {
background-color: white;
padding: 10px;
vertical-align: top;
box-shadow: 2px 1px 2px gray;
margin: 4px 10px 4px 10px;
}
button:active {
box-shadow: 0 0 0 white;
margin: 6px 10px 2px 10px;
}
<button>click me</button>
<button>click me</button>
<br>
<button>click me</button>
<button>click me</button>
As in the example, you can take away 2px from the bottom margin, and add 2px to the top margin, therefore you preserve the total size of the button.
You need vertical-align in case there are more than one button.
I think that the best way to make a button looks like it's pressed it's to make it a little darker.
button{
background-color: #03A9F4;
border: none;
padding: 15px 25px;
text-transform: uppercase;
color: white;
font-weight: 700;
border-radius: 3px;
}
button:hover, button:focus{
background-color: #0074a9;
outline: none;
}
<button>Button</button>
If you think visually about what happens when a push-button (like on an old-style stereo system) is pushed in, the button moves back. Visually, the face of the button is darker. The text on the button is inset. The border of the button is dark.
The other answers here all give part of the answer.
This visually does all of the above:
.btnPushed {
color: #efefef; //orig text color was #FFF
text-shadow: -1px -1px 0px #777, -1px -1px 0px #777;
box-shadow: inset 1px 1px 4px #222;
transform: translateY(1px); /* Add per Vince's helpful comment */
}
As you might notice, we apply the styling by adding a class.
$('button').click(function(){
$('button').removeClass('depressed');
$(this).addClass('depressed');
});
button {
border: 1px solid black;
border-radius: 3px;
color: #f5f5f5;
background-color: #b8860b;
background-image: linear-gradient(-180deg,#6699FF,#3473F5 90%);
cursor: pointer;
font-size: 14px;
line-height: 20px;
outline: none; /* Removes Chrome's blue outline */
margin: 2px;
}
button:active{
}
.depressed{
color: #efefef;
text-shadow: -1px -1px 0px #777, -1px -1px 0px #777;
box-shadow: inset 1px 1px 3px #222;
margin: 3px -1px -1px 3px; /* T R B L */
transform: translateY(1px);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<button>Button1</button>
<button>Button2</button>
<button class="depressed">Button3</button>
<button>Button4</button>
To avoid the adjustment (movement) of the other buttons due to the margin change, just put each button into a fix-size div. That way the buttons move around within their divs, without affecting the other buttons inside their own divs.
$('button').click(function(){
$('button').removeClass('depressed');
$(this).addClass('depressed');
});
div {
display: inline-block;
width: 65px;
height: 25px;
}
button {
border: 1px solid black;
border-radius: 3px;
color: #f5f5f5;
background-image: linear-gradient(-180deg,#6699FF,#3473F5 90%);
cursor: pointer;
font-size: 14px;
line-height: 20px;
outline: none; /* Removes Chrome's blue outline */
margin: 2px;
}
button:active{
}
.depressed{
color: #efefef;
text-shadow: -1px -1px 0px #777, -1px -1px 0px #777;
box-shadow: inset 1px 1px 3px #222;
margin: 3px -1px -1px 3px; /* T R B L */
transform: translateY(1px);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<div><button>Button1</button></div>
<div><button>Button2</button></div>
<div><button class="depressed">Button3</button></div>
<div><button>Button4</button></div>
Update:
Added transform: translateY(1px), per Vince's helpful comment below.
.button{
color: white;
background-color: blue;
padding: 8px 25px;
border-radius : 7px;
}
.button:active {
box-shadow: 0 0 0 black;
margin: 3px 0 0 0 ;
}
<input type="button" class="button" value="Enter">
button{
background-color:grey;
padding:10px;
border:none;
color:white;
}
button:hover{
background-color:black;
color:white;
}
<button class"b1">button</button>
Here's what it looks like in Firefox:
What is looks like in Chrome:
Here are the CSS rules I'm using:
<div class="checkbox-field">
<p>Mr.</p>
<input type="radio" name="prefix" value="mr" />
<p>Mrs.</p>
<input type="radio" name="prefix" value="mrs" />
</div>
.checkbox-field input {
float: left;
margin-right: 46px;
border: 1px solid #A97232;
padding: 3px;
width: 22px;
-webkit-box-shadow: 0 1px 3px -1px black;
-moz-box-shadow: 0 1px 3px -1px black;
box-shadow: 0 1px 3px -1px black;
border-radius: 4px 4px 4px 4px;
-moz-border-radius: 4px 4px 4px 4px;
-webkit-border-radius: 4px 4px 4px 4px;
color: #636363;
behavior: url(/Public/stylesheets/PIE.htc);
margin-top: 5px;
}
JSFiddle example here:
http://jsfiddle.net/zFNRy/
Please normalize your styles: http://necolas.github.com/normalize.css/