I need to match the selectors that I put down in the image but I can't find any css property to do it
The point is that I need that when the input-radio is checked the button is seen in another color, any css expert that can help me?
Thanks
<div class="radio" id="uniform-28">
<span class="checked">
<input type="radio" class="attribute_radio" name="group_1" value="28" id="28"></span>
</div>
<label for="28">5/6</label>
enter image description here
You cannot select parent elements via css, therefor you have to use script and toggle element classes. One way to do it:
$('.attribute_radio').each(function(i) {
var thisRadio = $(this);
var thisName = thisRadio.attr('name');
var groupRadios = $('.attribute_radio[name='+thisName+']');
thisRadio.on('change', function() {
groupRadios.each(function(j) {
var thatRadio = $(this);
thatRadio.closest('.radio').toggleClass('radio_checked', thatRadio.is(':checked'));
/* You could also target the label itself this way: */
var labelId = thatRadio.attr('id');
var thatLabel = $('label[for='+labelId+']');
thatLabel.toggleClass('label_checked', thatRadio.is(':checked'));
});
}).trigger('change');
});
.radio {
display: none;
}
.radio + label {
display: inline-block;
padding: 10px 14px;
min-width: 50px;
background: #ddd;
color: #444;
border: 3px solid #444;
border-radius: 6px;
}
.radio_checked + label {
background: yellow;
}
.label_checked {
/* Any styles */
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>
Group 1
</p>
<div class="radio" id="uniform-27">
<span class="checked">
<input type="radio" class="attribute_radio" name="group_1" value="27" id="27">
</span>
</div>
<label for="27">4</label>
<div class="radio" id="uniform-28">
<span class="checked">
<input type="radio" class="attribute_radio" name="group_1" value="28" id="28" checked="checked">
</span>
</div>
<label for="28">5/6</label>
<p>
Group 2
</p>
<div class="radio" id="uniform-37">
<span class="checked">
<input type="radio" class="attribute_radio" name="group_2" value="37" id="37" checked="checked">
</span>
</div>
<label for="37">XS</label>
<div class="radio" id="uniform-38">
<span class="checked">
<input type="radio" class="attribute_radio" name="group_2" value="38" id="38">
</span>
</div>
<label for="38">S</label>
Also on JSFiddle.
I think you should restructure your DOM and that will make it easy for you to apply CSS.
How about this?
<div class="radio" id="uniform-28">
<span class="checked">
<input type="radio" class="attribute_radio" name="group_1" value="28" id="28"/>
<label for="28">5/6</label>
</span>
</div>
And then you can apply style you want
.checked label {
background-color: yellow;
}
This way you don't have to do extra wotk with JS and CSS.
Also you might have to change your existing CSS if you want use above HTML.
Related
I need to do the same as here:
http://deinehelfer24.de/renovierungen/
As I understand it, this is done on contact form 7, but how are the images and multiple selections implemented?
I feel generous today, simpe example ho you can style labels
https://jsfiddle.net/Beneris/65mdtpo3/28/
HTML
<form>
<div class="input-group">
<div class="input-wrap">
<input type="radio" name="group1" id="group1-1" value="1">
<label for="group1-1">
<figure><img src="http://placekitten.com/g/100/100"><h3>Radio 1</h3></figure>
</label>
</div>
<div class="input-wrap">
<input type="radio" name="group1" id="group1-2" value="2">
<label for="group1-2">
<figure><img src="http://placekitten.com/g/100/100"><h3>Radio 2</h3></figure>
</label>
</div>
<div class="input-wrap">
<input type="radio" name="group1" id="group1-3" value="3">
<label for="group1-3">
<figure><img src="http://placekitten.com/g/100/100"><h3>Radio 3</h3></figure>
</label>
</div>
</div>
<div class="input-group">
<div class="input-wrap to-toggle 1 3">
<input type="checkbox" name="group2" id="group2-1" value="1">
<label for="group2-1">
<figure><img src="http://placekitten.com/g/100/100"><h3>checkbox 1</h3></figure>
</label>
</div>
<div class="input-wrap to-toggle 1 2">
<input type="checkbox" name="group2" id="group2-2" value="2">
<label for="group2-2">
<figure><img src="http://placekitten.com/g/100/100"><h3>checkbox 2</h3></figure>
</label>
</div>
<div class="input-wrap to-toggle 1 2 3">
<input type="checkbox" name="group2" id="group2-3" value="3">
<label for="group2-3">
<figure><img src="http://placekitten.com/g/100/100"><h3>checkbox 3</h3></figure>
</label>
</div>
</div>
</form>
CSS
.radio-group {
display:block;
}
.input-group .input-wrap{
display:inline-block;
vertical-align: top;
padding: 10px;
}
label figure {
background-color: #ccc;
padding: 5px 10px;
border-radius: 0 0 5px 5px;
cursor: pointer;
}
figure h3 {
text-align: center;
}
.input-group input:checked ~ label figure {
background-color: red;
}
.input-wrap input {
display:none;
}
JS
$('.to-toggle').hide();
$('input[name=group1]').on('change', function(){
var val = $(this).val();
$('.to-toggle').hide();
$('.to-toggle input').prop('checked', false);
$('.to-toggle.' + val).show();
//alert(val);
});
how to create focus on two elements?
<div class="form-group">
<label class="control-label"></label>
<div class="col-sm-10">
<input type="text" class="form-control">
<span class="loop-icon form-control-feedback"></span>
</div>
</div>
no focus
I would like to get something like that
results
I don't want to use javascript
You can use sibling selector " + " that will select the next element.
.inp:focus + .icon{
color:red;/* can use any color*/
}
This code will select the sibling of input, i.e. the icon class, when the input is focused,
form-group{
position:relative;
}
.icon{
position: absolute;
right: 35px;
top: 11px;
}
.inp{
padding:right:40px;
}
.inp:focus + .icon{
color:red;/* can use any color*/
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="form-group">
<label class="control-label"></label>
<div class="col-sm-10">
<input type="text" class="form-control inp">
<span class="fa fa-search form-control-feedback icon"></span>
</div>
</div>
I want to change the color of the glyphicon when a user focus on input field. Any help is appreciated.
<div class="form-group inner-addon left-addon">
<i class="glyphicon glyphicon-user userglyphicon"></i>
<input class="form-control user" name="username placeholder="Username">
</div>
I have reversed the position of the input and glyphicon, so we can access the glyphicon as a sibling.
To put the glyphicon in front of the input field, I defined the form-group as a flexbox and used order to reposition the elements.
.form-group1,
.form-group2 {
display: flex;
align-items: center;
}
.form-group1 input,
.form-group2 input {
order: 2;
}
.form-group1 i,
.form-group2 i {
order: 1;
padding-right: 0.5em;
}
.form-group1 input:focus+i {
color: red;
}
.form-group2 input:focus+i {
color: blue;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="form-group1 inner-addon left-addon">
<input class="form-control user" name="username" placeholder="Username" />
<i class="fa fa-user-o" aria-hidden="true"></i>
</div>
<br>
<div class="form-group2 inner-addon left-addon">
<input class="form-control user" name="username" placeholder="Username" />
<i class="fa fa-user-o" aria-hidden="true"></i>
</div>
I want to align some check boxes with labels such that the check boxes are in a vertical row to the right side and the labels are aligned with the starting edges in a vertical row on the left side.
.row {
display: flex;
}
.row label { flex: 1; max-width: 25%; }
<div class="container">
<div class="row">
<label>Label</label><input type="checkbox" />
</div>
<div class="row">
<label>Label 2</label><input type="checkbox" />
</div>
<div class="row">
<label>Label 3</label><input type="checkbox" />
</div>
</div>
I believe this is what you're looking for:
label {
display: inline-block;
padding-left: 15px;
}
<form>
<div>
<label>Label text</label><input type="checkbox" />
<label>Label text</label><input type="checkbox" />
<label>Label text</label><input type="checkbox" />
</div>
<form>
Working Example: JSFiddle
Css File:
.badgebox
{
opacity: 0;
}
.badgebox + .badge
{
/* Move the check mark away when unchecked */
text-indent: -999999px;
/* Makes the badge's width stay the same checked and unchecked */
width: 27px;
}
.badgebox:focus + .badge
{
/* Set something to make the badge looks focused */
/* This really depends on the application, in my case it was: */
/* Adding a light border */
box-shadow: inset 0px 0px 5px;
/* Taking the difference out of the padding */
}
.badgebox:checked + .badge
{
/* Move the check mark back when checked */
text-indent: 0;
}
HTML File:
<div class="container">
<div class="row text-center">
<br>
<br>
<h1>Badgebox: CSS only checkbox badge!</h1>
<h2>Works on Bootstrap 2.3.2 and up</h2>
<br>
<label for="default" class="btn btn-default">Default <input type="checkbox" id="default" class="badgebox"><span class="badge">✓</span></label>
<label for="primary" class="btn btn-primary">Primary <input type="checkbox" id="primary" class="badgebox"><span class="badge">✓</span></label>
<label for="info" class="btn btn-info">Info <input type="checkbox" id="info" class="badgebox"><span class="badge">✓</span></label>
<label for="success" class="btn btn-success">Success <input type="checkbox" id="success" class="badgebox"><span class="badge">✓</span></label>
<label for="warning" class="btn btn-warning">Warning <input type="checkbox" id="warning" class="badgebox"><span class="badge">✓</span></label>
<label for="danger" class="btn btn-danger">Danger <input type="checkbox" id="danger" class="badgebox"><span class="badge">✓</span></label>
</div>
</div>
Or
Refer this Link:
https://bootsnipp.com/snippets/featured/badgebox-css-checkbox-badge
I'm working on a web page and have some problems with the design, this is the piece of code where I need some help:
<form id="form_articulo_ver" method="post" action="./articulo/articulo_ver.php" role="form" target="frame_articulo_ver">
<div class="input-group col-md-3">
<div class="input-group-btn">
<button class="btn btn-primary" type="button" onClick="busca_referencia()" data-toggle="tooltip" data-placement="top" title="Buscar Referencia"><span class="glyphicon glyphicon-search"></span> </button>
</div>
<input type="text" class="form-control" placeholder="Referencia"/>
<span class="input-group-btn">
<button class="btn btn-success" type="button" onClick="aceptar_referencia()" data-toggle="tooltip" data-placement="top" title="Confirmar Referencia"><span class="glyphicon glyphicon-ok"></span> </button>
</span>
</div>
</form>
<br>
<form id="form_lineas_ref" method="post" action="./articulo/frame_lineas.php" role="form" target="frame_lineas">
<div class="input-group custom-input-group">
<input type="hidden" class="form-control"/>
<span class="input-group-addon">Desc.</span>
<input type="text" class="form-control" placeholder="Descripción"/>
<span class="input-group-addon">Precio</span>
<input type="text" class="form-control" placeholder="Precio"/>
<span class="input-group-addon">Uds.</span>
<input type="text" class="form-control" placeholder="Unidades"/>
<span class="input-group-addon">Dcto. %</span>
<input type="text" class="form-control" placeholder="Descuento"/>
<span class="input-group-addon">Importe</span>
<input type="text" class="form-control" placeholder="Importe"/>
<span class="input-group-addon">€</span>
<div class="input-group-btn">
<button class="btn btn-success" type="button" onClick="aceptar_linea()" data-toggle="tooltip" data-placement="top" title="Añadir linea"><span class="glyphicon glyphicon-ok"></span> </button>
</div>
</div>
</form>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" id="frame_lineas" name="frame_lineas" frameborder="0"></iframe>
</div>
This code looks like this:
But I need "Descripción" input to be larger than the others. I found a css that breaks the input when the screen is smaller, works fine... I don't care if "Descripción" input is same size in lite screen but in large ones need to have more witdh.
Here is the css of the "custom-input-group":
#media (max-width:500px) {
.custom-input-group.input-group .input-group-btn {
width:99%;
display:block;
margin-bottom:5px;
}
.custom-input-group.input-group .input-group-btn .btn {
width: 34%;
}
.custom-input-group.input-group .input-group-btn .btn:last-child {
border-radius:0 4px 4px 0
}
.custom-input-group {
display: block
}
.custom-input-group.input-group .input-group-addon {
clear: both;
display: block;
width: 100%;
border: 1px solid #ccc;
border-radius: 4px;
}
.custom-input-group.input-group .input-group-addon + .form-control {
border-radius: 4px;
margin-bottom: 5px;
}
}
Thank you very much. Sorry for my English.
Hello Just use Size=50 in your input tag .Hope it will help you
<span class="input-group-addon ">Desc.</span>
<input type="text" class="form-control " size="50"
placeholder="Descripción"/>
I suggest you use expanding on click input box for the description.
<div class="container-fluid">
<!--expanding input field -->
<h2 class="timeline-title">Expanding Input (CSS only)</h2>
<p><small class="text-muted">Grows wider when clicked...</small></p>
<input class="form-control input-lg" id="myInput" placeholder="Click here" type="text">
</div>
CSS here.
body {
background-color:#e9e9f4;}
/* expanding input CSS only */ #myInput{ width:130px; -webkit-transition:width 0.3s ease-in-out; } #myInput:focus { width:100%; -webkit-transition:width 0.5s ease-in-out;}
hope this helps