<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Испытание: вторая раскладка</title>
<link rel="stylesheet" href="/assets/course57/course.css">
</head>
<body>
<div></div>
<ul class="cards">
<li class="two heart"></li>
<li class="five diamond"></li>
<li class="ten heart"></li>
<li class="jack club"></li>
<li class="queen spade"></li>
<li class="king diamond"></li>
<li class="ace heart"></li>
<li class="six heart"></li>
<li class="seven diamond"></li>
<li class="eight spade"></li>
<li class="nine club"></li>
<li class="three club"></li>
<li class="four heart"></li>
</ul>
<ul class="cards">
<li class="five spade"></li>
<li class="six diamond"></li>
<li class="seven spade"></li>
<li class="eight club"></li>
<li class="two diamond"></li>
<li class="three heart"></li>
<li class="four club"></li>
<li class="queen club"></li>
<li class="king spade"></li>
<li class="seven diamond"></li>
<li class="nine heart"></li>
<li class="ten diamond"></li>
<li class="jack heart"></li>
</ul>
<ul class="cards">
<li class="two spade"></li>
<li class="ten heart"></li>
<li class="ace club"></li>
<li class="five heart"></li>
<li class="nine diamond"></li>
<li class="king diamond"></li>
<li class="ace spade"></li>
<li class="six heart"></li>
<li class="eight diamond"></li>
<li class="ace spade"></li>
<li class="queen heart"></li>
<li class="three diamond"></li>
<li class="four spade"></li>
</ul>
<ul class="cards">
<li class="king heart"></li>
<li class="jack club"></li>
<li class="two club"></li>
<li class="three spade"></li>
<li class="four diamond"></li>
<li class="ten club"></li>
<li class="jack spade"></li>
<li class="eight diamond"></li>
<li class="nine spade"></li>
<li class="queen diamond"></li>
<li class="five club"></li>
<li class="six club"></li>
<li class="seven heart"></li>
</ul>
<div></div>
</body>
</html>
html,
body {
margin: 0;
padding: 0;
font-family: "Arial", sans-serif;
}
body {
min-width: 550px;
min-height: 250px;
padding: 10px;
}
.cards {
position: relative;
width: 380px;
text-align: left;
}
.cards li {
width: 37px;
height: 55px;
}
.cards li::before {
font-family: "Courier", monospace;
}
.cards li:not(:first-of-type) {
margin-left: -20px;
}
ul::after {
content: "";
position: absolute;
right: 0;
top: 0;
display: block;
width: 37px;
height: 55px;
border: 1px dashed #33bb33;
border-radius: 5px;
}
li:nth-of-type(4n+1) {
background-color: #ffcc33;
}
ul:not(:first-of-type) li:nth-of-type(4n+2){
background-color: #0099ff;
}
ul:not(:first-of-type):not(:nth-of-type(3)) li:nth-of-type(4n+4){
background-color: #ff3300;
}
ul:nth-of-type(3) li:nth-of-type(3n+8) {
background-color: #339933;
}
ul:first-of-type li:nth-of-type(2n) {
background-color: #996666;
}
Сделал 4-цвет, как:
.cards:nth-of-type(3) .six.heart,.queen.heart {
background-color: #339933;
}
Не стал высчитывать такие сложные вычисления
Мой вариант, мне кажется чуть более оптимизирован,чем выше
пасьянс
html,
body {
margin: 0;
padding: 0;
font-family: "Arial", sans-serif;
}
body {
min-width: 550px;
min-height: 250px;
padding: 10px;
}
.cards {
position: relative;
width: 380px;
text-align: left;
}
.cards li {
width: 37px;
height: 55px;
}
.cards li::before {
font-family: "Courier", monospace;
}
.cards li:not(:first-child) {
margin-left: -20px;
}
ul::after {
content: "";
position: absolute;
right: 0;
top: 0;
display: block;
width: 37px;
height: 55px;
border: 1px dashed #33bb33;
border-radius: 5px;
}
.cards li:nth-child(4n+1) {
background-color: #ffcc33;
}
.cards:not(:first-of-type) li:nth-child(4n+2) {
background-color: #0099ff;
}
.cards:nth-of-type(even) li:nth-child(4n) {
background-color: #ff3300;
}
.cards:nth-last-of-type(2) li:nth-child(3n+8) {
background-color: #339933;
}
.cards:first-of-type li:nth-child(even) {
background-color: #996666;
}
Мой вариант:
.cards li {
width: 37px;
height: 55px;
}
.cards li::before {
font-family: “Courier”, monospace;
}
li:not(:first-child) {
margin-left: -20px;
}
.cards::after {
content: “”;
position: absolute;
right: 0;
top: 0;
display: block;
width: 37px;
height: 55px;
border: 1px dashed #33bb33;
border-radius: 5px;
}
li:nth-child(4n+1){
background-color: #ffcc33;
}
li:nth-child(4n+2) {
background-color: #0099ff;
}
ul:nth-of-type(2n) li:nth-child(4n+4) {
background-color: #ff3300;
}
ul:nth-of-type(3) li:nth-child(3n+8) {
background-color: #339933;
}
ul:first-of-type li:nth-child(2n) {
background-color: #996666;
}
html,
body {
margin: 0;
padding: 0;
font-family: “Arial”, sans-serif;
}
body {
min-width: 550px;
min-height: 250px;
padding: 10px;
}
.cards {
position: relative;
width: 380px;
text-align: left;
}
.cards li {
width: 37px;
height: 55px;
}
.cards li::before {
font-family: “Courier”, monospace;
}
.cards li:not(:first-of-type) {
margin-left: -20px;
}
.cards::after {
content: “”;
position: absolute;
right: 0;
top: 0;
display: block;
width: 37px;
height: 55px;
border: 1px dashed #33bb33;
border-radius: 5px;
}
.cards li:nth-child(4n+1) {
background-color: #ffcc33;
}
.cards:not(:first-of-type) li:nth-child(4n+2) {
background-color: #0099ff;
}
.cards:nth-of-type(2n) li:nth-child(4n) {
background-color: #ff3300;
}
.cards:nth-of-type(3) .ace.spade + li {
background-color: #339933;
}
.cards:first-of-type li:nth-child(2n) {
background-color: #996666;
}
html,
body {
margin: 0;
padding: 0;
font-family: “Arial”, sans-serif;
}
body {
min-width: 550px;
min-height: 250px;
padding: 10px;
}
.cards {
position: relative;
width: 380px;
text-align: left;
}
.cards li {
width: 37px;
height: 55px;
}
.cards li::before {
font-family: “Courier”, monospace;
}
li:not(:first-of-type) {
margin-left: -20px;
}
ul::after {
content: “”;
position: absolute;
right: 0;
top: 0;
display: block;
width: 37px;
height: 55px;
border: 1px dashed #33bb33;
border-radius: 5px;
}
li:nth-of-type(4n-3) {
background-color: #ffcc33;
}
ul:not(:first-of-type) li:nth-of-type(4n-2) {
background-color: #0099ff;
}
ul:nth-of-type(2n) li:nth-of-type(4n) {
background-color: #ff3300;
}
ul:nth-of-type(3) li:nth-of-type(3n+8) {
background-color: #339933;
}
ul:first-of-type li:nth-of-type(2n) {
background-color: #996666;
}
.cards::after {
content: “”;
position: absolute;
right: 0;
top: 0;
display: block;
width: 37px;
height: 55px;
border: 1px dashed #33bb33;
border-radius: 5px;
}
вариант где 3n+8 можно сделать еще вот так - выделить все .heart
идущие после .ace.spade
, но ваш вариант с 3n+8 конечно изящнее, я не подобрал итерацию и решил что тут другое правило надо использовать из ранее встречавшихся в уроках:
ul:nth-last-of-type(2) .ace.spade ~ .heart {
background-color: #339933;
}
я так после оптимизации:
li:nth-of-type(4n+1) {
background-color: #ffcc33;
}
ul:not(:first-of-type) li:nth-of-type(4n-2) {
background-color: #0099ff;
}
ul:not(:nth-of-type(odd)) li:nth-of-type(4n) {
background-color: #ff3300;
}
ul:nth-of-type(3) .six,.queen
{
background-color: #339933;
}
ul:first-of-type > li:nth-of-type(even) {
background-color: #996666;
}
html,
body {
margin: 0;
padding: 0;
font-family: “Arial”, sans-serif;
}
body {
min-width: 550px;
min-height: 250px;
padding: 10px;
}
.cards {
position: relative;
width: 380px;
text-align: left;
}
.cards li:not(:first-child) {
display:inline-block;
padding:0px;
margin-left:-20px;
width: 37px;
height: 55px;
}
li:first-child{
width: 37px;
height: 55px;
}
.cards li::before {
font-family: “Courier”, monospace;
}
/li{/
/* margin-left: -20px;/
/}*/
ul::after{
content: “”;
position: absolute;
right: 0;
top: 0;
display: block;
width: 37px;
height: 55px;
border: 1px dashed #33bb33;
border-radius: 5px;
}
li:nth-of-type(4n+1) {
background-color: #ffcc33;
}
ul:not(:first-of-type) li:nth-of-type(4n+2) {
background-color: #0099ff;
}
ul:not(:nth-child(even)) li:nth-of-type(4n+4){
background-color: #ff3300;
}
ul:nth-last-of-type(2) .spade.ace+.heart{
background-color: #339933;
}
ul:first-of-type li:nth-of-type(2n+2){
background-color: #996666;
}