Skip to content

Commit

Permalink
Рефакторинг демки
Browse files Browse the repository at this point in the history
  • Loading branch information
reznikovAndrey committed Aug 6, 2024
1 parent c8989b4 commit 01bd300
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions css/mobile-first-vs-desktop-first/demos/adaptive-navbar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="ru">

<head>
<title>Адаптивная верстка - Mobile-first vs Desktop-first - Дока</title>
<title>Адаптивная вёрстка - Mobile-first vs Desktop-first - Дока</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
Expand Down Expand Up @@ -51,11 +51,11 @@
padding: 8px;
}

.toggle-icon {
.burger-icon {
cursor: pointer;
}

.toggle-icon:hover,
.burger-icon:hover,
a:hover {
opacity: .5;
transition: opacity 100ms ease-in-out;
Expand Down Expand Up @@ -95,12 +95,12 @@

#flex-direction,
#current-screen-width,
#toggle-icon {
#burger-icon {
text-decoration: underline;
}

@media (width >=640px) {
.toggle-icon {
.burger-icon {
display: none;
}

Expand All @@ -115,7 +115,7 @@
<body>
<header>
<nav class="navbar">
<i class="fa fa-bars toggle-icon" onclick="handleClick(this)"></i>
<i class="fa fa-bars burger-icon" onclick="handleClick(this)"></i>
<ul class="navbar__links_list">
<li>
<a href="#" class="link_active">Интересные факты</a>
Expand Down Expand Up @@ -154,20 +154,19 @@ <h3>Текущая ширина экрана:

<br />

<div>.toggle-icon {</div>
<div>.burger-icon {</div>
<div>&nbsp;&nbsp; display:
<span id="toggle-icon"></span>;
<span id="burger-icon"></span>;
</div>
<div>}</div>
</div>
</main>

<script>
const toggleIcon = document.querySelector('i');
const linksList = document.querySelector('ul');
const flexDirection = document.getElementById('flex-direction');
const screenWidth = document.getElementById('current-screen-width');
const toggleIconStyle = document.getElementById('toggle-icon')
const burgerIconStyle = document.getElementById('burger-icon')

let isOpen = false;

Expand All @@ -182,11 +181,11 @@ <h3>Текущая ширина экрана:
linksList.classList.remove('navbar__links_list_hidden')
linksList.classList.add('navbar__links_list_showed')
flexDirection.innerText = 'row'
toggleIconStyle.innerText = 'none'
burgerIconStyle.innerText = 'none'

} else {
flexDirection.innerText = 'column'
toggleIconStyle.innerText = 'inherit'
burgerIconStyle.innerText = 'initial'

if (!isOpen) {
linksList.classList.remove('navbar__links_list_showed')
Expand Down

0 comments on commit 01bd300

Please sign in to comment.