Prevent flexbox overflow - css

I'm making a series of quiz questions and am utilizing flexboxes for each answer choice.
Ultimately, I'd like each row banded, but the answer choices (the flexboxes) are overflowing outside of the "band."
I want the answer choices to not wrap, so I'm not sure how to accomplish this.
I made a fiddle:
https://jsfiddle.net/4L8e2s9r/1/
input[type="radio"] {
display: none;
}
input[type="radio"]:checked+.quizlabel {
border: 2px solid #0052e7;
transition: .1s;
background-color: #0052e7;
box-shadow: 2px 2px 3px #c8c8c8;
color: #fff;
}
input[type="radio"]:hover+.quizlabel {
border: 2px solid #0052e7;
}
.quizlabel {
padding: 5px;
margin: 5px;
border: 2px solid #484848;
color: #000;
font-family: sans-serif;
font-size: 14px;
}
.quizform>div {
padding: 10px;
margin-top: 10px;
}
.quizlabel:first-of-type {
margin-left: 0;
}
.quizform {
padding: 10px;
font-family: sans-serif;
}
.quizform p {
margin: 2px;
font-weight: Bold;
}
.quizrow:nth-of-type(odd) {
background-color: #e2e3e5;
}
.quizlist {
display: flex;
justify-content: flex-start;
flex-direction: row;
flex-wrap: nowrap;
margin: 0 padding: 0;
}
#result_div {
font-family: sans-serif;
color: #000;
border: 3px solid #000;
padding: 10px;
}
#result_div p {
color: #000;
}
.quiz-submit {
font-family: sans-serif;
color: #fff;
background-color: #000;
padding: 10px;
cursor: pointer;
}
.quiz-submit:hover {
background-color: #0052e7;
}
<form name="quizform" class="quizform">
<div class="quizrow">
<p>Q1</p>
<div class="quizlist">
<input type="radio" name="q1" value="1" id="q1-1"><label for="q1-1" class="quizlabel"><span>Strongly Disagree</span></label>
<input type="radio" name="q1" value="2" id="q1-2"><label for="q1-2" class="quizlabel"><span>Disagree</span></label>
<input type="radio" name="q1" value="3" id="q1-3"><label for="q1-3" class="quizlabel">Neutral</label>
<input type="radio" name="q1" value="4" id="q1-4"><label for="q1-4" class="quizlabel">Agree</label>
<input type="radio" name="q1" value="5" id="q1-5"><label for="q1-5" class="quizlabel">Strongly Agree</label>
</div>
</div>
<div class="quizrow">
<p>Q2</p>
<div class="quizlist">
<input type="radio" name="q2" value="1" id="q2-1"><label for="q-1" class="quizlabel"><span>Strongly Disagree</span></label>
<input type="radio" name="q2" value="2" id="q2-2"><label for="q1-2" class="quizlabel"><span>Disagree</span></label>
<input type="radio" name="q2" value="3" id="q2-3"><label for="q1-3" class="quizlabel">Neutral</label>
<input type="radio" name="q2" value="4" id="q2-4"><label for="q1-4" class="quizlabel">Agree</label>
<input type="radio" name="q2" value="5" id="q2-5"><label for="q1-5" class="quizlabel">Strongly Agree</label>
</div>
</div>
<p></p>
<button type="submit" class="quiz-submit">Submit</button>
</form>

If you really don't want to wrap you can use #media queries to change flex-direction of your quizlist class to column.
input[type="radio"] {
display: none;
}
input[type="radio"]:checked+.quizlabel {
border: 2px solid #0052e7;
transition: .1s;
background-color: #0052e7;
box-shadow: 2px 2px 3px #c8c8c8;
color: #fff;
}
input[type="radio"]:hover+.quizlabel {
border: 2px solid #0052e7;
}
.quizlabel {
padding: 5px;
margin: 5px;
border: 2px solid #484848;
color: #000;
font-family: sans-serif;
font-size: 14px;
}
.quizform>div {
padding: 10px;
margin-top: 10px;
}
.quizlabel:first-of-type {
margin-left: 0;
}
.quizform {
padding: 10px;
font-family: sans-serif;
}
.quizform p {
margin: 2px;
font-weight: Bold;
}
.quizrow:nth-of-type(odd) {
background-color: #e2e3e5;
}
.quizlist {
display: flex;
justify-content: flex-start;
flex-direction: row;
flex-wrap: nowrap;
margin: 0 padding: 0;
}
#media (max-width: 500px){
.quizlist {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
text-align: center;
}
}
#result_div {
font-family: sans-serif;
color: #000;
border: 3px solid #000;
padding: 10px;
}
#result_div p {
color: #000;
}
.quiz-submit {
font-family: sans-serif;
color: #fff;
background-color: #000;
padding: 10px;
cursor: pointer;
}
.quiz-submit:hover {
background-color: #0052e7;
}
<form name="quizform" class="quizform">
<div class="quizrow">
<p>Q1</p>
<div class="quizlist">
<input type="radio" name="q1" value="1" id="q1-1"><label for="q1-1" class="quizlabel"><span>Strongly Disagree</span></label>
<input type="radio" name="q1" value="2" id="q1-2"><label for="q1-2" class="quizlabel"><span>Disagree</span></label>
<input type="radio" name="q1" value="3" id="q1-3"><label for="q1-3" class="quizlabel">Neutral</label>
<input type="radio" name="q1" value="4" id="q1-4"><label for="q1-4" class="quizlabel">Agree</label>
<input type="radio" name="q1" value="5" id="q1-5"><label for="q1-5" class="quizlabel">Strongly Agree</label>
</div>
</div>
<div class="quizrow">
<p>Q2</p>
<div class="quizlist">
<input type="radio" name="q2" value="1" id="q2-1"><label for="q-1" class="quizlabel"><span>Strongly Disagree</span></label>
<input type="radio" name="q2" value="2" id="q2-2"><label for="q1-2" class="quizlabel"><span>Disagree</span></label>
<input type="radio" name="q2" value="3" id="q2-3"><label for="q1-3" class="quizlabel">Neutral</label>
<input type="radio" name="q2" value="4" id="q2-4"><label for="q1-4" class="quizlabel">Agree</label>
<input type="radio" name="q2" value="5" id="q2-5"><label for="q1-5" class="quizlabel">Strongly Agree</label>
</div>
</div>
<p></p>
<button type="submit" class="quiz-submit">Submit</button>
<div> </div>
<div> </div>
<div id="result_div" style="display:none;">
<p id="result_text"></p>
</div>
</form>

I think this is what you're aiming for?
The boxes weren't getting smaller because of the text inside of them, so you needed to add flex-wrap:wrap; to the .quizlist so that way they would go onto the next row. You also needed to add a flex and flex-grow to specify the widths you want them to flex to. If you don't want them to increase widths to match that of the screen size, then remove the flex-grow.
input[type="radio"] {
display: none;
}
input[type="radio"]:checked+.quizlabel {
border: 2px solid #0052e7;
transition: .1s;
background-color: #0052e7;
box-shadow: 2px 2px 3px #c8c8c8;
color: #fff;
}
input[type="radio"]:hover+.quizlabel {
border: 2px solid #0052e7;
}
.quizlabel {
padding: 5px;
margin: 5px;
border: 2px solid #484848;
color: #000;
font-family: sans-serif;
font-size: 14px;
flex: 0 0 5%;
flex-grow: 1;
}
.quizform>div {
padding: 10px;
margin-top: 10px;
}
.quizlabel:first-of-type {
margin-left: 0;
}
.quizform {
padding: 10px;
font-family: sans-serif;
}
.quizform p {
margin: 2px;
font-weight: Bold;
}
.quizrow:nth-of-type(odd) {
background-color: #e2e3e5;
}
.quizlist {
display: flex;
justify-content: flex-start;
flex-direction: row;
flex-wrap: wrap;
margin: 0;
padding: 0;
}
#result_div {
font-family: sans-serif;
color: #000;
border: 3px solid #000;
padding: 10px;
}
#result_div p {
color: #000;
}
.quiz-submit {
font-family: sans-serif;
color: #fff;
background-color: #000;
padding: 10px;
cursor: pointer;
}
.quiz-submit:hover {
background-color: #0052e7;
}
<form name="quizform" class="quizform">
<div class="quizrow">
<p>Q1</p>
<div class="quizlist">
<input type="radio" name="q1" value="1" id="q1-1"><label for="q1-1" class="quizlabel"><span>Strongly Disagree</span></label>
<input type="radio" name="q1" value="2" id="q1-2"><label for="q1-2" class="quizlabel"><span>Disagree</span></label>
<input type="radio" name="q1" value="3" id="q1-3"><label for="q1-3" class="quizlabel">Neutral</label>
<input type="radio" name="q1" value="4" id="q1-4"><label for="q1-4" class="quizlabel">Agree</label>
<input type="radio" name="q1" value="5" id="q1-5"><label for="q1-5" class="quizlabel">Strongly Agree</label>
</div>
</div>
<div class="quizrow">
<p>Q2</p>
<div class="quizlist">
<input type="radio" name="q2" value="1" id="q2-1"><label for="q-1" class="quizlabel"><span>Strongly Disagree</span></label>
<input type="radio" name="q2" value="2" id="q2-2"><label for="q1-2" class="quizlabel"><span>Disagree</span></label>
<input type="radio" name="q2" value="3" id="q2-3"><label for="q1-3" class="quizlabel">Neutral</label>
<input type="radio" name="q2" value="4" id="q2-4"><label for="q1-4" class="quizlabel">Agree</label>
<input type="radio" name="q2" value="5" id="q2-5"><label for="q1-5" class="quizlabel">Strongly Agree</label>
</div>
</div>
<p></p>
<button type="submit" class="quiz-submit">Submit</button>
</form>

Related

not able to select all the when checked

hope i can get some help.
First, i'm new in to programming. I found a great tuto on youtube and wanted to recopied it. It works almost fine, but for some reason I don't get the same result.
When the mouse goes hover the stars it only shows some part of it and when i checked ex. 4 stars it only shows the last part of the 4th star.
thans for the help
HTML:
enter image description here
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rating Star</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" integrity="sha512-5A8nwdMOWrSz20fDsjczgUidUBR8liPYU+WymTZP1lmY9G6Oc7HlZv156XqnsgNUzTyMefFTcsFH/tnJE/+xBg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h2>5 Star Skills Rating Bar</h2>
<div class="skills">
<h3 class="name"> Html</h3>
<div class="rating">
<input type="radio" name="html">
<input type="radio" name="html">
<input type="radio" name="html">
<input type="radio" name="html">
<input type="radio" name="html">
<input type="radio" name="html">
<input type="radio" name="html">
<input type="radio" name="html">
<input type="radio" name="html">
<input type="radio" name="html">
</div>
</div>
<div class="skills">
<h3 class="name"> CSS</h3>
<div class="rating">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
<input type="radio" name="CSS">
</div>
</div>
<div class="skills">
<h3 class="name"> Javascript</h3>
<div class="rating">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
<input type="radio" name="Javascript">
</div>
</div>
<div class="skills">
<h3 class="name"> Photoshop</h3>
<div class="rating">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
<input type="radio" name="Photoshop">
</div>
</div>
<!-- <p style="color:white">Fournir un commentaire:</p>
<textarea name="message" id="" cols="30" rows="10"></textarea> -->
</div>
</div>
</body>
</html>
```
here the css:
#import url('https://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700,800,900&display=swap');
*
{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body
{
display:flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #0a2b3c;
}
.container
{
position: relative;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
padding: 30px;
border-radius: 10px;
box-shadow: -1px -1px 2px rgba(255, 255, 255,0.25),
inset 2px 2px 2px rgba(255, 255, 255,0.25),
8px 30px 30px rgba(0, 0, 0, 0.4),
inset -2px -2px 5px rgba(0, 0, 0, 0.3);
}
.container h2
{
margin-bottom: 10px;
font-weight: 500px;
color: #1f9cff;
}
.container .skills
{
display: flex;
justify-content: center;
align-items: center;
margin: 10px 0;
padding-right: 10px;
box-shadow: -1px -1px 2px rgba(255, 255, 255,0.25),
inset 2px 2px 2px rgba(255, 255, 255,0.25),
8px 30px 30px rgba(0, 0, 0, 0.4),
inset -2px -2px 5px rgba(0, 0, 0, 0.3);
transition: 0.5s;
}
.container:hover .skills
{
filter: blur(0px);
opacity: 0.2;
}
.container .skills:hover
{
filter: blur(0px);
opacity: 2;
}
.container .skills h3
{
min-width: 180px;
text-align: right;
padding-right: 20px;
color:#fff;
font-size: 20px;
font-weight: 400px;
letter-spacing: 2px;
}
.container .skills .rating
{
position: relative;
display: flex;
margin: 10px;
flex-direction: row-reverse;
}
.container .skills .rating input
{
position: relative;
width: 20px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
-webkit-appearance: none;
appearance: none;
overflow: hidden;
}
.container .skills .rating input::before
{
content: '\f005 ';
position: absolute;
font-family: fontAwesome;
font-size: 34px;
position: absolute;
left: 4px;
color:#030b0f;
transition: 0.5s;
}
.container .skills .rating input:nth-child(2n + 1)::before
{
right: 4px;
left: initial;
}
.container .skills .rating input:hover ∼ input::before,
.container .skills .rating input:hover::before
{
color:#1f9cff;
}
here the result:
I tried like 3x the same video

How to put a textarea and text inut over each other next to a radio?

I have to make a website homework and I have a problem with positioning a text input and a text area above each other next to a bigger radio box.
I've seen a similar post on stack overflow but my problem wasn't solved with that.I'd need something like this: https://i.stack.imgur.com/MUApR.png
.szavazas {
margin-left: 5%;
margin-top: 3%;
}
.raddio {
float: left;
width: 200px;
margin-bottom: 5%;
color: white;
background: green;
border-radius: 8px;
border: 1px solid #003300;
text-align: left;
box-shadow: 0 0 2px 1px black;
height: 350px;
}
input[type="radio"] {
text-align: left;
margin-top: 10px;
margin-bottom: 10px;
}
.velemeny {
float: left;
box-shadow: 0 0 2px 1px black;
width: 200px;
height: 175px;
}
.textin {
float: left;
border: 1px solid black;
background-color: #003300;
color: white;
width: 200px;
height: 165px;
}
<div class="szavazas">
<form class="raddio" action="/action_page.php">
<input type="radio" name="noveny" value="Nagy Flamingóvirág">Nagy Flamingóvirág<br>
<input type="radio" name="noveny" value="Gerbera">Gerbera<br>
<input type="radio" name="noveny" value="Szobai Futóka">Szobai Futóka<br>
<input type="radio" name="noveny" value="Rákvirág">Rákvirág<br>
<input type="radio" name="noveny" value="Zöldike">Zöldike<br>
<input type="radio" name="noveny" value="Borostyán">Borostyán<br>
<input type="radio" name="noveny" value="Azálea">Azálea<br>
<input type="radio" name="noveny" value="Anyósnyelv">Anyósnyelv<br>
<input type="radio" name="noveny" value="Tarka Sárkányfa">Tarka Sárkányfa<br>
<input type="radio" name="noveny" value="Filodendron">Filodendron<br>
</form>
<textarea class="velemeny" rows="7" cols="40" placeholder="Irja le a véleményét a növényről/virágról és hogy találkozott-e már vele? "></textarea>
<form class="textin" action="/action_page.php">
Itt lesz valami hosszu szoveg amit ide fogok irni <br>
<input type="text" name="masiknoveny">
</form>
</div>
You can use flexproperty to align them the way you want. It is a very strong css property and can be used to create any layout you need.
the code below should help you to understand and get started with it.
More about flex : https://codepen.io/enxaneta/full/adLPwv/
.layout {
display: flex;
}
.right-side {
display: flex;
flex-direction: column;
}
.szavazas {
margin-left: 5%;
margin-top: 3%;
}
.raddio {
float: left;
width: 200px;
margin-bottom: 5%;
color: white;
background: green;
border-radius: 8px;
border: 1px solid #003300;
text-align: left;
box-shadow: 0 0 2px 1px black;
height: 350px;
}
input[type="radio"] {
text-align: left;
margin-top: 10px;
margin-bottom: 10px;
}
.velemeny {
float: left;
box-shadow: 0 0 2px 1px black;
width: 200px;
height: 175px;
}
.textin {
float: left;
border: 1px solid black;
background-color: #003300;
color: white;
width: 200px;
height: 165px;
}
<div class="layout">
<div class="left-side">
<form class="raddio" action="/action_page.php">
<input type="radio" name="noveny" value="Nagy Flamingóvirág">Nagy Flamingóvirág<br>
<input type="radio" name="noveny" value="Gerbera">Gerbera<br>
<input type="radio" name="noveny" value="Szobai Futóka">Szobai Futóka<br>
<input type="radio" name="noveny" value="Rákvirág">Rákvirág<br>
<input type="radio" name="noveny" value="Zöldike">Zöldike<br>
<input type="radio" name="noveny" value="Borostyán">Borostyán<br>
<input type="radio" name="noveny" value="Azálea">Azálea<br>
<input type="radio" name="noveny" value="Anyósnyelv">Anyósnyelv<br>
<input type="radio" name="noveny" value="Tarka Sárkányfa">Tarka Sárkányfa<br>
<input type="radio" name="noveny" value="Filodendron">Filodendron<br>
</form>
</div>
<div class="right-side">
<textarea class="velemeny" rows="7" cols="40" placeholder="Irja le a véleményét a növényről/virágról és hogy találkozott-e már vele? "></textarea>
<form class="textin" action="/action_page.php">
Itt lesz valami hosszu szoveg amit ide fogok irni <br>
<input type="text" name="masiknoveny">
</form>
</div>
</div>
I have made some change to your code and achieved the bellow result. Hope this is what you want.
.raddio, .right-side {
float: left;
width: 300px;
margin-bottom: 5%;
color: white;
background: green;
border-radius: 8px;
border: 1px solid #003300;
text-align: left;
box-shadow: 0 0 2px 1px black;
height: 350px;
}
.right-side{
width: 205px;
margin-left: 15px;
border-width:0;
background: transparent;
box-shadow: none;
}
input[type="radio"] {
text-align: left;
margin-top: 10px;
margin-bottom: 10px;
}
.velemeny {
/* float: left; */
box-shadow: 0 0 2px 1px black;
width: 200px;
height: 175px;
border-radius: 8px;
box-sizing: border-box;
margin-bottom: 15px;
}
.textin {
/* float: left; */
border: 1px solid black;
background-color: #003300;
color: white;
width: 200px;
height: 160px;
border-radius: 8px;
padding: 10px;
box-sizing: border-box;
box-shadow: 0 0 2px 1px black;
}
<div class="layout">
<form class="" action="/action_page.php">
<div class="left-side raddio">
<input type="radio" name="noveny" value="Nagy Flamingóvirág">Nagy Flamingóvirág<br>
<input type="radio" name="noveny" value="Gerbera">Gerbera<br>
<input type="radio" name="noveny" value="Szobai Futóka">Szobai Futóka<br>
<input type="radio" name="noveny" value="Rákvirág">Rákvirág<br>
<input type="radio" name="noveny" value="Zöldike">Zöldike<br>
<input type="radio" name="noveny" value="Borostyán">Borostyán<br>
<input type="radio" name="noveny" value="Azálea">Azálea<br>
<input type="radio" name="noveny" value="Anyósnyelv">Anyósnyelv<br>
<input type="radio" name="noveny" value="Tarka Sárkányfa">Tarka Sárkányfa<br>
<input type="radio" name="noveny" value="Filodendron">Filodendron<br>
</div>
<div class="right-side">
<textarea class="velemeny" rows="7" cols="40" placeholder="Irja le a véleményét a növényről/virágról és hogy találkozott-e már vele? "></textarea>
<div class="textin">
Itt lesz valami hosszu szoveg amit ide fogok irni <br>
<input type="text" name="masiknoveny">
</div>
</div>
</form>
</div>

Change color on radio button (default and checked)

I have a question:
I want my radio button at default-mode to have the css:
border-color: #00AD51;
color: #fff;
background-color: #00AD51;
and when the user selects/clicks on another radio button it changes to this css:
border-color: #00AD51;
color: #00AD51;
background-color: #fff;
Is this possible? How can I make specific css on default-mode and checked-mode on radio buttons?
HTML:
<p><b>What is your favorite animal?</b></p><br />
<div class="Animals"><div class="input">
<input id="dog" type="radio" name="Animal" checked>
<label for="dog"><span>Dog</span></label>
</div>
<div class="Animals"><div class="input">
<input id="cat" type="radio" name="Animal">
<label for="cat"><span>Cat</span></label>
</div>
<div class="Animals"><div class="input">
<input id="Horse" type="radio" name="Animal">
<label for="Horse"><span>Horse</span></label>
</div>
<div class="Animals"><div class="input">
<input id="Cow" type="radio" name="Animal">
<label for="Cow"><span>Cow</span></label>
</div>
Link to codepen: https://codepen.io/vicm/pen/QBPQWZ
Here is a snippet where I:
Added the closing </div> in your HTML,
Reorganized your CSS code and tried to remove duplicate styled properties,
Corrected some typo errors (display: inline-blok to display: inline-block, position:relavitve; to position: relative; …),
I added some styling plus comments to make things clear about the different possible states,
Instead of using checked on the "recommended" answer, you can use another custom property, like "recommend", and use it in your CSS to stylize it correctly.
input[type=radio] {
margin-right: 3px;
position: relative;
top: 3px;
}
.Animals {
display: inline-block;
height: 100px;
margin: 10px;
border: 2px solid #003D6A;
border-radius: 3px;
background-color: #fff;
padding: 10px;
text-align: center;
line-height: 20px;
font-family: Helvetica;
font-size: 20px;
}
.Animals .input {
padding-bottom: 0;
}
.Animals input[type=radio] {
opacity: 0;
}
.Animals input[type=radio]+label {
cursor: pointer;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0);
border: 2px solid;
margin: 10px;
height: 100px;
border-radius: 3px;
text-align: center;
font-size: 20px;
font-family: Helvetica;
width: 292px;
/* Default */
border-color: darkblue;
background-color: #fff;
color: darkblue;
}
/* Recommanded */
.Animals input[type=radio][recommand]+label {
border-color: turquoise;
color: turquoise;
}
/* Hover */
.Animals input[type=radio]+label:hover {
border-color: #00AD51;
color: #00AD51;
}
/* Checked */
.Animals input[type=radio]:checked+label {
border-color: #00AD51;
background-color: #00AD51;
color: #fff;
}
.Animals label span {
position: relative;
top: 33%;
}
<p><b>What is your favorite animal?</b></p><br />
<div class="Animals">
<div class="input">
<input id="dog" type="radio" name="Animal" recommand>
<label for="dog"><span>Dog</span></label>
</div>
</div>
<div class="Animals">
<div class="input">
<input id="cat" type="radio" name="Animal">
<label for="cat"><span>Cat</span></label>
</div>
</div>
<div class="Animals">
<div class="input">
<input id="Horse" type="radio" name="Animal">
<label for="Horse"><span>Horse</span></label>
</div>
</div>
<div class="Animals">
<div class="input">
<input id="Cow" type="radio" name="Animal">
<label for="Cow"><span>Cow</span></label>
</div>
</div>
If you wish to modify something, it should be easier now.
You can use this simple trick.
When user can click or check the radio button
.Animals input[type=radio]:checked + label{border-color: #00AD51;color: #00AD51;background-color: #fff;}
Hope this help.
Let me know further clarification.
input[type=radio]
{
margin-right: 3px;
position: relative;
top: 3px;
}
.Animals
{
border:2px solid #003D6A;
margin:10px;
height:100px;
padding:10px;
border-radius:3px;
text-align:center;
font-size: 20px;
line-height: 20px;
background-color:#fff;
font-family: Helvetica;
display: inline-blok;
}
.Animals{
margin: 0 auto;
}
.Animals input[type=radio] {
opacity: 0;
position:relavitve;
}
.Animals input[type=radio] + label {
cursor: pointer;
text-shadow: 1px 1px 0 rgba(0,0,0,0);
border: 2px solid #003D6A;
margin: 10px;
height: 100px;
border-radius: 3px;
text-align: center;
font-size: 20px;
font-family: Helvetica;
width: 292px;
background-color: #ffffff;
}
.Animals input[type=radio] + label:hover{
border-color: #00AD51;
background-color: #fff;
color: #00AD51;
}
.Animals .input
{
padding-bottom:0;
}
.Animals label span
{
position:relative;
top:33%;
}
.Animals input[type=radio]:checked + label{
border-color: #00AD51;
color: #00AD51;
background-color: #fff;
}
<p><b>What is your favorite animal?</b></p><br />
<div class="Animals"><div class="input">
<input id="dog" type="radio" name="Animal" checked>
<label for="dog"><span>Dog</span></label>
</div>
<div class="Animals"><div class="input">
<input id="cat" type="radio" name="Animal">
<label for="cat"><span>Cat</span></label>
</div>
<div class="Animals"><div class="input">
<input id="Horse" type="radio" name="Animal">
<label for="Horse"><span>Horse</span></label>
</div>
<div class="Animals"><div class="input">
<input id="Cow" type="radio" name="Animal">
<label for="Cow"><span>Cow</span></label>
</div>

z-index not working with li psuedo element

grrrrrrr, I have been struggling with this for a while.
I try to create a progress bar with connectors, I would the connectors to be under the Circles I have, when the circle is with class active the connector is shown and I would like to avoid it.
Take a look at my fiddle.
/*custom font*/
#import url(http://fonts.googleapis.com/css?family=Montserrat);
body {
font-family: montserrat, arial, verdana;
margin:0;
padding:0;
background-image:url("Capture.PNG");
}
.modal{
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content{
background-color: #fefefe;
margin: 8% auto;
border: 1px solid #888;
width: 662px;
height: 662px;
}
.modal-header{
height:100px;
}
.right-header{
float:right;
width:50%;
}
#msform .formPage {
height: 662px;
padding: 35px;
box-sizing: border-box;
position: relative;
font-family: Arial, Helvetica, sans-serif;
}
/*Hide all except first fieldset*/
#msform > .formPage ~ .formPage{
display: none;
}
/*inputs*/
#msform input, #msform textarea {
padding: 15px;
border: 1px solid #ccc;
border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
/*buttons*/
#msform .action-button {
width: 100px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#msform .action-button:hover, #msform .action-button:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
}
/*headings*/
.fs-title {
font-size: 15px;
text-transform: uppercase;
color: #2C3E50;
margin-bottom: 10px;
}
.fs-subtitle {
font-weight: normal;
font-size: 13px;
color: #666;
margin-bottom: 20px;
}
/*progressbar*/
#progressbar {
/*CSS counters to number the steps*/
counter-reset: step;
}
/*This is the li circle*/
#progressbar li {
counter-increment: step;
width: 27px;
height: 27px;
background-color:#dcdedf;
margin-left: 35px;
border-radius: 50%;
list-style-type: none;
float: left;
}
/*Display the li number*/
#progressbar li:before {
content: counter(step);
text-align: center;
line-height: 26px;
display: block;
color:white;
}
/*progressbar connectors*/
#progressbar li:after {
content: "";
width: 38px;
height: 10px;
background-color: #dcdedf;
position: relative;
top: -18px;
left: -36px;
display: block;
z-index: -1;
}
#progressbar li:first-child:after {
/*connector not needed before the first step*/
content: none;
}
/*marking active/completed steps green*/
/*The number of the step and the connector before it = green*/
#progressbar li.active, #progressbar li.active:after{
background: #3395ff;
color: white;
}
#progressbar li:first-child{
margin-left:0;
}
.close {
color: #aaa;
float: right;
font-size: 24px;
padding: 5px 15px;
}
.close:hover, .close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
<div class="modal">
<div class='modal-content'>
<div class='modal-header'>
<span class="close" data-action="close-modal">x</span>
<div class="left-header">
<span>Add new App</span>
<span></span>
</div>
<div class="right-header">
<!-- progressbar -->
<ul id="progressbar">
<li class="active"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
<hr/>
<div class="modal-inner-content">
<form id="msform">
<div class="formPage">
<h2 class="fs-title">Create your account</h2>
<h3 class="fs-subtitle">This is step 1</h3>
<input type="text" name="email" placeholder="Email" />
<input type="password" name="pass" placeholder="Password" />
<input type="password" name="cpass" placeholder="Confirm Password" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
<div class="formPage">
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
<input type="text" name="twitter" placeholder="Twitter" />
<input type="text" name="facebook" placeholder="Facebook" />
<input type="text" name="gplus" placeholder="Google Plus" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
<div class="formPage">
<h2 class="fs-title">Personal Details</h2>
<h3 class="fs-subtitle">We will never sell it</h3>
<input type="text" name="fname" placeholder="First Name" />
<input type="text" name="lname" placeholder="Last Name" />
<input type="text" name="phone" placeholder="Phone" />
<textarea name="address" placeholder="Address"></textarea>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="submit" name="submit" class="submit action-button" value="Submit" />
</div>
<div class="formPage">
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
<input type="text" name="twitter" placeholder="Twitter" />
<input type="text" name="facebook" placeholder="Facebook" />
<input type="text" name="gplus" placeholder="Google Plus" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
<div class="formPage">
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
<input type="text" name="twitter" placeholder="Twitter" />
<input type="text" name="facebook" placeholder="Facebook" />
<input type="text" name="gplus" placeholder="Google Plus" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
</form>
</div>
</div>
</div>
You need to set the z-index of the immediate parent i.e #progressbar to raise it above the other ancestors.
#progressbar {
position: relative;
z-index: 1;
}
/*custom font*/
#import url(http://fonts.googleapis.com/css?family=Montserrat);
body {
font-family: montserrat, arial, verdana;
margin: 0;
padding: 0;
background-image: url("Capture.PNG");
}
.modal {
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
margin: 8% auto;
border: 1px solid #888;
width: 662px;
height: 662px;
}
.modal-header {
height: 100px;
}
.right-header {
float: right;
width: 50%;
}
#msform .formPage {
height: 662px;
padding: 35px;
box-sizing: border-box;
position: relative;
font-family: Arial, Helvetica, sans-serif;
}
/*Hide all except first fieldset*/
#msform>.formPage~.formPage {
display: none;
}
/*inputs*/
#msform input,
#msform textarea {
padding: 15px;
border: 1px solid #ccc;
border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
/*buttons*/
#msform .action-button {
width: 100px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#msform .action-button:hover,
#msform .action-button:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
}
/*headings*/
.fs-title {
font-size: 15px;
text-transform: uppercase;
color: #2C3E50;
margin-bottom: 10px;
}
.fs-subtitle {
font-weight: normal;
font-size: 13px;
color: #666;
margin-bottom: 20px;
}
/*progressbar*/
#progressbar {
/*CSS counters to number the steps*/
counter-reset: step;
position: relative;
z-index: 1;
}
/*This is the li circle*/
#progressbar li {
counter-increment: step;
width: 27px;
height: 27px;
background-color: #dcdedf;
margin-left: 35px;
border-radius: 50%;
list-style-type: none;
float: left;
}
/*Display the li number*/
#progressbar li:before {
content: counter(step);
text-align: center;
line-height: 26px;
display: block;
color: white;
}
/*progressbar connectors*/
#progressbar li:after {
content: "";
width: 38px;
height: 10px;
background-color: #dcdedf;
position: relative;
top: -18px;
left: -36px;
display: block;
z-index: -1;
}
#progressbar li:first-child:after {
/*connector not needed before the first step*/
content: none;
}
/*marking active/completed steps green*/
/*The number of the step and the connector before it = green*/
#progressbar li.active,
#progressbar li.active:after {
background: #3395ff;
color: white;
}
#progressbar li:first-child {
margin-left: 0;
}
.close {
color: #aaa;
float: right;
font-size: 24px;
padding: 5px 15px;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
<div class="modal">
<div class='modal-content'>
<div class='modal-header'>
<span class="close" data-action="close-modal">x</span>
<div class="left-header">
<span>Add new App</span>
<span></span>
</div>
<div class="right-header">
<!-- progressbar -->
<ul id="progressbar">
<li class="active"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
<hr/>
<div class="modal-inner-content">
<form id="msform">
<div class="formPage">
<h2 class="fs-title">Create your account</h2>
<h3 class="fs-subtitle">This is step 1</h3>
<input type="text" name="email" placeholder="Email" />
<input type="password" name="pass" placeholder="Password" />
<input type="password" name="cpass" placeholder="Confirm Password" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
<div class="formPage">
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
<input type="text" name="twitter" placeholder="Twitter" />
<input type="text" name="facebook" placeholder="Facebook" />
<input type="text" name="gplus" placeholder="Google Plus" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
<div class="formPage">
<h2 class="fs-title">Personal Details</h2>
<h3 class="fs-subtitle">We will never sell it</h3>
<input type="text" name="fname" placeholder="First Name" />
<input type="text" name="lname" placeholder="Last Name" />
<input type="text" name="phone" placeholder="Phone" />
<textarea name="address" placeholder="Address"></textarea>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="submit" name="submit" class="submit action-button" value="Submit" />
</div>
<div class="formPage">
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
<input type="text" name="twitter" placeholder="Twitter" />
<input type="text" name="facebook" placeholder="Facebook" />
<input type="text" name="gplus" placeholder="Google Plus" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
<div class="formPage">
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
<input type="text" name="twitter" placeholder="Twitter" />
<input type="text" name="facebook" placeholder="Facebook" />
<input type="text" name="gplus" placeholder="Google Plus" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</div>
</form>
</div>
</div>
</div>
It seems to work fine when using z-index...
http://www.codeply.com/go/NklFtnx5ks
#progressbar li:after {
content: "";
width: 47px;
height: 10px;
background-color: #dcdedf;
position: relative;
top: -18px;
left: -45px;
display: block;
opacity: .99;
z-index: -1;
}

CSS: Checkbox switch effect works only for the first checkbox

I need to make that switching effect working on any single checkbox I click. For example, I'll check the second (styled) checkbox, it will automatically switch and all others will stay unaffected. Thx very much for help.
https://jsfiddle.net/99asehku/
HTML:
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div><br><br>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div><br><br>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch1" class="onoffswitch-checkbox1" id="myonoffswitch1" checked>
<label class="onoffswitch-label1" for="myonoffswitch1">
<span class="onoffswitch-inner1"></span>
<span class="onoffswitch-switch1"></span>
</label>
</div>
CSS:
.onoffswitch {
position: relative; width: 58px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #999999; border-radius: 20px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 10px; padding: 0; line-height: 10px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "ANO";
padding-left: 10px;
background-color: #34A7C1; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "NE";
padding-right: 10px;
background-color: #EEEEEE; color: #999999;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 10px; margin: 0px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 44px;
border: 2px solid #999999; border-radius: 20px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
First of all id must be unique. Don't use same id for different element.
And make for for all different.
.onoffswitch {
position: relative; width: 58px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #999999; border-radius: 20px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 10px; padding: 0; line-height: 10px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "ANO";
padding-left: 10px;
background-color: #34A7C1; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "NE";
padding-right: 10px;
background-color: #EEEEEE; color: #999999;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 10px; margin: 0px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 44px;
border: 2px solid #999999; border-radius: 20px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div><br><br>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch1" checked>
<label class="onoffswitch-label" for="myonoffswitch1">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div><br><br>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch2" checked>
<label class="onoffswitch-label" for="myonoffswitch2">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
You should differentiate their id and ids should be same as label 'for' attribute:
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div><br><br>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch1" checked>
<label class="onoffswitch-label" for="myonoffswitch1">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div><br><br>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch1" class="onoffswitch-checkbox1" id="myonoffswitch2" checked>
<label class="onoffswitch-label1" for="myonoffswitch2">
<span class="onoffswitch-inner1"></span>
<span class="onoffswitch-switch1"></span>
</label>
</div>
Sharing updated fiddle please check:
https://jsfiddle.net/anujAdmin/9w413j0k/
You have to give to each checkbox switch a name and id unique.
Look at this: jsfiddle; the last one has its own id and name, while the second has the same id and name of the first. (Of course the css code must be repeated or rules modified to apply for each new id)
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>

Resources