Cannot add element in the same line - html

I'm trying to make a favourite checkbox on the right side of the div, this is the html structure:
.star {
visibility: hidden;
font-size: 30px;
cursor: pointer;
color: orange;
}
.star:before {
content: "\2605";
position: absolute;
visibility: visible;
}
.star:checked:before {
content: "\2606";
position: absolute;
}
.group {
background-color: #20262e;
}
<div class="group text-truncate">
<label class="font-weight-bold">
<span class="align-middle text-truncate" style="color:white">This is a long text</span>
<span class="align-middle" style="color: orange;">(3 items)</span>
</label>
<input type="checkbox" style="float:right;" class="group-checkbox star">
</div>
if you look at the JSFIDDLE, you will see that the checkbox is greather than the container, how can I manage this?

There are a few things I would change:
use flex instead of float
use a label for your star instead of the input itself
remove the absolute positioning - it's not needed and can just complicate things
don't mix inline styles with css - it's best to use all css (I haven't fixed this though)
/* seperate the checkbox and star styles */
.group-checkbox {
display:none;
}
.group-checkbox:checked + .star:before { /* using the adjacent sibling selector to selec the star after a checked input */
content: "\2606";
}
.star {
font-size: 30px;
cursor: pointer;
color: orange;
}
.star:before {
content: "\2605";
}
.group {
background-color: #20262e;
line-height:30px; /* may want to match the size of the star font */
display:flex; /* make the container flex */
width:100%;
}
.group .font-weight-bold {
flex-grow:1; /* make this label grow to fill the space the star doesn't take */
}
<div class="group text-truncate">
<label class="font-weight-bold">
<span class="align-middle text-truncate" style="color:white">This is a long text</span>
<span class="align-middle" style="color: orange;">(3 items)</span>
</label>
<input type="checkbox" class="group-checkbox" id="checkbox"><!-- give this an id -->
<label class="star" for="checkbox"><!--use a label and point it at the id of the chechbox so that you can click on it to change the status--></label>
</div>

My solution it's to suggest you to use flexbox it's very easy to understand, your problem is come from the font-size that you assign on your icon. You need to reduce font-size and on the parent make the CSS I make for you :)
.group {
display: flex;
flex-flow: row wrap;
align-items: center;
justify-content: space-between;
}
.star {
position: relative;
visibility: hidden;
font-size: 20px;
cursor: pointer;
color: orange;
}
.star:before {
content: "\2605";
position: absolute;
top: 50%;
transform: translateY(-50%);
visibility: visible;
}
.star:checked:before {
content: "\2606";
position: absolute;
}
.group{
background-color: #20262e;
}
<div class="group text-truncate">
<label class="font-weight-bold">
<span class="align-middle text-truncate" style="color:white">This is a long text</span>
<span class="align-middle" style="color: orange;">(3 items)</span>
</label>
<input type="checkbox" style="float:right;" class="group-checkbox star">
</div>

Please add position: relative; to .group and adjust the star position accordingly. check below:
.star {
visibility: hidden;
font-size: 20px;
cursor: pointer;
color: orange;
}
.star:before {
top: -3px;
right: 2px;
content: "\2605";
position: absolute;
visibility: visible;
}
.star:checked:before {
content: "\2606";
position: absolute;
}
.group {
position: relative;
background-color: #20262e;
}
<div class="group text-truncate">
<label class="font-weight-bold">
<span class="align-middle text-truncate" style="color:white">This is a long text</span>
<span class="align-middle" style="color: orange;">(3 items)</span>
</label>
<input type="checkbox" style="float:right;" class="group-checkbox star">
</div>

in your .star:before and .star:after, you need to set the position to relative
Now it let's them to be in the same position as the input that has star class itself!
Now you can align the input to be in the right place.
In that case, you can add these to your .star styles:
.star {
position: relative;
bottom: 12px;
right: 15px;
}
And it will be what you're looking for
This is the snippet:
.star {
visibility: hidden;
font-size: 30px;
cursor: pointer;
color: orange;
position: relative;
bottom: 12px;
right: 12px;
}
.star:before {
content: "\2605";
position: relative;
visibility: visible;
}
.star:checked:before {
content: "\2606";
position: relative;
}
.group {
background-color: #20262e;
height: 25px;
}
<div class="group text-truncate">
<label class="font-weight-bold">
<span class="align-middle text-truncate" style="color:white">This is a long text</span>
<span class="align-middle" style="color: orange;">(3 items)</span>
</label>
<input type="checkbox" style="float:right;" class="group-checkbox star">
</div>

I think you can just add a top attribute and clean it up with positioning and padding like below.
.star {
visibility: hidden;
font-size: 30px;
cursor: pointer;
color: orange;
}
.star:before {
content: "\2605";
position: absolute;
visibility: visible;
top: 0;
right: 10px;
}
.star:checked:before {
content: "\2606";
position: absolute;
}
.group{
background-color: #20262e;
padding: 5px;
}
<div class="group text-truncate">
<label class="font-weight-bold">
<span class="align-middle text-truncate" style="color:white">This is a long text</span>
<span class="align-middle" style="color: orange;">(3 items)</span>
</label>
<input type="checkbox" style="float:right;" class="group-checkbox star">
</div>

Few minor updates to the .star and .star:before classes will fix the issue, please have a look at the below-working snippet
.star {
visibility: hidden;
font-size: 30px;
cursor: pointer;
color: orange;
position: relative;
margin: 0;
padding: 0;
}
.star:before {
content: "\2605";
position: absolute;
visibility: visible;
top: 0;
right: 0;
line-height: 1;
font-size: 20px;
}
.star:checked:before {
content: "\2606";
position: absolute;
}
.group {
background-color: #20262e;
}
<div class="group text-truncate">
<input type="checkbox" style="float:right;" class="group-checkbox star">
<label class="font-weight-bold">
<span class="align-middle text-truncate" style="color:white">This is a long text</span>
<span class="align-middle" style="color: orange;">(3 items)</span>
</label>
</div>

Related

input and span elements with tooltip within div in same line

The span element in div has a tooltip. When I remove the tooltip from the span, see second div (word), the input field moves a bit higher than rest of input fields.
How can I fix this issue? Thank you in advanced.
<div>
<div class="word">
<input id="word-4" name="word-4" type="text" data-index="3" value="the">
<span class="x-tag" value="4"></span>
<span class="tooltip" value="4"><span class="tooltiptext">Words</span>><</span>
</div>
<div class="word">
<input id="word-5" name="word-5" type="text" data-index="4" value="supermarket">
<span class="x-tag" value="5"></span>
<span class="" value=""></span>
</div>
<div class="word">
<input id="word-6" name="word-6" type="text" data-index="5" value="nerby">
<span class="x-tag" value="6"></span>
<span class="tooltip" value="6"><span class="tooltiptext">Words</span>><</span>
</div>
</div>
Here is the full example:
https://jsfiddle.net/myFiddler/5encgkh0/1/
Remove float:left from input, there is no need to use and give padding to parent element
/***************/
/* Tool-Tip */
/***************/
/*https://www.w3schools.com/css/css_tooltip.asp*/
.parent{
padding:25px;
}
.tooltip {
position: relative;
display: inline-block;
/* border-bottom: 1px dotted black; If you want dots under the hoverable text */
}
/* Tooltip text */
.tooltip .tooltiptext {
position: absolute;
z-index: 1;
visibility: hidden;
width: 120px;
margin-left: -60px;
bottom: 100%;
left: 50%;
background-color: black;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
/* Fade in tooltip - takes 1 second to go from 0% to 100% opac: */
opacity: 0;
transition: opacity 2s;
}
/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
.tooltip .tooltiptext:after {
content: " ";
position: absolute;
top: 100%; /* At the bottom of the tooltip */
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: black transparent transparent transparent;
}
/********************/
/*** Word Input ***/
/********************/
.word {
width: 141px;
display: inline-block;
box-sizing: border-box;
position: relative;
margin-bottom: 12px;
}
.word .no-linking {
cursor: auto;
}
.icon-link.checked {
color: rgb(255,120,90);
}
.word > input {
width: 100px !important;
line-height: 24px;
font-size: 14px !important;
}
span.word {
border-radius: 4px;
margin-bottom: 5px;
}
.icon-link {
display: inline-block;
padding-top: 6px;
padding-left: 3px;
cursor: pointer;
}
.x-tag:after {
font-size: 13px;
content: "x";
padding: 1px 2px;
position: absolute;
display: inline-block;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
z-index: 100;
right: 36px;
line-height: 24px;
}
<div class="parent">
<div class="word">
<input id="word-1" name="word-1" type="text" data-index="0" value="I">
<span class="x-tag" value="1"></span>
<span class="tooltip" value="1"><span class="tooltiptext">Words</span>><</span>
</div>
<div class="word">
<input id="word-2" name="word-2" type="text" data-index="1" value="go">
<span class="x-tag" value="2"></span>
<span class="tooltip" value="2"><span class="tooltiptext">Words</span>><</span>
</div>
<div class="word">
<input id="word-3" name="word-3" type="text" data-index="2" value="to">
<span class="x-tag" value="3"></span>
<span class="tooltip" value="3"><span class="tooltiptext">Words</span>><</span>
</div>
<div class="word">
<input id="word-4" name="word-4" type="text" data-index="3" value="the">
<span class="x-tag" value="4"></span>
<span class="tooltip" value="4"><span class="tooltiptext">Words</span>><</span>
</div>
<div class="word">
<input id="word-5" name="word-5" type="text" data-index="4" value="supermarket">
<span class="x-tag" value="5"></span>
<span class="" value=""></span>
</div>
<div class="word">
<input id="word-6" name="word-6" type="text" data-index="5" value="nerby">
<span class="x-tag" value="6"></span>
<span class="tooltip" value="6"><span class="tooltiptext">Words</span>><</span>
</div>
</div>

Radio Buttons Fill

I'm Having trouble with my radio buttons, I don't want them to entirely fill the circle. Any word of advice. Here is link to what is happening on Codepen.
https://codepen.io/winterlion/pen/LYYJwZP
.item .text {
position: absolute;
display: inline-block;
cursor: pointer;
}
.item .text:before {
content: '';
display: inline-block;
vertical-align: text-bottom;
width: 18px;
height: 18px;
margin-right: 5px;
border-radius: 50%;
border: 2px solid #235b96;
outline: none;
box-shadow: 0 0 5px 0px gray inset;
}
.item input[type="radio"] {
display: none;
}
.item input[type="radio"]:checked+label .text:before {
content: '';
color: #235b96;
background-color: #479623;
}
<div class="item">
<input type="radio" id="r1" name="group1" value="trial1" />
<label for="r1" class="wrapper">
<span class="background"></span>
<h1 class="rp-text">Radio Buttons</h1>
<hr class="split-hr">
<br>
<span class="text"></span>
</label>
</div>
<div class="item">
<input type="radio" id="r2" name="group1" value="trial2" />
<label for="r2" class="wrapper">
<span class="background"></span>
<h1 class="rp-text">Buttons</h1>
<span class="text"></span>
</label>
</div>
If I understood your question right, you just want to move styles related to a green dot to an ::after pseudo element that must be a bit smaller than ::before.
.item .text {
position: absolute;
display: inline-block;
cursor: pointer;
}
.item .text::before,
.item .text::after {
content: '';
display: inline-block;
margin-right: 5px;
border-radius: 50%;
}
.item .text::before {
width: 18px;
height: 18px;
border: 2px solid #235b96;
box-shadow: 0 0 5px 0px gray inset;
}
.item input[type="radio"]:checked + label .text::after {
width: 12px;
height: 12px;
position: absolute;
left: 5px;
top: 5px;
}
.item input[type="radio"] {
display: none;
}
.item input[type="radio"]:checked + label .text:after {
color: #235b96;
background-color: #479623;
}
<div class="item">
<input type="radio" id="r1" name="group1" value="trial1" />
<label for="r1" class="wrapper">
<span class="background"></span>
<h1 class="rp-text">Radio Buttons</h1>
<hr class="split-hr">
<br>
<span class="text"></span>
</label>
</div>
<div class="item">
<input type="radio" id="r2" name="group1" value="trial2" />
<label for="r2" class="wrapper">
<span class="background"></span>
<h1 class="rp-text">Buttons</h1>
<span class="text"></span>
</label>
</div>

How to properly use CSS content?

I'm having trouble with this piece of code. It keeps showing up as the letter "a" instead of the mobile menu symbol.
.mobile_menu_bar:before {
position: relative;
top: 0;
left: 0;
font-size: 32px;
content: "\61";
cursor: pointer;
}
<div id="et_mobile_nav_menu">
<div class="mobile_nav closed">
<span class="select_page">Select Page</span>
<span class="mobile_menu_bar mobile_menu_bar_toggle"></span>
</div>
</div>
Am I suppose to define the content: "\61" ?
22 was lost in action. It should be \2261. See the snippet below:
.mobile_menu_bar:before {
position: relative;
top: 0;
left: 0;
font-size: 32px;
content: "\2261";
cursor: pointer;
}
<div id="et_mobile_nav_menu">
<div class="mobile_nav closed">
<span class="select_page">Select Page</span>
<span class="mobile_menu_bar mobile_menu_bar_toggle"></span>
</div>
</div>
Hello may u forget some code, try like this
.mobile_menu_bar:before{
position: relative;
top: 0;
left: 0;
font-size: 32px;
content: "\2261";
cursor: pointer;
}
Html file:
<div id="et_mobile_nav_menu">
<div class="mobile_nav closed">
<span class="select_page">Select Page</span>
<span class="mobile_menu_bar mobile_menu_bar_toggle"></span>
</div>
</div>

change background when radio button clicked

I have a radio button which i have given some style.
when i click on it then the div background color should change.
.no_of_speakers_radio_button {
margin: 0 auto;
display: flex;
padding: 35px 0px;
text-align: center;
flex-direction: column;
border:thin red solid;
width:100px;
}
.no_of_speakers_radio_button label {
overflow: hidden;
}
.no_of_speakers_radio_button label span {
text-align: center;
font-size: 15px;
margin: auto;
display: block;
}
.no_of_speakers_radio_button input {
position: absolute;
}
.no_of_speakers_radio_button input:checked + span {
background-color: #ebeff1;
text-align: center;
}
.no_of_speakers_radio_button input:not(:checked + span) {
background: transparent;
}
.no_of_speakers_radio_button:hover{
background: #ebeff1;
}
<div class="no_of_speakers_radio_button">
<label class="four_speakers">
<input type="radio" name="choose_speaker" class="click">
<span class="font_size_20">4</span>
<span class="font_size_17">Speakers</span>
</label>
</div>
<div class="no_of_speakers_radio_button">
<label class="eight_speakers">
<input type="radio" name="choose_speaker" class="click">
<span class="font_size_20">8</span>
<span class="font_size_17">Speakers</span>
</label>
</div>
What i want is, when clicking on radio button then whole div background should change rather than changing only span background.
Thank you.
With pure css, you can't select a parent element from within a child
element
Approach #01 (Without HTML Modifications):
Without modifying current HTML structure, you can use :before or :after pseudo element to create a fake active state.
You will need to add following CSS:
.no_of_speakers_radio_button {
position: relative;
}
.no_of_speakers_radio_button input:checked + span:before {
background-color: #ebeff1;
position: absolute;
z-index: -1;
content: '';
bottom: 0;
right: 0;
left: 0;
top: 0;
}
.no_of_speakers_radio_button {
margin: 0 auto;
display: flex;
padding: 35px 0px;
text-align: center;
flex-direction: column;
border:thin red solid;
position: relative;
width:100px;
}
.no_of_speakers_radio_button label {
overflow: hidden;
}
.no_of_speakers_radio_button label span {
text-align: center;
font-size: 15px;
margin: auto;
display: block;
}
.no_of_speakers_radio_button input {
position: absolute;
}
.no_of_speakers_radio_button input:checked + span {
background-color: #ebeff1;
text-align: center;
}
.no_of_speakers_radio_button input:checked + span:before {
background-color: #ebeff1;
position: absolute;
z-index: -1;
content: '';
bottom: 0;
right: 0;
left: 0;
top: 0;
}
.no_of_speakers_radio_button input:not(:checked + span) {
background: transparent;
}
.no_of_speakers_radio_button:hover{
background: #ebeff1;
}
<div class="no_of_speakers_radio_button">
<label class="four_speakers">
<input type="radio" name="choose_speaker" class="click">
<span class="font_size_20">4</span>
<span class="font_size_17">Speakers</span>
</label>
</div>
<div class="no_of_speakers_radio_button">
<label class="eight_speakers">
<input type="radio" name="choose_speaker" class="click">
<span class="font_size_20">8</span>
<span class="font_size_17">Speakers</span>
</label>
</div>
Alternate Approach (With HTML Modification):
You can modify your HTML to the code below. The trick is to place original input out of the view and place a fake input[type="radio"] button in place.
HTML:
<div class="no_of_speakers_radio_button">
<input type="radio" id="radio1" name="choose_speaker" class="click">
<label class="four_speakers" for="radio1">
<div>
<span class="font_size_20">4</span>
<span class="fake-radio"></span>
</div>
<span class="font_size_17">Speakers</span>
</label>
</div>
CSS:
.no_of_speakers_radio_button input {
position: absolute;
opacity: 0;
left: -9999px;
top: -9999px;
}
.no_of_speakers_radio_button label .fake-radio {
position: relative;
border: 1px solid black;
border-radius: 100%;
height: 12px;
width: 12px;
}
.no_of_speakers_radio_button label .fake-radio:before {
background-color: #222;
border-radius: 100%;
position: absolute;
opacity: 0;
z-index: 10;
content: '';
bottom: 2px;
right: 2px;
left: 2px;
top: 2px;
}
.no_of_speakers_radio_button input:checked + label .fake-radio:before {
opacity: 1;
}
.no_of_speakers_radio_button {
margin: 0 auto;
border:thin red solid;
position: relative;
overflow: hidden;
width:100px;
}
.no_of_speakers_radio_button label {
padding: 35px 0px;
text-align: center;
flex-direction: column;
position: relative;
cursor: pointer;
display: flex;
height: 100%;
}
.no_of_speakers_radio_button div span {
text-align: center;
font-size: 15px;
margin: auto;
display: inline-block;
vertical-align: middle;
}
.no_of_speakers_radio_button input {
position: absolute;
opacity: 0;
left: -9999px;
top: -9999px;
}
.no_of_speakers_radio_button label .fake-radio {
position: relative;
border: 1px solid black;
border-radius: 100%;
height: 12px;
width: 12px;
}
.no_of_speakers_radio_button label .fake-radio:before {
background-color: #222;
border-radius: 100%;
position: absolute;
opacity: 0;
z-index: 10;
content: '';
bottom: 2px;
right: 2px;
left: 2px;
top: 2px;
}
.no_of_speakers_radio_button input:checked + label {
background-color: #ebeff1;
}
.no_of_speakers_radio_button input:checked + label .fake-radio:before {
opacity: 1;
}
.no_of_speakers_radio_button input:not(:checked + span) {
background: transparent;
}
.no_of_speakers_radio_button label:hover {
background: #ebeff1;
}
<div class="no_of_speakers_radio_button">
<input type="radio" id="radio1" name="choose_speaker" class="click">
<label class="four_speakers" for="radio1">
<div>
<span class="font_size_20">4</span>
<span class="fake-radio"></span>
</div>
<span class="font_size_17">Speakers</span>
</label>
</div>
<div class="no_of_speakers_radio_button">
<input type="radio" id="radio2" name="choose_speaker" class="click">
<label class="eight_speakers" for="radio2">
<div>
<span class="font_size_20">8</span>
<span class="fake-radio"></span>
</div>
<span class="font_size_17">Speakers</span>
</label>
</div>
<div class="no_of_speakers_radio_button">
<input type="radio" id="radio3" name="choose_speaker" class="click">
<label class="eight_speakers" for="radio3">
<div>
<span class="font_size_20">8</span>
<span class="fake-radio"></span>
</div>
<span class="font_size_17">Speakers</span>
</label>
</div>
<div class="no_of_speakers_radio_button">
<input type="radio" id="radio4" name="choose_speaker" class="click">
<label class="eight_speakers" for="radio4">
<div>
<span class="font_size_20">8</span>
<span class="fake-radio"></span>
</div>
<span class="font_size_17">Speakers</span>
</label>
</div>
<div class="no_of_speakers_radio_button">
<input type="radio" id="radio5" name="choose_speaker" class="click">
<label class="eight_speakers" for="radio5">
<div>
<span class="font_size_20">8</span>
<span class="fake-radio"></span>
</div>
<span class="font_size_17">Speakers</span>
</label>
</div>
You can use JQuery for this:
$(document).ready(function() {
$('.no_of_speakers_radio_button input[type="radio"]').click(function() {
$(this).parent().parent().addClass("selected");
});
});
CSS:
.no_of_speakers_radio_button.selected {
background: #ebeff1;
}
Using css there is no click trigger. However you can use javascript for click function to toggle background color
var radio1 = document.getElementsByClassName("click")[0];
var radio2 = document.getElementsByClassName("click")[1];
radio1.addEventListener("click",function(){
radio1.parentNode.parentNode.style.backgroundColor="red";
radio2.parentNode.parentNode.style.backgroundColor="white";
})
radio2.addEventListener("click",function(){
radio2.parentNode.parentNode.style.backgroundColor="red";
radio1.parentNode.parentNode.style.backgroundColor="white";
})
.no_of_speakers_radio_button {
margin: 0 auto;
display: flex;
padding: 35px 0px;
text-align: center;
flex-direction: column;
border:thin red solid;
width:100px;
}
.no_of_speakers_radio_button label {
overflow: hidden;
}
.no_of_speakers_radio_button label span {
text-align: center;
font-size: 15px;
margin: auto;
display: block;
}
.no_of_speakers_radio_button input {
position: absolute;
}
.no_of_speakers_radio_button input:checked + span {
text-align: center;
}
.no_of_speakers_radio_button input:not(:checked + span) {
background: transparent;
}
.no_of_speakers_radio_button:hover{
background: #ebeff1;
}
<div class="no_of_speakers_radio_button" class="four_speakers">
<label >
<input type="radio" name="choose_speaker" class="click" >
<span class="font_size_20">4</span>
<span class="font_size_17">Speakers</span>
</label>
</div>
<div class="no_of_speakers_radio_button">
<label class="eight_speakers">
<input type="radio" name="choose_speaker" class="click">
<span class="font_size_20">8</span>
<span class="font_size_17">Speakers</span>
</label>
</div>
You cannot traverse a parent in css i.e. there is no parent-selector.
However you can modify your html structure and style it in such a way as to achieve what you want here. I have modified your code a little bit here:
.no_of_speakers_radio_button {
margin: 0 auto;
display: flex;
height: 100px;
padding: 0;
text-align: center;
flex-direction: column;
border: thin red solid;
width: 100px;
}
.no_of_speakers_radio_button label {
overflow: hidden;
height: 100%;
display: block;
}
.no_of_speakers_radio_button label span {
text-align: center;
font-size: 15px;
margin: auto;
display: block;
}
.no_of_speakers_radio_button input {
position: absolute;
margin-top: 40px;
}
.no_of_speakers_radio_button input:checked + span {
background-color: #ebeff1;
text-align: center;
}
.no_of_speakers_radio_button input:not(:checked + span) {
background: transparent;
}
.no_of_speakers_radio_button:hover {
background: #ebeff1;
}
.font_size_20 {
height: 60px;
padding-top: 40px;
}
<div class="no_of_speakers_radio_button">
<label class="four_speakers">
<input type="radio" name="choose_speaker" class="click">
<span class="font_size_20">4 <span>Speakers</span> </span>
</label>
</div>
<div class="no_of_speakers_radio_button">
<label class="eight_speakers">
<input type="radio" name="choose_speaker" class="click">
<span class="font_size_20">8 <span>Speakers</span></span>
</label>
</div>
give a radio button a class name and in that class just put change background

horizontally laid out absolute buttons just layering on top of each other

I am setting up toogle button by absolutely positioning labels on top of checkboxes. I need them to horizontally aligned but they are just layering on top of each other.
<ul style="display: block; float: left;">
<li style="display: inline-block;">
<div class="btn_wrapper">
<input type="checkbox" value="1" id="newest" name=""/>
<label class="btn btn-sm btn-default" for="newest">Newest</label>
</div>
</li>
<li style="display: inline-block;">
<div class="btn_wrapper">
<input type="checkbox" value="1" id="popular" name=""/>
<label class="btn btn-sm btn-default" for="popular">Popular</label>
</div>
</li>
<li style="display: inline-block;">
<div class="btn_wrapper">
<input type="checkbox" value="1" id="price" name=""/>
<label class="btn btn-sm btn-default" for="price">Price</label>
</div>
</li>
</ul>
ul {
display: block;
li {
display: inline-block
.btn_wrapper {
position: relative;
clear: both;
label {
display: block;
cursor: pointer;
position: absolute;
top: 5px;
left: 5px;
z-index: 1;
background-color: #CCC;
}
input[type=checkbox], input[type=radio] {
position: absolute;
top: 5px;
left: 5px;
}
input[type=checkbox]:checked + label {
color: $shop_color_text_strong;
}
}
}
}
This is what it looks like:
This is what I ended up going with. Basically adding display: none to my inputs and removing the absolute position from the label it worked out fine.
ul {
display: block;
li.filter_btn {
margin-left: -2px;
}
li {
display: inline-block;
width: auto;
height: 30px;
label {
display: block;
cursor: pointer;
top: 5px;
left: 5px;
z-index: 1;
width: auto;
background-color: #CCC;
}
input[type=checkbox], input[type=radio] {
display: none;
}
input[type=checkbox]:checked + label {
color: $shop_color_text_strong;
}
}
}