lesson3-6

In this example below you will see how to do a lesson3-6 with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by Megwarez, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright Megwarez ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>lesson3-6</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8"/>
    <title>Task6</title>
</head>
<body>

<form action="#">
    <div>
        <input type="checkbox" id="red">
        <input type="checkbox" id="green">
        <input type="checkbox" id="blue">

        <label for="red">красные</label>
        <label for="green">зеленые</label>
        <label for="blue">синие</label>

        <span class="red">красные</span>
        <span class="green">зеленые</span>
        <span class="green">зеленые</span>
        <span class="red">красные</span>
        <span class="blue">синие</span>
        <span class="green">зеленые</span>
        <span class="red">красные</span>
        <span class="blue">синие</span>
        <span class="red">красные</span>
        <span class="green">зеленые</span>
        <span class="blue">синие</span>
    </div>
</form>

</body>
</html>
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/Megwarez/lesson3-6-wMJWJR */
/*
	по состоянию checked включать/выключать 
	соответствующие элементы
	
	http://clck.ru/d/Jxj_mgDC143fZ
*/

body {
	font: 11px Arial;
}

input {
	display: none;
}

label {
	text-decoration: underline;
	margin-right: 2em;
}

label[for="red"] {
	color: red;
}
label[for="green"] {
	color: green;
}
label[for="blue"] {
	color: blue;
}

span {
	display: none;
	border-radius: 0.5em;
	padding: .1em .5em;
	color: #FFF;
}

input#red:checked ~ span.red {
	display: inline-block;
}
input#blue:checked ~ span.blue {
	display: inline-block;
}
input#green:checked ~ span.green {
	display: inline-block;
}

.red {
	background-color: red;
}
.green {
	background-color: green;
}
.blue {
	background-color: blue;
}

Comments