Attribute & nth child pseudo Selectors
<!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>Attribute and nth pseudo selectors</title>
<style>
body {
background-color: rgb(22, 19, 19);
}
.container {
display: block;
width: 233px;
margin: auto;
}
input {
display: block;
}
input[type='text'] {
padding: 23px;
border: 2px solid red;
}
input[type='submit'] {
padding: 23px;
border: 2px solid red;
}
a[target] {
font-size: 64px;
color: rgb(228, 87, 5);
}
a[target='self'] {
font-size: 64px;
color: rgb(31, 21, 172);
}
input[type='email'] {
color: crimson;
border: 4px solid black;
}
/* this will apply css for third child */
li:nth-child(3) {
color: blue;
}
/* this will apply css for every 2nd child */
li:nth-child(2n+0) {
color: rgb(175, 0, 0);
}
/* this will apply css for every third child */
li:nth-child(3n+0) {
color: rgb(26, 90, 0);
}
li:nth-child(1n+0) {
color: rgb(97, 0, 92);
}
li:nth-child(odd) {
color: rgb(105, 103, 105);
background-color: red;
}
li:nth-child(even) {
color: rgb(26, 0, 97);
background-color: purple;
}
</style>
</head>
<body>
<div class="container">
<h1><a href="http://google.com" target="_blank">Go to google</a></h1>
<h1><a href="http://facebook.com" target="self">Go to Facebook</a></h1>
<form action="" class="form-control">
<input type="text" placeholder="enter your name">
<input type="password" placeholder="enter your password">
<input type="email" placeholder="enter your email">
<input type="submit" value="Submit">
</form>
<ul>
<li class="item" id="item-1">Item1</li>
<li class="item" id="item-2">Item2</li>
<li class="item" id="item-3">Item3</li>
<li class="item" id="item-4">Item4</li>
<li class="item" id="item-5">Item5</li>
<li class="item" id="item-6">Item6</li>
<li class="item" id="item-7">Item7</li>
<li class="item" id="item-8">Item8</li>
<li class="item" id="item-9">Item9</li>
<li class="item" id="item-10">Item10</li>
</ul>
</div>
</body>
</html>
Comments
Post a Comment