Use CSS tables for the navbar

This commit is contained in:
Yorin Anne De Jong 2018-02-13 16:01:19 +01:00
parent 1f2de139eb
commit 84b6b60a37
2 changed files with 29 additions and 20 deletions

View File

@ -32,9 +32,9 @@ function loginBar($sp = 'default-sp') {
$attr = $as->getAttributes(); $attr = $as->getAttributes();
if($attr) { if($attr) {
$uname = $attr['uid'][0]; $uname = $attr['uid'][0];
$result .= "\t<p class=\"login\">logget inn som: " . htmlspecialchars($uname) . "</p>\n"; $result .= "\t<p id=\"login\">logget inn som: " . htmlspecialchars($uname) . "</p>\n";
} else { } else {
$result .= "\t<a class=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">logg inn</a>\n"; $result .= "\t<a id=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">logg inn</a>\n";
} }
$result .= "\t<a href=\"#menu\" id=\"menu_toggle\">MENU<big>&nbsp;&#9776;</big></a>\n"; $result .= "\t<a href=\"#menu\" id=\"menu_toggle\">MENU<big>&nbsp;&#9776;</big></a>\n";

View File

@ -23,33 +23,43 @@ h1, h2, h3, h4, h5, h6, li, a.btn, p.login{
nav, #menu { nav, #menu {
background: #024; background: #024;
padding: 0;
} }
nav { nav {
position: fixed; position: fixed;
width: 100%;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
height: 3em; height: 3em;
display: table;
} }
nav #menu, nav #login {
display: table-cell;
}
nav #login {
text-align: right;
padding: 0 .75em;
margin: 0;
}
nav ul { nav ul {
position: fixed;
top: 0;
left: 0;
right: 0;
margin: .1em auto 0 auto; margin: .1em auto 0 auto;
text-align: center; text-align: center;
margin: 0; margin: 0;
z-index: 3; z-index: 3;
} }
nav li { nav li {
display: inline-block;
margin: auto .25em; margin: auto .25em;
} }
nav #menu_toggle { nav #menu_toggle {
margin: 0; margin: 0;
display: none;
} }
nav li, nav #menu_toggle { nav li, nav #menu_toggle, nav #login {
display: inline-block;
line-height: 3em; line-height: 3em;
height: 3em;
} }
nav a { nav a {
display: inline-block; display: inline-block;
@ -61,22 +71,14 @@ nav a {
nav li.active, nav li:hover { nav li.active, nav li:hover {
border-bottom: 2px solid white; border-bottom: 2px solid white;
} }
nav .login{
position: fixed;
top: .8em;
right: .8em;
margin: auto;
z-index: 3;
color: gray;
}
nav #menu_toggle {
display: none;
}
@media(max-width: 800px){ @media(max-width: 800px){
nav { nav {
z-index: 1000; z-index: 1000;
} }
nav #login {
z-index: 2000;
}
nav li.active, nav li:hover { nav li.active, nav li:hover {
border: none; border: none;
} }
@ -90,6 +92,7 @@ nav #menu_toggle {
} }
nav #menu li, nav #menu li a { nav #menu li, nav #menu li a {
margin-left: 0; margin-left: 0;
display: block;
} }
nav #menu, nav #menu li.active a { nav #menu, nav #menu li.active a {
padding-left: 1em; padding-left: 1em;
@ -109,16 +112,22 @@ nav #menu_toggle {
nav #menu_toggle, nav #menu:target li.active a { nav #menu_toggle, nav #menu:target li.active a {
display: block; display: block;
position: fixed; position: fixed;
top: 0;
left: 0; left: 0;
right: 0; right: 0;
} }
nav #menu_toggle { nav #menu_toggle {
text-align: center; text-align: center;
} }
nav #menu_toggle:hover { nav #menu_toggle:hover, nav #login:hover {
background: rgba(255,255,255,.1); background: rgba(255,255,255,.1);
} }
nav #login {
position: fixed;
right: 0;
top: 0;
}
} }
header { header {
margin-top: 3rem; margin-top: 3rem;