Я закодировал навигационную панель, чтобы она была липкой при прокрутке и также меняла цвет. Но все изменения происходят так внезапно, и я не знаю, как это исправить. Вот примеры кода:
// jshint esversion: 6
window.onscroll = function() { myFunction(); };
let navbar = document.getElementsByClassName("navigation")[0];
let sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky");
} else {
navbar.classList.remove("sticky");
}
}/* ------------------------------------- */
/* BASIC RESET */
/* ------------------------------------- */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html { font-size: 62.5%; }
body {
box-sizing: inherit;
color: #777;
background-color: #fff;
font-family: 'Roboto', sans-serif;
font-size: 1.8rem;
font-weight: 400;
line-height: 1.5;
}
.clearfix {zoom: 1;}
.clearfix:after {
content: '.';
clear: both;
display: block;
height: 0;
visibility: hidden;
}
/* ------------------------------------- */
/* THE REUSABLE CONTENT */
/* ------------------------------------- */
/* HTML contents */
h1, h2.header-heading, h2 {
margin: 0;
text-transform: uppercase;
}
h1 {
font-size: 4.5rem;
color: #fff;
letter-spacing: .4rem;
word-spacing: .5rem;
font-weight: 300;
}
h2 {
font-size: 3.5rem;
}
/* Links */
a {
text-decoration: none;
display: inline-block;
}
/* Buttons */
.btn {
border: 1px solid #fff;
border-radius: .3rem;
font-size: 1.6rem;
padding: 1.2rem 3.5rem;
text-transform: uppercase;
color: #fff;
background-color: transparent;
font-weight: bold;
letter-spacing: .3rem;
transition: all .2s;
}
.btn:hover {
background-color: #fff;
color: #000;
}
/* Utility classes */
.u-margin-top-small {
margin-top: 2.5rem;
}
.u-text-align-center {
text-align: center;
}
.u-inline-block {
display: inline-block;
}
/* ------------------------------------- */
/* THE HEADER SECTION */
/* ------------------------------------- */
header {
background-color: #353353;
height: 98vh;
}
.hero-text-box {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}
h2.header-heading {
font-size: 3.5rem;
margin-top: 2rem;
color: #F9F871;
font-weight: 400;
}
/* ------------------------------------- */
/* THE NAVBAR */
/* ------------------------------------- */
.navigation {
position: relative;
padding: 1rem;
border-bottom: .5px solid #777;
}
.logo-box {
float: left;
}
.logo {
color: #353353;
text-transform: uppercase;
font-weight: 700;
font-size: 4rem;
letter-spacing: .4rem;
margin-left: 5rem;
}
nav {
padding: 1rem;
}
.navbar {
float: right;
list-style: none;
margin-right: 10rem;
margin-top: 1.5rem;
}
.navbar li {
display: inline-block;
}
.navbar li a {
margin: 0 1rem;
padding: .2rem .6rem;
color: black;
text-transform: uppercase;
border-bottom: 2px solid transparent;
transition: all .3s;
}
.navbar li a:hover {
border-bottom: 2px solid #F9F871;
transition: all .3s;
}
/* The sticky navbar */
.sticky {
position: fixed;
background-color: #353353;
top: 0;
width: 100%;
}
.sticky .navbar-lists {
color: #fff;
}
.sticky .logo {
color: #fff;
}<!DOCTYPE html>
<html lang = "en">
<head>
<!-- Required meta tags -->
<meta charset = "UTF-8">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<meta http-equiv = "X-UA-Compatible" content = "ie=edge">
<!-- Rubik fonts link -->
<link rel = "preconnect" href = "https://fonts.gstatic.com">
<link href = "https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;700&display=swap" rel = "stylesheet">
<!-- CSS links -->
<link rel = "stylesheet" href = "css/normalize.css">
<link rel = "stylesheet" href = "css/styles.css">
<title>Arun Bohra - Design Business Solutions</title>
</head>
<body>
<header>
<div class = "hero-text-box u-text-align-center u-inline-block">
<h1>Hello my name is Arun</h1>
<h2 class = "header-heading u-margin-top-small">I'm a front-end developer</h2>
<a href = "#" class = "btn u-margin-top-small u-inline-block">Who am I</a>
</div>
</header>
<div class = "navigation">
<nav class = "clearfix">
<div class = "logo-box">
<a href = "#" class = "logo">
Arun
</a>
</div>
<ul class = "navbar">
<li><a href = "#" class = "navbar-lists">Home</a></li>
<li><a href = "#" class = "navbar-lists">About me</a></li>
<li><a href = "#" class = "navbar-lists">Skills</a></li>
<li><a href = "#" class = "navbar-lists">Projects</a></li>
<li><a href = "#" class = "navbar-lists">Contact</a></li>
</ul>
</nav>
</div>
<section class = "about-section">
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
</section>
<script src = "js/index.js" charset = "utf-8"></script>
</body>
</html>Я хочу добавить плавности, когда навигационная панель становится липкой вверху. Было бы здорово, если бы я смог сделать это с помощью свойства transition в css. Кто-нибудь может мне с этим помочь?



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Просто добавьте свойство transition: background duration; в класс навигации. Это сгладит изменение фона.
// jshint esversion: 6
window.onscroll = function() { myFunction(); };
let navbar = document.getElementsByClassName("navigation")[0];
let sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky");
} else {
navbar.classList.remove("sticky");
}
}/* ------------------------------------- */
/* BASIC RESET */
/* ------------------------------------- */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html { font-size: 62.5%; }
body {
box-sizing: inherit;
color: #777;
background-color: #fff;
font-family: 'Roboto', sans-serif;
font-size: 1.8rem;
font-weight: 400;
line-height: 1.5;
}
.clearfix {zoom: 1;}
.clearfix:after {
content: '.';
clear: both;
display: block;
height: 0;
visibility: hidden;
}
/* ------------------------------------- */
/* THE REUSABLE CONTENT */
/* ------------------------------------- */
/* HTML contents */
h1, h2.header-heading, h2 {
margin: 0;
text-transform: uppercase;
}
h1 {
font-size: 4.5rem;
color: #fff;
letter-spacing: .4rem;
word-spacing: .5rem;
font-weight: 300;
}
h2 {
font-size: 3.5rem;
}
/* Links */
a {
text-decoration: none;
display: inline-block;
}
/* Buttons */
.btn {
border: 1px solid #fff;
border-radius: .3rem;
font-size: 1.6rem;
padding: 1.2rem 3.5rem;
text-transform: uppercase;
color: #fff;
background-color: transparent;
font-weight: bold;
letter-spacing: .3rem;
transition: all .2s;
}
.btn:hover {
background-color: #fff;
color: #000;
}
/* Utility classes */
.u-margin-top-small {
margin-top: 2.5rem;
}
.u-text-align-center {
text-align: center;
}
.u-inline-block {
display: inline-block;
}
/* ------------------------------------- */
/* THE HEADER SECTION */
/* ------------------------------------- */
header {
background-color: #353353;
height: 98vh;
}
.hero-text-box {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}
h2.header-heading {
font-size: 3.5rem;
margin-top: 2rem;
color: #F9F871;
font-weight: 400;
}
/* ------------------------------------- */
/* THE NAVBAR */
/* ------------------------------------- */
.navigation {
position: relative;
padding: 1rem;
border-bottom: .5px solid #777;
transition: background 0.5s;
}
.logo-box {
float: left;
}
.logo {
color: #353353;
text-transform: uppercase;
font-weight: 700;
font-size: 4rem;
letter-spacing: .4rem;
margin-left: 5rem;
}
nav {
padding: 1rem;
}
.navbar {
float: right;
list-style: none;
margin-right: 10rem;
margin-top: 1.5rem;
}
.navbar li {
display: inline-block;
}
.navbar li a {
margin: 0 1rem;
padding: .2rem .6rem;
color: black;
text-transform: uppercase;
border-bottom: 2px solid transparent;
transition: all .3s;
}
.navbar li a:hover {
border-bottom: 2px solid #F9F871;
transition: all .3s;
}
/* The sticky navbar */
.sticky {
position: fixed;
background-color: #353353;
top: 0;
width: 100%;
}
.sticky .navbar-lists {
color: #fff;
}
.sticky .logo {
color: #fff;
}<!DOCTYPE html>
<html lang = "en">
<head>
<!-- Required meta tags -->
<meta charset = "UTF-8">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<meta http-equiv = "X-UA-Compatible" content = "ie=edge">
<!-- Rubik fonts link -->
<link rel = "preconnect" href = "https://fonts.gstatic.com">
<link href = "https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;700&display=swap" rel = "stylesheet">
<!-- CSS links -->
<link rel = "stylesheet" href = "css/normalize.css">
<link rel = "stylesheet" href = "css/styles.css">
<title>Arun Bohra - Design Business Solutions</title>
</head>
<body>
<header>
<div class = "hero-text-box u-text-align-center u-inline-block">
<h1>Hello my name is Arun</h1>
<h2 class = "header-heading u-margin-top-small">I'm a front-end developer</h2>
<a href = "#" class = "btn u-margin-top-small u-inline-block">Who am I</a>
</div>
</header>
<div class = "navigation">
<nav class = "clearfix">
<div class = "logo-box">
<a href = "#" class = "logo">
Arun
</a>
</div>
<ul class = "navbar">
<li><a href = "#" class = "navbar-lists">Home</a></li>
<li><a href = "#" class = "navbar-lists">About me</a></li>
<li><a href = "#" class = "navbar-lists">Skills</a></li>
<li><a href = "#" class = "navbar-lists">Projects</a></li>
<li><a href = "#" class = "navbar-lists">Contact</a></li>
</ul>
</nav>
</div>
<section class = "about-section">
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
</section>
<script src = "js/index.js" charset = "utf-8"></script>
</body>
</html>Не обязательно. Здесь свойство перехода применяется к родительскому элементу, потому что его цвет меняется при прокрутке вниз. Итак, в основном, это применимо к элементу, свойства которого меняются, или к тому, который вы хотите оживить.
Я могу предложить вам поработать с max-height и желаемым transition на вашем навигаторе, проверьте это:
// jshint esversion: 6
window.onscroll = function() { myFunction(); };
let navbar = document.getElementsByClassName("navigation")[0];
let sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky");
// add the ready class after a tiny delay
setTimeout(() => {
navbar.classList.add("ready");
}, 100);
} else {
navbar.classList.remove("sticky");
// don't forget to also remove ready class
navbar.classList.remove("ready");
}
}/* ------------------------------------- */
/* BASIC RESET */
/* ------------------------------------- */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html { font-size: 62.5%; }
body {
box-sizing: inherit;
color: #777;
background-color: #fff;
font-family: 'Roboto', sans-serif;
font-size: 1.8rem;
font-weight: 400;
line-height: 1.5;
}
.clearfix {zoom: 1;}
.clearfix:after {
content: '.';
clear: both;
display: block;
height: 0;
visibility: hidden;
}
/* ------------------------------------- */
/* THE REUSABLE CONTENT */
/* ------------------------------------- */
/* HTML contents */
h1, h2.header-heading, h2 {
margin: 0;
text-transform: uppercase;
}
h1 {
font-size: 4.5rem;
color: #fff;
letter-spacing: .4rem;
word-spacing: .5rem;
font-weight: 300;
}
h2 {
font-size: 3.5rem;
}
/* Links */
a {
text-decoration: none;
display: inline-block;
}
/* Buttons */
.btn {
border: 1px solid #fff;
border-radius: .3rem;
font-size: 1.6rem;
padding: 1.2rem 3.5rem;
text-transform: uppercase;
color: #fff;
background-color: transparent;
font-weight: bold;
letter-spacing: .3rem;
transition: all .2s;
}
.btn:hover {
background-color: #fff;
color: #000;
}
/* Utility classes */
.u-margin-top-small {
margin-top: 2.5rem;
}
.u-text-align-center {
text-align: center;
}
.u-inline-block {
display: inline-block;
}
/* ------------------------------------- */
/* THE HEADER SECTION */
/* ------------------------------------- */
header {
background-color: #353353;
height: 98vh;
}
.hero-text-box {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}
h2.header-heading {
font-size: 3.5rem;
margin-top: 2rem;
color: #F9F871;
font-weight: 400;
}
/* ------------------------------------- */
/* THE NAVBAR */
/* ------------------------------------- */
.navigation {
position: relative;
padding: 1rem;
border-bottom: .5px solid #777;
}
.logo-box {
float: left;
}
.logo {
color: #353353;
text-transform: uppercase;
font-weight: 700;
font-size: 4rem;
letter-spacing: .4rem;
margin-left: 5rem;
}
nav {
padding: 1rem;
}
.navbar {
float: right;
list-style: none;
margin-right: 10rem;
margin-top: 1.5rem;
}
.navbar li {
display: inline-block;
}
.navbar li a {
margin: 0 1rem;
padding: .2rem .6rem;
color: black;
text-transform: uppercase;
border-bottom: 2px solid transparent;
transition: all .3s;
}
.navbar li a:hover {
border-bottom: 2px solid #F9F871;
transition: all .3s;
}
/* The sticky navbar */
.sticky {
position: fixed;
background-color: #353353;
top: 0;
width: 100%;
max-height: 0px; /* set max-height as 0 */
transition: height 1500ms linear; /* define your max-height transition */
}
.sticky.ready {
max-height: 9999px; /* when "ready" the sticky navbar transitions to have a height */
}
.sticky .navbar-lists {
color: #fff;
}
.sticky .logo {
color: #fff;
}<!DOCTYPE html>
<html lang = "en">
<head>
<!-- Required meta tags -->
<meta charset = "UTF-8">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<meta http-equiv = "X-UA-Compatible" content = "ie=edge">
<!-- Rubik fonts link -->
<link rel = "preconnect" href = "https://fonts.gstatic.com">
<link href = "https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;700&display=swap" rel = "stylesheet">
<!-- CSS links -->
<link rel = "stylesheet" href = "css/normalize.css">
<link rel = "stylesheet" href = "css/styles.css">
<title>Arun Bohra - Design Business Solutions</title>
</head>
<body>
<header>
<div class = "hero-text-box u-text-align-center u-inline-block">
<h1>Hello my name is Arun</h1>
<h2 class = "header-heading u-margin-top-small">I'm a front-end developer</h2>
<a href = "#" class = "btn u-margin-top-small u-inline-block">Who am I</a>
</div>
</header>
<div class = "navigation">
<nav class = "clearfix">
<div class = "logo-box">
<a href = "#" class = "logo">
Arun
</a>
</div>
<ul class = "navbar">
<li><a href = "#" class = "navbar-lists">Home</a></li>
<li><a href = "#" class = "navbar-lists">About me</a></li>
<li><a href = "#" class = "navbar-lists">Skills</a></li>
<li><a href = "#" class = "navbar-lists">Projects</a></li>
<li><a href = "#" class = "navbar-lists">Contact</a></li>
</ul>
</nav>
</div>
<section class = "about-section">
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
</section>
<script src = "js/index.js" charset = "utf-8"></script>
</body>
</html>Вы можете точно настроить задержку setTimeout и transition durantion, чтобы получить лучший / более плавный эффект.
Я изменил код, используя flexbox и переходы в заголовке и навигации, чтобы улучшить эффект перехода.
// jshint esversion: 6
window.onscroll = function() { myFunction(); };
let navbar = document.getElementsByClassName("navigation")[0];
let sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky");
} else {
navbar.classList.remove("sticky");
}
}/* ------------------------------------- */
/* BASIC RESET */
/* ------------------------------------- */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html { font-size: 62.5%; }
body {
box-sizing: inherit;
color: #777;
background-color: #fff;
font-family: 'Roboto', sans-serif;
font-size: 1.8rem;
font-weight: 400;
line-height: 1.5;
}
.clearfix {zoom: 1;}
.clearfix:after {
content: '.';
clear: both;
display: block;
height: 0;
visibility: hidden;
}
/* ------------------------------------- */
/* THE REUSABLE CONTENT */
/* ------------------------------------- */
/* HTML contents */
h1, h2.header-heading, h2 {
margin: 0;
text-transform: uppercase;
}
h1 {
font-size: 4.5rem;
color: #fff;
letter-spacing: .4rem;
word-spacing: .5rem;
font-weight: 300;
}
h2 {
font-size: 3.5rem;
}
/* Links */
a {
text-decoration: none;
display: inline-block;
}
/* Buttons */
.btn {
border: 1px solid #fff;
border-radius: .3rem;
font-size: 1.6rem;
padding: 1.2rem 3.5rem;
text-transform: uppercase;
color: #fff;
background-color: transparent;
font-weight: bold;
letter-spacing: .3rem;
transition: all .2s;
}
.btn:hover {
background-color: #fff;
color: #000;
}
/* Utility classes */
.u-margin-top-small {
margin-top: 2.5rem;
}
.u-text-align-center {
text-align: center;
}
.u-inline-block {
display: inline-block;
}
/* ------------------------------------- */
/* THE HEADER SECTION */
/* ------------------------------------- */
header {
background-color: #353353;
height: 98vh;
}
.hero-text-box {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}
h2.header-heading {
font-size: 3.5rem;
margin-top: 2rem;
color: #F9F871;
font-weight: 400;
}
/* ------------------------------------- */
/* THE NAVBAR */
/* ------------------------------------- */
.navigation {
display: flex;
justify-content: center;
align-items: center;
position: relative;
border-bottom: .5px solid #777;
box-sizing: border-box;
height: 80px;
transition: all .5s;
padding: 1rem;
}
.logo-box {
float: left;
}
.logo {
color: #353353;
text-transform: uppercase;
font-weight: 700;
font-size: 4rem;
letter-spacing: .4rem;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
width: 100%;
height: 50px;
}
.navbar {
float: right;
list-style: none;
}
.navbar li {
display: inline-block;
}
.navbar li a {
margin: 0 1rem;
padding: .2rem .6rem;
color: black;
text-transform: uppercase;
border-bottom: 2px solid transparent;
transition: all .3s;
}
.navbar li a:hover {
border-bottom: 2px solid #F9F871;
transition: all .3s;
}
/* The sticky navbar */
.sticky {
position: fixed;
background-color: #353353;
top: 0;
width: 100%;
height: 50px;
padding: 0rem 1rem;
}
.sticky .navbar-lists {
color: #fff;
}
.sticky .logo {
color: #fff;
}<!DOCTYPE html>
<html lang = "en">
<head>
<!-- Required meta tags -->
<meta charset = "UTF-8">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<meta http-equiv = "X-UA-Compatible" content = "ie=edge">
<!-- Rubik fonts link -->
<link rel = "preconnect" href = "https://fonts.gstatic.com">
<link href = "https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;700&display=swap" rel = "stylesheet">
<!-- CSS links -->
<link rel = "stylesheet" href = "css/normalize.css">
<link rel = "stylesheet" href = "css/styles.css">
<title>Arun Bohra - Design Business Solutions</title>
</head>
<body>
<header>
<div class = "hero-text-box u-text-align-center u-inline-block">
<h1>Hello my name is Arun</h1>
<h2 class = "header-heading u-margin-top-small">I'm a front-end developer</h2>
<a href = "#" class = "btn u-margin-top-small u-inline-block">Who am I</a>
</div>
</header>
<div class = "navigation">
<nav class = "clearfix">
<div class = "logo-box">
<a href = "#" class = "logo">
Arun
</a>
</div>
<ul class = "navbar">
<li><a href = "#" class = "navbar-lists">Home</a></li>
<li><a href = "#" class = "navbar-lists">About me</a></li>
<li><a href = "#" class = "navbar-lists">Skills</a></li>
<li><a href = "#" class = "navbar-lists">Projects</a></li>
<li><a href = "#" class = "navbar-lists">Contact</a></li>
</ul>
</nav>
</div>
<section class = "about-section">
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
<h2>Who am I</h2>
</section>
<script src = "js/index.js" charset = "utf-8"></script>
</body>
</html>
Спасибо! Я предполагаю, что в любом случае мы всегда должны применять свойство перехода к родительскому элементу. Это правильно?