Показать сообщение отдельно
  #25 (permalink)  
Старый 31.03.2020, 15:23
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,125

Сергей Ракипов,
<!DOCTYPE html>
<html>
<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
  main{
	max-width: 720px;
	margin: 0 auto;
}
label{
	cursor: pointer;
}
label:hover{
	color: #03A5D;
}
input[type=radio] {
	display: none;
}
input[type=checkbox] {
	display: none;
}
.stlradio {
    display: inline-block;
    border: 1px solid #b2b1b1;
    width: 16px;
    height: 16px;
    position: relative;
    vertical-align: middle;
    box-sizing: border-box;
    margin-right: 4px;
    border-radius: 300px;
    background-color:#ffffff;
}
.stlradio:before {
    content: "";
    background: #03A5D7;
    width: 8px;
    height: 8px;
    opacity: 0;
    transition: 0.3s;
    position: absolute;
    top: 3px;
    left: 3px;
    border-radius: 300px;
}
input:checked + .stlradio:before {
    opacity: 1;
}
.stlchek {
    display: inline-block;
    border: 1px solid #b2b1b1;
    width: 16px;
    height: 16px;
    position: relative;
    vertical-align: middle;
    box-sizing: border-box;
    margin-right: 4px;
}
.stlchek:before {
    content: "";
    background: #03A5D7;
    width: 8px;
    height: 8px;
    opacity: 0;
    transition: 0.3s;
    position: absolute;
    top: 3px;
    left: 3px;
}
input:checked + .stlchek:before {
    opacity: 1;
}
.name{
display: inline-block;
}
.name:hover{
	color: #03A5D7;
}
.align_game{
	display:flex;
	align-items: center;
}
.align{
	display: inline-flex;
	align-items: center;
	margin: 0px 5px 0px 5px;
}
.all_game{
	position: relative;
}
.game_ps {
	position:absolute;
	display: none;
}
.game_xb {
	position:absolute;
	display: none;
}
.game_nin {
	position:absolute;
	display: none;
}
.all_game > div.open{
    display: block;
}
  </style>
</head>
<body>
<main>
		<div class="game_console">
			Выберите консоль: <br><br>
			<div class="align_game">
				<input type="radio" name="console" class="radio" id="ps4" value="PS4"><div class="stlradio"></div><div class="name"> <label for="ps4">PS4</label></div>
			</div>
			<div class="align_game">
				<input type="radio" name="console" class="radio" id="xbox" value="X-box"> <div class="stlradio"></div><div class="name"> <label for="xbox">X-box</label></div>
			</div>
			<div class="align_game">
				<input type="radio" name="console" class="radio" id="nindendo" value="Nindendo"><div class="stlradio"></div><div class="name"> <label for="nindendo">Nindendo</label></div>
			</div>
		</div>
		<br>
		<div class="out_console"></div><br>
		<div class="out_select_game"></div>
		<br><br>
		<div class="out_game"></div>
		<br>
		<div class="all_game">
			<div class="game_ps">
				<label for="game_1">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_1" value="God of War"><div class="stlchek"></div><div class="name"> God of War</div>
				</div>
				</label>
				<label for="game_2">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_2" value="Uncharted 4"> <div class="stlchek"></div><div class="name"> Uncharted 4</div>
				</div>
				</label>
				<label for="game_3">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_3" value="BloodBorne"><div class="stlchek"></div><div class="name"> BloodBorne</div>
				</div>
				</label>
			</div>
			<div class="game_xb">
				<label for="game_4">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_4" value="Gears 5"><div class="stlchek"></div> <div class="name">Gears 5</div>
				</div>
				</label>
				<label for="game_5">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_5" value="Halo Infinite"><div class="stlchek"></div> <div class="name">Halo Infinite</div>
				</div>
				</label>
				<label for="game_6">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_6" value="Cuphead"><div class="stlchek"></div><div class="name"> Cuphead</div>
				</div>
				</label>
			</div>
			<div class="game_nin">
				<label for="game_7">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_7" value="Zelda"><div class="stlchek"></div><div class="name"> Zelda</div>
				</div>
				</label>
				<label for="game_8">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_8" value="Yoshi's"><div class="stlchek"></div><div class="name"> Yoshi's</div>
				</div>
				</label>
				<label for="game_9">
				<div class="align">
					<input type="checkbox" class="stlchek box" id="game_9" value="Mario Odyssey"><div class="stlchek"></div> <div class="name">Mario Odyssey</div>
				</div>
				</label>
			</div>
		</div>
	</main>
<script>
var index = 0;
var game = document.querySelectorAll('.all_game > div');
function gamesSelectedShow() {
    var nameGames = [];
    game[index].querySelectorAll('input').forEach(function(input) {
        if (input.checked) nameGames.push(input.value)
    })
    document.querySelector('.out_select_game').innerHTML = nameGames.length ? nameGames : 'Сделайте выбор!';
}
function consoleSelectedShow() {
    game.forEach(function(div, i) {
        div.classList.toggle('open', i === index)
    })
}
document.querySelectorAll('[name="console"]').forEach(function(console, i) {
    console.addEventListener('change', function() {
        document.querySelector('.out_console').innerHTML = 'Ваша консоль: ' + console.value;
        index = i;
        consoleSelectedShow();
        gamesSelectedShow();
    })
})
game.forEach(function(div) {
    div.addEventListener('change', gamesSelectedShow)
})
</script>
</body>
</html>
Ответить с цитированием