I'm having trouble finalizing my menu and headings. Whenever I resize the browser window, they shift to the right instead of staying centered as I want them to. I would really appreciate any help with this. Below is the HTML and CSS code.
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {
slideIndex = 1
}
x[slideIndex - 1].style.display = "block";
setTimeout(carousel, 2000);
}
@charset "UTF-8";
/* CSS Document */
body {
width: 100%;
margin: 0, auto;
}
body {
min-width: 100px;
}
body {
background-color: rgba(255, 255, 255, 1.00)
}
body,
h1,
h2,
h3,
p {
font-family: "Verdana", sans-serif;
}
h1 {
font-size: 3em;
text-align: center;
font-weight: lighter;
position: relative;
margin-top: 0px;
margin-bottom: 0px;
}
h2,
h3 {
font-weight: normal;
}
h2 {
font-size: 1.3em;
text-align: fixed;
margin-right: 600px;
margin-bottom: 0px;
margin-top: 0px;
margin-left: 339px;
font-family: "Verdana", sans-serif;
}
h3,
p {
font-size: 1em;
font-family: 100% "Verdana", sans-serif;
margin-left: 339px
}
ul {
font-size: 1.2em;
...
menu li:hover .sub-menu {
z-index: 6;
opacity: 2;
}
.sub-menu {
width: 171px;
padding: 0px 0px;
position: absolute;
top: 44px;
left: 1px;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.2);
background-color: rgba(255, 255, 255, 1.00);
height: 349px;
}
.sub-menu li {
display: block;
font-size: .7em;
color: rgba(135, 135, 135, 1.00);
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background-color: rgba(231, 231, 231, 1.00);
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../../Xavier website styles.css">
</head;
<body>
<header>
<h1><a href="../../Xavier home:portfolio page.html">Xavier King</a></h1>
</header>
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li><a href="../../Xavier home:portfolio page.html">Portfolio </a></li>
<li>
<a>Projects <span class="arrow">▼</span></a> <ul class="sub-menu">
<li><a href="../freedom/freedom.html">Are We Free?</a></li>
...
</body>
</html>