Line 1: | Line 1: | ||
{{Linkoping_Sweden/Header}} | {{Linkoping_Sweden/Header}} | ||
+ | <!DOCTYPE html> | ||
<html> | <html> | ||
− | |||
<head> | <head> | ||
<style> | <style> | ||
body {margin:0;} | body {margin:0;} | ||
− | .topnav { | + | /* Add a background color to the top navigation */ |
+ | .topnav, uses { | ||
overflow: hidden; | overflow: hidden; | ||
− | background-color: # | + | background-color: #333; |
} | } | ||
+ | |||
+ | /* Style the links inside the navigation bar, used my non-lists/non-buttons */ | ||
.topnav a { | .topnav a { | ||
float: left; | float: left; | ||
display: block; | display: block; | ||
− | color: | + | color: #f2f2f2; |
text-align: center; | text-align: center; | ||
padding: 14px 16px; | padding: 14px 16px; | ||
text-decoration: none; | text-decoration: none; | ||
font-size: 17px; | font-size: 17px; | ||
− | |||
} | } | ||
+ | /* Change the color of links on hover, uses */ | ||
.topnav a:hover { | .topnav a:hover { | ||
− | background-color: | + | background-color: green; |
− | color: | + | color: black; |
− | + | ||
} | } | ||
+ | /* Hide the link that should open and close the topnav on small screens */ | ||
.topnav .icon { | .topnav .icon { | ||
display: none; | display: none; | ||
} | } | ||
+ | /* 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) */ | ||
@media screen and (max-width: 600px) { | @media screen and (max-width: 600px) { | ||
.topnav a:not(:first-child) {display: none;} | .topnav a:not(:first-child) {display: none;} | ||
Line 41: | Line 45: | ||
} | } | ||
+ | /* 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) */ | ||
@media screen and (max-width: 600px) { | @media screen and (max-width: 600px) { | ||
.topnav.responsive {position: relative;} | .topnav.responsive {position: relative;} | ||
Line 56: | Line 61: | ||
} | } | ||
− | + | /*Full container box, not used*/ | |
− | + | .container { | |
− | + | overflow: hidden; | |
− | + | background-color: #333; | |
− | + | font-family: Arial; | |
− | . | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | + | /*Text color for non-dropdown text, not used*/ | |
− | + | .container a { | |
− | + | float: left; | |
− | + | font-size: 16px; | |
− | + | color: white; | |
− | . | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | color: | + | |
text-align: center; | text-align: center; | ||
padding: 14px 16px; | padding: 14px 16px; | ||
Line 91: | Line 78: | ||
} | } | ||
− | + | /* LIST */ | |
− | + | /* The container <div> - needed to position the dropdown content, uses */ | |
− | + | .dropdown { | |
+ | float: left; | ||
+ | /*overflow: hidden;*/ | ||
+ | } | ||
+ | /* Dropdown Button, uses */ | ||
+ | .dropdown .dropbtn { | ||
+ | font-size: 16px; | ||
+ | border: none; | ||
+ | outline: none; | ||
+ | color: white; | ||
+ | padding: 14px 16px; | ||
+ | background-color: inherit; /*inherited from .topnav*/ | ||
} | } | ||
− | + | /* Background color when hovering, uses */ | |
− | + | .container a:hover, .dropdown:hover .dropbtn { | |
+ | background-color: blue; | ||
} | } | ||
− | + | /* Dropdown Content (Hidden by Default), uses */ | |
+ | .dropdown-content { | ||
display: none; | display: none; | ||
position: absolute; | position: absolute; | ||
− | background-color: # | + | 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; | |
} | } | ||
− | + | /* Links inside the dropdown, uses */ | |
− | color: | + | .dropdown-content a { |
+ | float: none; | ||
+ | color: black; | ||
padding: 12px 16px; | padding: 12px 16px; | ||
text-decoration: none; | text-decoration: none; | ||
display: block; | display: block; | ||
− | text-align: | + | text-align: left; |
} | } | ||
− | + | /* Change color of dropdown links on hover, uses */ | |
+ | .dropdown-content a:hover { | ||
+ | background-color: #ddd; | ||
+ | } | ||
+ | |||
+ | /* Show the dropdown menu on hover */ | ||
+ | .dropdown:hover .dropdown-content { | ||
display: block; | display: block; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | |||
− | |||
− | |||
</style> | </style> | ||
</head> | </head> | ||
<body> | <body> | ||
− | |||
<div class="topnav" id="myTopnav"> | <div class="topnav" id="myTopnav"> | ||
− | + | <a href="#home">Home</a> | |
− | + | <a href="#news">News</a> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <div class="dropdown"> | |
− | < | + | <button class="dropbtn">DropdownX</button> |
− | <div class=" | + | <div class="dropdown-content"> |
− | <a href="#"> | + | <a href="#">Link 1</a> |
− | <a href="#"> | + | <a href="#">Link 2</a> |
− | <a href="#"> | + | <a href="#">Link 3</a> |
</div> | </div> | ||
− | </ | + | </div> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">☰</a> | <a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">☰</a> | ||
− | |||
</div> | </div> | ||
Line 183: | Line 155: | ||
<script> | <script> | ||
+ | /* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */ | ||
function myFunction() { | function myFunction() { | ||
var x = document.getElementById("myTopnav"); | var x = document.getElementById("myTopnav"); | ||
Line 192: | Line 165: | ||
} | } | ||
</script> | </script> | ||
− | + | ||
</body> | </body> | ||
+ | </html> | ||
Line 259: | Line 233: | ||
------------------------------------------------------------------------------- --> | ------------------------------------------------------------------------------- --> | ||
− | |||
{{Linkoping_Sweden/Footer}} | {{Linkoping_Sweden/Footer}} |
Revision as of 13:00, 19 June 2017