Fix nav on destop

This commit is contained in:
Dávid Jančár 2024-05-16 09:28:52 +02:00
parent 46f859bed8
commit 9ef94f51b6

@ -1,7 +1,8 @@
body{ body {
min-width: 100%; min-width: 100%;
margin: 0; margin: 0;
} }
.wrapper { .wrapper {
display: flex; display: flex;
flex-flow: row wrap; flex-flow: row wrap;
@ -10,12 +11,12 @@ body{
background-color: #333333; background-color: #333333;
} }
.wrapper > * { .wrapper>* {
/*padding: 10px;*/ /*padding: 10px;*/
flex: 1 100%; flex: 1 100%;
} }
.container{ .container {
/* We first create a flex layout context */ /* We first create a flex layout context */
display: flex; display: flex;
@ -35,7 +36,7 @@ body{
min-width: auto; min-width: auto;
} }
.container_menu{ .container_menu {
/* We first create a flex layout context */ /* We first create a flex layout context */
display: flex; display: flex;
@ -56,7 +57,7 @@ body{
} }
/******* header *******/ /******* header *******/
header{ header {
background-color: #151b54; background-color: #151b54;
} }
@ -73,18 +74,19 @@ header{
} }
#header p{ #header p {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
/* navigation */ /* navigation */
/* Add a black background color to the top navigation */ /* Add a black background color to the top navigation */
nav{ nav {
background-color: #333; background-color: #333;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
} }
.topnav { .topnav {
background-color: #333; background-color: #333;
overflow: hidden; overflow: hidden;
@ -134,7 +136,7 @@ nav{
position: absolute; position: absolute;
background-color: #f9f9f9; background-color: #f9f9f9;
min-width: 160px; min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1; z-index: 1;
} }
@ -149,7 +151,8 @@ nav{
} }
/* Add a dark background on topnav links and the dropdown button on hover */ /* Add a dark background on topnav links and the dropdown button on hover */
.topnav a:hover, .dropdown:hover .dropbtn { .topnav a:hover,
.dropdown:hover .dropbtn {
background-color: #555; background-color: #555;
color: white; color: white;
} }
@ -165,21 +168,32 @@ nav{
display: block; display: block;
} }
main main {
{
background-color: #eeeeee; background-color: #eeeeee;
} }
.topnav.responsive .dropdown-content {
position: relative;
display: flex;
flex-direction: column;
max-height: 0;
}
.dropbtn:hover + .dropdown-content {
max-height: unset;
}
/* Medium screens */ /* Medium screens */
@media all and (max-width: 600px) { @media all and (max-width: 600px) {
/******* header *******/ /******* header *******/
#header { #header {
/* When on medium sized screens, we center it by evenly distributing empty space around items */ /* When on medium sized screens, we center it by evenly distributing empty space around items */
flex-flow: column wrap; flex-flow: column wrap;
} }
#header .flex-item{ #header .flex-item {
padding: 2px; padding: 2px;
margin: 2px; margin: 2px;
line-height: 25px; line-height: 25px;
@ -195,12 +209,14 @@ main
/* Small screens */ /* Small screens */
@media all and (max-width: 500px) { @media all and (max-width: 500px) {
/******* header *******/ /******* header *******/
#header { #header {
/* On small screens, we are no longer using row direction but column */ /* On small screens, we are no longer using row direction but column */
flex-flow: column wrap; flex-flow: column wrap;
} }
#header .flex-item{
#header .flex-item {
padding: 2px; padding: 2px;
margin: 2px; margin: 2px;
line-height: 25px; line-height: 25px;
@ -210,40 +226,49 @@ main
/******* navigation *******/ /******* navigation *******/
/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */ /* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
.topnav a:not(:first-child), .dropdown .dropbtn { .topnav a:not(:first-child),
.dropdown .dropbtn {
display: none; display: none;
} }
.topnav a.icon { .topnav a.icon {
float: right; float: right;
display: block; display: block;
} }
.container_menu{ .container_menu {
display: flex; display: flex;
flex-flow: row; flex-flow: row;
} }
/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */ /* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
.topnav.responsive {position: relative;} .topnav.responsive {
position: relative;
}
.topnav.responsive a.icon { .topnav.responsive a.icon {
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
} }
.topnav.responsive a { .topnav.responsive a {
float: none; float: none;
display: block; display: block;
text-align: left; text-align: left;
} }
.topnav.responsive .dropdown {float: none;}
.topnav.responsive .dropdown-content {position: relative;} .topnav.responsive .dropdown {
float: none;
}
.topnav.responsive .dropdown .dropbtn { .topnav.responsive .dropdown .dropbtn {
display: block; display: block;
width: 100%; width: 100%;
text-align: left; text-align: left;
} }
.responsive{ .responsive {
display: flex; display: flex;
flex-flow: column; flex-flow: column;
} }