Как сделать скольжение Topbar вместе с остальной частью страницы?CSS

Разбираемся в CSS
Ответить Пред. темаСлед. тема
Anonymous
 Как сделать скольжение Topbar вместе с остальной частью страницы?

Сообщение Anonymous »

Я делаю веб -сайт, и я не могу заставить Topbar скользить вместе с остальной частью страницы. Раньше это, когда Topbar не прокручивался вместе со страницей, но так как я заставил ее следить за страницей, он больше не делает этого. Если бы кто-то мог бы помочь мне понять это, я бы очень признателен за помощь! />

Код: Выделить всё

/* Set the width of the side navigation to 250px and the left margin of the page content and top bar to 250px */
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}

/* Set the width of the side navigation to 0 and the left margin of the page content and top bar to 0 */
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft = "0";
}< /code>
/* The side navigation menu */
.sidenav {
height: 100%;
/* 100% Full-height */
width: 0;
/* 0 width - change this with JavaScript */
position: fixed;
/* Stay in place */
z-index: 1000;
/* Stay on top */
top: 0;
/* Stay at the top */
left: 0;
background-color: #111;
/* Black*/
overflow-x: hidden;
/* Disable horizontal scroll */
padding-top: 60px;
/* Place content 60px from the top */
transition: 0.5s;
/* 0.5 second transition effect to slide in the sidenav */
}

/* The navigation menu links */
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}

/* When you mouse over the navigation links, change their color */
.sidenav a:hover {
color: #f1f1f1;
}

/* Position and style the close button (top right corner) */
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}

/* Style page content - use this if you want to push the page content to the right when you open the side navigation */
#main {
position: relative;
transition: margin-left .5s ease;
padding: 20px;
z-index: 10;
}

.top-bar {
display: flex;
align-items: center;
/* Vertically center the items */
width: 100%;
position: fixed;
/* Make the bar stick to the top */
top: 0;
left: 0;
z-index: 1000;
/* Ensure it stays above other content */
background-color: beige;
/* Add background color (adjust as needed) */
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
/* Optional shadow for separation */
transition: margin-left 0.5s ease;
/* Add transition for smooth sliding */
}

.logo {
display: block;
margin-left: auto;
margin-right: auto;
}

.openbtn {
margin-left: 40px;
font-size: 20px;
cursor: pointer;
background-color: #111;
color: white;
padding: 10px 15px;
border: none;
border-radius: 5px;
}

.openbtn:hover {
background-color: #444;
}

.user {
margin-right: 40px;
font-size: 20px;
cursor: pointer;
background-color: #111;
color: white;
padding: 10px 15px;
border: none;
border-radius: 5px;
}

.user:hover {
background-color: #444;
}< /code>

[url=javascript:void(0)]×[/url]
[url=/]Home[/url]
[url=#]Men's Shoes[/url]
[url=#]Women's Shoes[/url]
[url=#]Kid's Shoes[/url]
[url=#]About Us[/url]
[url=/faq]FAQ[/url]




☰

[img]img/shoelogo.png[/img]

[url=/login]
★
[/url]


FAQ




Подробнее здесь: https://stackoverflow.com/questions/794 ... f-the-page
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Как сделать скольжение Topbar вместе с остальной частью страницы?
    Anonymous » » в форуме Html
    0 Ответы
    16 Просмотры
    Последнее сообщение Anonymous
  • Как сделать скольжение Topbar вместе с остальной частью страницы?
    Anonymous » » в форуме CSS
    0 Ответы
    16 Просмотры
    Последнее сообщение Anonymous
  • Как сделать скольжение Topbar вместе с остальной частью страницы?
    Anonymous » » в форуме Javascript
    0 Ответы
    6 Просмотры
    Последнее сообщение Anonymous
  • Как сделать скольжение Topbar вместе с остальной частью страницы?
    Anonymous » » в форуме Html
    0 Ответы
    9 Просмотры
    Последнее сообщение Anonymous
  • Curl (возможно) не обновляется вместе с остальной частью xampp
    Anonymous » » в форуме Linux
    0 Ответы
    13 Просмотры
    Последнее сообщение Anonymous

Вернуться в «CSS»