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>
Related
I have this page, I'm using fleboxes and I need to the boxes be something like
My code now:
<div class="cardActions">
<h2 style="display:inline">Card Actions | <i class="fas fa-home"></i> </h2> >> eCommerce >> Eletronics
</div>
<div class="filters">
<div class="container column">
<p style="margin-top: 8%; margin-bottom: 5%; margin-left: 4% ;font-weight: bold;"> Multi Range
</p>
<div class="checkBoxes">
<input type="radio" name="multiRange" style="display: inline;" id="radio1">
<label for="radio1">$10</label> <br>
<input type="radio" name="multiRange" id="radio2">
<label for="radio2">$10-$100</label> <br>
<input type="radio" name="multiRange" id="radio3">
<label for="radio3">$100-$500</label> <br>
<input type="radio" name="multiRange" id="radio4">
<label for="radio4">$500</label> <br>
<input type="radio" name="multiRange" id="radio5">
<label for="radio5">All</label>
</div>
<p style="font-weight: bold; margin-top: 10%; margin-left: 4%">
Slider<input type="text" id="amount" readonly style="border:0; font-weight:bold; background-color: #ffab00; margin-left: 35%;">
</p>
<div style="background-color: #091e42; width: 80%; margin-left: 5%; margin-right: 5%; margin-top: 10%; margin-bottom: 10%;"
id="slider-range"></div>
<hr class="solid">
<p style="margin-top: 10%; margin-left: 4% ; margin-bottom: 10%; font-weight: bold;"> Category
</p>
<div class="checkBoxes">
<input type="checkbox" id="check1"> <label for="check1">Teste</label> <br>
<input type="checkbox" id="check2"> <label for="check2">Teste</label> <br>
<input type="checkbox" id="check3"> <label for="check3">Teste</label> <br>
<input type="checkbox" id="check4"> <label for="check4">Teste</label> <br>
<input type="checkbox" id="check5"> <label for="check5">Teste</label> <br>
<input type="checkbox" id="check6"> <label for="check6">Teste</label> <br>
<input type="checkbox" id="check7"> <label for="check7">Teste</label> <br>
<input type="checkbox" id="check8"> <label for="check8">Teste</label> <br>
<input type="checkbox" id="check9"> <label for="check9">Teste</label> <br>
<input type="checkbox" id="check10"> <label for="check10">Teste</label>
</div>
<hr class="solid">
<p style="margin-top: 10%; margin-bottom: 10%; margin-left: 4%; font-weight: bold;">
Brand
</p>
<div class="checkBoxes">
<input type="checkbox" id="check1"> <label for="check1">Teste</label> <br>
<input type="checkbox" id="check2"> <label for="check2">Teste</label> <br>
<input type="checkbox" id="check3"> <label for="check3">Teste</label> <br>
<input type="checkbox" id="check4"> <label for="check4">Teste</label> <br>
<input type="checkbox" id="check5"> <label for="check5">Teste</label> <br>
<input type="checkbox" id="check6"> <label for="check6">Teste</label> <br>
<input type="checkbox" id="check7"> <label for="check7">Teste</label> <br>
<input type="checkbox" id="check8"> <label for="check8">Teste</label> <br>
<input type="checkbox" id="check9"> <label for="check9">Teste</label> <br>
<input type="checkbox" id="check10"> <label for="check10">Teste</label>
</div>
<hr class="solid">
<p style="margin-top: 10%; margin-bottom: 10%; margin-left: 4%; font-weight: bold;">
Rating
</p>
<div class="rating">
<span style="color: white;">☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
</div>
<div class="rating">
<span style="color: white;">☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
</div>
<div class="rating">
<span style="color: white;">☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
</div>
</div> <!--Fim-->
The css:
#import url('https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
text-decoration: none;
font-family: 'Josefin Sans', sans-serif;
}
body{
background-color: #f3f5f9;
}
.wrapper{
display: flex;
position: relative;
}
.wrapper .sidebar{
width: 200px;
height: 100%;
background: #091e42;
padding: 30px 0px;
position: fixed;
}
.wrapper .sidebar h2{
color: #fff;
text-transform: uppercase;
text-align: center;
margin-bottom: 30px;
}
.wrapper .sidebar ul li{
padding: 15px;
border-bottom: 1px solid #bdb8d7;
border-bottom: 1px solid rgba(0,0,0,0.05);
border-top: 1px solid rgba(255,255,255,0.05);
}
.wrapper .sidebar ul li a{
color: #bdb8d7;
display: block;
}
.wrapper .sidebar ul li a .fas{
width: 25px;
}
.wrapper .sidebar ul li:hover{
background-color: #36b37e;
}
.wrapper .sidebar ul li:hover a{
color: #fff;
}
.wrapper .sidebar .social_media{
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
display: flex;
}
.wrapper .sidebar .social_media a{
display: block;
width: 40px;
background: #36b37e;
height: 40px;
line-height: 45px;
text-align: center;
margin: 0 5px;
color: #bdb8d7;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.wrapper .main_content{
width: 100%;
margin-left: 200px;
}
.wrapper .main_content .header{
padding: 20px;
background: #fff;
color: #717171;
border-bottom: 1px solid #e0e4e8;
}
.header{
padding: 20px;
background: #fff;
color: #717171;
border-bottom: 1px solid #e0e4e8;
margin-top: 1%;
margin-bottom: 1%;
margin-left: 2%;
margin-right: 2%;
}
.filters{
width: 18%;
height: 88%;
background-color: #ffab00;
display: flex;
flex-wrap: wrap;
margin-left: 1%;
margin-top: 1%;
border-radius: 10px;
}
.cardActions{
margin-left: 2%;
}
.wrapper .main_content .info{
margin: 20px;
color: #717171;
line-height: 25px;
}
.wrapper .main_content .info div{
margin-bottom: 20px;
}
#media (max-height: 500px){
.social_media{
display: none !important;
}
}
.topIcons{
margin-right: 2%;
}
.container {
margin: 0 auto;
display: flex;
}
.column {
flex-direction: column;
height: fit-content;
width: 100%;
justify-content: flex-start;
}
input[type="radio"]{
margin-left: 4%;
margin-bottom: 5%;
}
input[type="checkbox"]{
margin-left: 4%;
margin-bottom: 5%;
}
hr.solid {
border-top: 1px solid white;
margin-left: 4%;
margin-right: 4%;
}
/* Products */
.products{
width: 78%;
height: 13%;
background-color: #091e42;
flex-direction: row;
display: block;
margin-left: 50%;
}
/* Rating */
/*
Ratings Stars
(with as little code as possible)
*/
.rating {
unicode-bidi: bidi-override;
direction: rtl;
text-align: center;
color: white;
font-size: x-large;
}
.rating > span {
display: inline-block;
position: relative;
width: 1.1em;
}
.rating > span:hover,
.rating > span:hover ~ span {
color: transparent;
}
.rating > span:hover:before,
.rating > span:hover ~ span:before {
content: "\2605";
position: absolute;
left: 0;
color: gold;
}
Right now I cant manage to make this, can someone help me?
I need to create boxes like the red ones in the picture.
I tried everything and still can't make this work.
Is there something i'm missing or making wrong?
All you need to do is, put a sibling to your filter div and make their parent display: flex; one did this, then give the remaining width to your right side red-bordered section. for example, you have give filter width: 18%; margin-left: 1%; which makes it 19% and now you have 81% in hand, so distribute it accordingly in width and margin to right side div. Apply other stylings as per you need.
#import url('https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
text-decoration: none;
font-family: 'Josefin Sans', sans-serif;
}
body{
background-color: #f3f5f9;
}
.wrapper{
display: flex;
position: relative;
}
.wrapper .sidebar{
width: 200px;
height: 100%;
background: #091e42;
padding: 30px 0px;
position: fixed;
}
.wrapper .sidebar h2{
color: #fff;
text-transform: uppercase;
text-align: center;
margin-bottom: 30px;
}
.wrapper .sidebar ul li{
padding: 15px;
border-bottom: 1px solid #bdb8d7;
border-bottom: 1px solid rgba(0,0,0,0.05);
border-top: 1px solid rgba(255,255,255,0.05);
}
.wrapper .sidebar ul li a{
color: #bdb8d7;
display: block;
}
.wrapper .sidebar ul li a .fas{
width: 25px;
}
.wrapper .sidebar ul li:hover{
background-color: #36b37e;
}
.wrapper .sidebar ul li:hover a{
color: #fff;
}
.wrapper .sidebar .social_media{
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
display: flex;
}
.wrapper .sidebar .social_media a{
display: block;
width: 40px;
background: #36b37e;
height: 40px;
line-height: 45px;
text-align: center;
margin: 0 5px;
color: #bdb8d7;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.wrapper .main_content{
width: 100%;
margin-left: 200px;
}
.wrapper .main_content .header{
padding: 20px;
background: #fff;
color: #717171;
border-bottom: 1px solid #e0e4e8;
}
.header{
padding: 20px;
background: #fff;
color: #717171;
border-bottom: 1px solid #e0e4e8;
margin-top: 1%;
margin-bottom: 1%;
margin-left: 2%;
margin-right: 2%;
}
.filters{
width: 18%;
height: 88%;
background-color: #ffab00;
display: flex;
flex-wrap: wrap;
margin-left: 1%;
margin-top: 1%;
border-radius: 10px;
}
.cardActions{
margin-left: 2%;
}
.wrapper .main_content .info{
margin: 20px;
color: #717171;
line-height: 25px;
}
.wrapper .main_content .info div{
margin-bottom: 20px;
}
#media (max-height: 500px){
.social_media{
display: none !important;
}
}
.topIcons{
margin-right: 2%;
}
.container {
margin: 0 auto;
display: flex;
}
.column {
flex-direction: column;
height: fit-content;
width: 100%;
justify-content: flex-start;
}
input[type="radio"]{
margin-left: 4%;
margin-bottom: 5%;
}
input[type="checkbox"]{
margin-left: 4%;
margin-bottom: 5%;
}
hr.solid {
border-top: 1px solid white;
margin-left: 4%;
margin-right: 4%;
}
/* Products */
.atul {
display: flex;
}
.rightSide {
display: flex;
flex-direction: column;
padding: 10px;
border: 1px solid red;
border-radius: 4px;
width: 80%;
margin-left: 1%;
}
.subSection{
min-height: 50px;
height: 100%;
margin-bottom: 20px;
padding: 10px;
border: 1px solid red;
border-radius: 4px;
}
.products{
width: 78%;
height: 13%;
background-color: #091e42;
flex-direction: row;
display: block;
margin-left: 50%;
}
/* Rating */
/*
Ratings Stars
(with as little code as possible)
*/
.rating {
unicode-bidi: bidi-override;
direction: rtl;
text-align: center;
color: white;
font-size: x-large;
}
.rating > span {
display: inline-block;
position: relative;
width: 1.1em;
}
.rating > span:hover,
.rating > span:hover ~ span {
color: transparent;
}
.rating > span:hover:before,
.rating > span:hover ~ span:before {
content: "\2605";
position: absolute;
left: 0;
color: gold;
}
<div class="cardActions">
<h2 style="display:inline">Card Actions | <i class="fas fa-home"></i> </h2> >> eCommerce >> Eletronics
</div>
<section class="atul">
<div class="filters">
<div class="container column">
<p style="margin-top: 8%; margin-bottom: 5%; margin-left: 4% ;font-weight: bold;"> Multi Range
</p>
<div class="checkBoxes">
<input type="radio" name="multiRange" style="display: inline;" id="radio1">
<label for="radio1">$10</label> <br>
<input type="radio" name="multiRange" id="radio2">
<label for="radio2">$10-$100</label> <br>
<input type="radio" name="multiRange" id="radio3">
<label for="radio3">$100-$500</label> <br>
<input type="radio" name="multiRange" id="radio4">
<label for="radio4">$500</label> <br>
<input type="radio" name="multiRange" id="radio5">
<label for="radio5">All</label>
</div>
<p style="font-weight: bold; margin-top: 10%; margin-left: 4%">
Slider<input type="text" id="amount" readonly style="border:0; font-weight:bold; background-color: #ffab00; margin-left: 35%;">
</p>
<div style="background-color: #091e42; width: 80%; margin-left: 5%; margin-right: 5%; margin-top: 10%; margin-bottom: 10%;" id="slider-range"></div>
<hr class="solid">
<p style="margin-top: 10%; margin-left: 4% ; margin-bottom: 10%; font-weight: bold;"> Category
</p>
<div class="checkBoxes">
<input type="checkbox" id="check1"> <label for="check1">Teste</label> <br>
<input type="checkbox" id="check2"> <label for="check2">Teste</label> <br>
<input type="checkbox" id="check3"> <label for="check3">Teste</label> <br>
<input type="checkbox" id="check4"> <label for="check4">Teste</label> <br>
<input type="checkbox" id="check5"> <label for="check5">Teste</label> <br>
<input type="checkbox" id="check6"> <label for="check6">Teste</label> <br>
<input type="checkbox" id="check7"> <label for="check7">Teste</label> <br>
<input type="checkbox" id="check8"> <label for="check8">Teste</label> <br>
<input type="checkbox" id="check9"> <label for="check9">Teste</label> <br>
<input type="checkbox" id="check10"> <label for="check10">Teste</label>
</div>
<hr class="solid">
<p style="margin-top: 10%; margin-bottom: 10%; margin-left: 4%; font-weight: bold;">
Brand
</p>
<div class="checkBoxes">
<input type="checkbox" id="check1"> <label for="check1">Teste</label> <br>
<input type="checkbox" id="check2"> <label for="check2">Teste</label> <br>
<input type="checkbox" id="check3"> <label for="check3">Teste</label> <br>
<input type="checkbox" id="check4"> <label for="check4">Teste</label> <br>
<input type="checkbox" id="check5"> <label for="check5">Teste</label> <br>
<input type="checkbox" id="check6"> <label for="check6">Teste</label> <br>
<input type="checkbox" id="check7"> <label for="check7">Teste</label> <br>
<input type="checkbox" id="check8"> <label for="check8">Teste</label> <br>
<input type="checkbox" id="check9"> <label for="check9">Teste</label> <br>
<input type="checkbox" id="check10"> <label for="check10">Teste</label>
</div>
<hr class="solid">
<p style="margin-top: 10%; margin-bottom: 10%; margin-left: 4%; font-weight: bold;">
Rating
</p>
<div class="rating">
<span style="color: white;">☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
</div>
<div class="rating">
<span style="color: white;">☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
</div>
<div class="rating">
<span style="color: white;">☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
<span>☆</span>
</div>
</div>
</div>
<div class="rightSide">
<div class="subSection"></div>
<div class="subSection"></div>
<div class="subSection"></div>
<div class="subSection"></div>
</div>
</section>
<div id='listpage'> //here it should be flex-direction:column
<div class='list'>
<div></div>
<div></div>
<div></div>
</div>
<div class='list'>
<div></div>
<div></div>
<div></div>
</div>
</div>
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>
I got my general CSS code for the tool tips from here, but tried tailoring it to my needs:
/* The tooltip stuff */
.tooltip
{
top: -5px;
z-index: 1;
display: inline-block;
width: 200px;
background-color: #e55;
padding: 5px 0;
position: absolute;
color: #fff;
border-radius: 6px;
margin-left: 6px;
}
.tooltip::after
{
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent #e55 transparent transparent;
}
For some reason, however, when I test this with a dummy tool tip, it not only is missing its arrow, but it isn't even on the row that needs it! Even worse, the tool tips, for some reason, sit on top each other!
The HTML code to the main div is as follows:
<div class="main pageCenter">
<form id="newUserRegistration">
<span class="row">
<label for="firstName" class="half">First name</label>
<input type="text" id="firstName" class="half">
<span class="tooltip">text</span>
</input>
</span>
<span class="rowTight">
<label for="lastName" class="half">Last name</label>
<input type="text" id="lastName" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="empIDNumber" class="half">Employee ID number</label>
<input type="text" class="number" class="half">
<span class="tooltip">other text</span>
</input>
</span>
<span class="rowTight">
<label for="dept" class="half">Department</label>
<select id="dept" class="half">
<!-- To be populated with data from a Mustache template-->
{{#departments}}
<option id="{{departmentHTMLID}}">{{departmentName}}</option>
{{/departments}}
</select>
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="manager" class="half">Manager name</label>
<input type="text" id="manager" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="username" class="half">Username</label>
<input type="text" id="username" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="password" class="half">Password</label>
<input type="text" id="password" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="confirmPassword" class="half">Confirm password</label>
<input type="text" id="confirmPassword" class="half">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="rowTight">
<label for="email" class="half" title="A confirmation email will be sent to this e-mail address.">E-mail address</label>
<input type="email" class="half" title="A confirmation email will be sent to this e-mail address.">
<span class="hidden tooltip"></span>
</input>
</span>
<span class="right row buttonRow">
<input type="reset" class="right" value="Clear"/>
<input type="submit" class="right" value="Submit" />
</span>
</form>
</div>
and the rest of my CSS code is as follows:
/* Fractional-width classes */
.fiveSixths { width: 83.3333333333333333%; }
.fourFifths { width: 80%; }
.threeFourths { width: 75%; }
.twoThirds { width: 66.6666666666666667%; }
.threeFifths { width: 60%; }
.half { width: 50%; }
.twoFifths { width: 40%; }
.third { width: 33.3333333333333333%; }
.fourth { width: 25%;}
.fifth { width: 20%; }
.sixth { width: 16.6666666666666667%; }
.main
{
border: 2px solid orange;
border-radius: 5px;
box-shadow: 0px 0px 100px orange;
}
.main > *
{
padding: 10px;
}
.pageCenter
{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
input[type="text"],input[type="password"], input[type="email"]
{
border-left-style: none !important;
border-right-style: none !important;
border-top-style: none !important;
border-bottom-color: #888 !important;
}
input[type="submit"],input[type="reset"],button
{
height: 25px;
width: 100px;
border-width: 1px;
border-radius: 3px;
}
input[type="submit"]
{
background-color: orange;
border-color: orange;
}
input[type="submit"]:hover
{
background-color: #fb0;
}
.hidden
{
display: none;
visibility: hidden;
}
.row:not(.buttonRow),.rowTight:not(.buttonRow)
{
display: block;
width: 100%;
}
.row
{
margin-top: 10px;
margin-bottom: 10px;
}
.rowTight
{
margin-top: 5px;
margin-bottom: 5px;
}
.right
{
float: right;
}
.number
{
text-align: right;
}
.main
{
min-width: 450px;
width: 50%;
}
#formContainer
{
padding: 20px;
}
#newUserRegistration > *:not(input[type="submit"])
{
width: 100%;
overflow: hidden;
}
#newUserRegistration > * > *
{
float: left;
}
#newUserRegistration > * > *:not(:first-child):not([type="submit"]):not([type="reset"]):not(button)
{
margin-left: -4px;
}
#newUserRegistration span
{
overflow: auto;
}
I've been trying to play with this for a while, but couldn't get the tool tips to position properly, nor for them to not be on top each other.
Although position: relative was declared on your containing elements, the overflow: auto property declared in addition prevented any overflow of the element's contents being visible, and so the tooltip could not be properly observed because of this.
To address this:
Remove the float: left rules declared on nested elements by the
following rule: #newUserRegistration > * > * - the global
selectors (*) for this rule causes havoc in this case, and should
be avoided, for better practice use more specific selectors and
only style what you are required to.
Only float your form fields right, with more specific selectors,
e.g:
#newUserRegistration select, #newUserRegistration input {
float: right;
}
You are no longer required to clear floats using overflow: auto on
the containing parent element, allowing your absolutely positioned
tooltips to remain visible. In addition, a left positioning property has been added to your tooltips.
Updated JSFiddle
Code Snippet Demonstration:
/* The tooltip stuff */
.tooltip
{
top: -5px;
left: 100%; /* Added - position absolute tooltip relative to parent row */
z-index: 1;
display: inline-block;
width: 200px;
background-color: #e55;
padding: 5px 0;
position: absolute;
color: #fff;
border-radius: 6px;
margin-left: 6px;
}
.tooltip::after
{
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent #e55 transparent transparent;
}
/* Fractional-width classes */
.fiveSixths { width: 83.3333333333333333%; }
.fourFifths { width: 80%; }
.threeFourths { width: 75%; }
.twoThirds { width: 66.6666666666666667%; }
.threeFifths { width: 60%; }
.half { width: 50%; }
.twoFifths { width: 40%; }
.third { width: 33.3333333333333333%; }
.fourth { width: 25%;}
.fifth { width: 20%; }
.sixth { width: 16.6666666666666667%; }
.main
{
border: 2px solid orange;
border-radius: 5px;
box-shadow: 0px 0px 100px orange;
}
.main > *
{
padding: 10px;
}
.pageCenter
{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
input[type="text"],input[type="password"], input[type="email"]
{
border-left-style: none !important;
border-right-style: none !important;
border-top-style: none !important;
border-bottom-color: #888 !important;
}
input[type="submit"],input[type="reset"],button
{
height: 25px;
width: 100px;
border-width: 1px;
border-radius: 3px;
}
input[type="submit"]
{
background-color: orange;
border-color: orange;
}
input[type="submit"]:hover
{
background-color: #fb0;
}
.hidden
{
display: none;
visibility: hidden;
}
.row:not(.buttonRow),.rowTight:not(.buttonRow)
{
display: block;
position: relative;
width: 100%;
}
.row
{
margin-top: 10px;
margin-bottom: 10px;
}
.rowTight
{
margin-top: 5px;
margin-bottom: 5px;
}
.right
{
float: right;
}
.number
{
text-align: right;
}
.main
{
min-width: 450px;
width: 50%;
}
#formContainer
{
padding: 20px;
}
#newUserRegistration > *:not(input[type="submit"])
{
width: 100%;
overflow: hidden;
}
#newUserRegistration > * > * /* this is causing mayhem, selectors should be more specific */
{
float: left;
}
/* ...like this */
#newUserRegistration select, #newUserRegistration input {
float: right;
}
#newUserRegistration label {
float: none;
}
#newUserRegistration > * > *:not(:first-child):not([type="submit"]):not([type="reset"]):not(button)
{
margin-left: -4px;
}
/* not necessary, since you no longer need to clear nested elements that are floated
#newUserRegistration span
{
overflow: auto;
} */
<div class="main pageCenter">
<form id="newUserRegistration">
<span class="row">
<label for="firstName" class="half">First name</label>
<input type="text" id="firstName" class="half" />
<span class="tooltip">text</span>
</span>
<span class="rowTight">
<label for="lastName" class="half">Last name</label>
<input type="text" id="lastName" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="empIDNumber" class="half">Employee ID number</label>
<input type="text" class="number half" />
<span class="tooltip">other text</span>
</span>
<span class="rowTight">
<label for="dept" class="half">Department</label>
<select id="dept" class="half">
<!-- To be populated with data from a Mustache template-->
{{#departments}}
<option id="{{departmentHTMLID}}">{{departmentName}}</option>
{{/departments}}
</select>
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="manager" class="half">Manager name</label>
<input type="text" id="manager" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="username" class="half">Username</label>
<input type="text" id="username" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="password" class="half">Password</label>
<input type="text" id="password" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="confirmPassword" class="half">Confirm password</label>
<input type="text" id="confirmPassword" class="half" />
<span class="hidden tooltip"></span>
</span>
<span class="rowTight">
<label for="email" class="half" title="A confirmation email will be sent to this e-mail address.">E-mail address</label>
<input type="email" class="half" title="A confirmation email will be sent to this e-mail address." />
<span class="hidden tooltip"></span>
</span>
<span class="right row buttonRow">
<input type="submit" class="right" value="Submit" />
<input type="reset" class="right" value="Clear"/>
</span>
</form>
</div>
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
I've built a modified tab-chart. When you click on the tabs on the left hand side, they switch the content on the right. The only problem is the main content div on the right, even with a width of 100% is only going about a third of the way across the screen. Any ideas why?
* {
padding: 0;
margin: 0;
}
#container {
display: block;
height: 100%;
width: 100%;
}
#topBar1 {
height: 55px;
width: 100%;
background-color: #FAFAFA;
border-bottom: 1px solid #d9d9d9;
display: block;
position: relative;
z-index: 2;
}
#topBar2 {
height: 22px;
width: 100%;
background-color: #FAFAFA;
display: block;
border-radius: 11%;
box-shadow: 0 6px 10px -2.5px #ccc;
position: relative;
z-index: 2;
transition: all;
}
main {
display: block;
background-color: #EEEEEE;
height: 1000px;
width: 100%;
position: relative;
z-index: 1;
top: -5px;
}
nav {
height: 100%;
width: 261px;
}
nav::after {
height: 100%;
width: 1px;
content: "";
display: block;
background: #d9d9d9;
position: relative;
left: 260px;
top: -1000px;
}
input[type=radio] {
display: none;
}
.tabs {
list-style: none;
position: relative;
//border: 1px solid #ccc;
width: 260px;
height: 100%;
top: 15px;
}
.tabs li {
font-family: Roboto, sans-serif;
font-size: 13px;
padding: 10px 20px 20px 60px;
color: #222222;
//border: 1px solid #ccc;
background-color: none;
transition: all .2s ease-in-out;
}
.tabs li:hover {
background-color: #d9d9d9;
}
.tabs li:active {
background-color: #d9d9d9;
}
.tabs label {
display: block;
position: relative;
cursor: pointer;
top: 6px;
}
.tab-content {
position: absolute;
display: none;
z-index: 2;
height: 100%;
width: 100%;
left: 261px;
top: 0;
border: 1px solid #ccc;
}
[id^=tab]:checked~[class^=tab-content] {
display: block;
}
.contentItem {
//border: 1px solid #ccc;
height: 38px;
width: 200px;
margin-left: 10px;
margin-top: 10px;
margin-bottom: 20px;
margin-left: 10px;
background-color: #FAFAFA;
box-shadow: .5px 2px 6px #ccc;
float: left;
}
.documentIcon {
height: 30px;
width: 30px;
border: 1px solid #ccc;
margin: 3px;
margin-left: 5px;
margin-right: 10px;
float: left;
}
.contentText {
font-family: Roboto, sans-serif;
font-size: 12px;
color: #222222;
line-height: 3;
}
<div id="container">
<div id="topBar1"></div>
<!--topBar-->
<div id="topBar2"></div>
<!--topBar2-->
<main>
<nav>
<ul class="tabs">
<li>
<input type="radio" name="tabs" id="tab-1" checked />
<label for="tab-1">Staff Directory</label>
<div class="tab-content" id="tab-content-1">
<div class="contentItem" id="ci1">
<img src="" alt="" class="documentIcon" />
<p class="contentText">Telephone Extension List</p>
</div>
</div>
<!--tab-content-->
</li>
<li>
<input type="radio" name="tabs" id="tab-2" />
<label for="tab-2">How-To Guides</label>
<div class="tab-content" id="tab-content-2">
<p>Put Tab 2 Content here</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab-3" />
<label for="tab-3">OECTA Calendar</label>
<div class="tab-content" id="tab-content3">
<p>Put tab content 3 here</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab-4" />
<label for="tab-4">Finance</label>
<div class="tab-content" id="tab-content-4">
<p>Put tab content for 4 here</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab-5" />
<label for="tab-5">Directories and Contact Lists</label>
<div class="tab-content" id="tab-content-5">
<p>Put Tab 5 content here</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab-6" />
<label for="tab-6">Upcoming Meetings</label>
<div class="tab-content" id="tab-content-6">
<p>Put tab 6 content here</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab-7" />
<label for="tab-7">Manuals and Handbooks</label>
<div class="tab-content" id="tab-content-7">
<p>Tab Content 7</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab-8" />
<label for="tab-8">Information and Forms</label>
<div class="tab-content" id="tab-content-8">
<p>Tab Content 8</p>
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab-9" />
<label for="tab-9">Visitor Information</label>
<div class="tab-content" id="tab-content-9">
<p>Tab Content 9</p>
</div>
</li>
</ul>
</nav>
</main>
</div>
You looking for something like this? https://jsfiddle.net/csgn6051/9/
.tabs
{
width: calc(100% - 270px);
}