Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

HTML & CSS Getting correct NavBar width

Hi everyone,

it's time for me to get some help again.
It's about the same navBar element that I've already asked for help with on another project a while ago. Now I'm reusing this element, but it's gonna drive me crazy.

The issue now is that the new website I'm working on has a centered fixed max-width of 60em, as you can see here:

Code:
html {
    font-family: Georgia, Ubuntu, Roboto;
    margin: 0;
    line-height: 1.15;
    word-wrap: break-word;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background-color: #f0f0f0;
    scroll-behavior: smooth;
}

body {
    margin: 0 auto;
    min-height: 100vh;
    max-width: 60em;
    border: 1px solid #222;
    border-radius: 0;
    background-color: #fff;
    line-height: 1.4;
}

1. Now I have to adjust the navBar element to max-width: 60em as well, so that the navBar fits to the rest of the page. This turned out to be impossible though, with all my attempts I broke another part of the navBar. If you copy the code into a document and render it in a browser you'll see what I mean.

## NavBar:

Code:
<!DOCTYPE html>
<html lang="de" >
<head>
  <meta charset="UTF-8">
  <title>NavBar Debugging</title>
<style>

body {
  background: #020304;
}
body h1 {
  position: fixed;
  top: 0.5em;
  left: 40px;
  z-index: 6;
  font-size: 20px;
  font-weight: 900;
  font-family: sans-serif;
  text-transform: uppercase;
  color: #222;
}

body input + label {
  position: fixed;
  top: 1.5em;
  right: 40px;
  height: 20px;
  width: 15px;
  z-index: 5;
}
body input + label span {
  position: absolute;
  width: 100%;
  height: 2px;
  top: 50%;
  margin-top: -1px;
  left: 0;
  display: block;
  background: #020304;
  transition: 0.5s;
}
body input + label span:first-child {
  top: 3px;
}
body input + label span:last-child {
  top: 16px;
}
body label:hover {
  cursor: pointer;
}
body input:checked + label span {
  opacity: 0;
  top: 50%;
}
body input:checked + label span:first-child {
  opacity: 1;
  transform: rotate(405deg);
}
body input:checked + label span:last-child {
  opacity: 1;
  transform: rotate(-405deg);
}
body input ~ nav {
  background: white;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4em;
  z-index: 3;
  transition: 0.5s;
  transition-delay: 0.5s;
  overflow: hidden;
}
body input ~ nav > ul {
  list-style-type: none;
  text-align: center;
  position: absolute;
  top: 15%;
  left: 10%;
  right: 30%;
}
body input ~ nav > ul > li {
  opacity: 0;
  transition: 0.5s;
  transition-delay: 0s;
}
body input ~ nav > ul > li > a {
  text-decoration: none;
  text-transform: uppercase;
  color: #020304;
  font-weight: 700;
  font-family: sans-serif;
  display: block;
  padding: 30px;
}
body input:checked ~ nav {
  height: 100%;
  transition-delay: 0s;
}
body input:checked ~ nav > ul > li {
  opacity: 1;
  transition-delay: 0.5s;
}

</style>

</head>
<body>

<h1>Logotext</h1>
<input id="burger" type="checkbox" />
<label for="burger">
    <span></span>
    <span></span>
    <span></span>
</label>
<nav>   
  <ul>
    <li><a href="./index.html" target="_blank">Heimat</a></li>
        <li><a href="faq.html" target="_blank">FAQ</a></li>
        <li><a href="about.html" target="_blank">Über</a></li>
        <li><a href="contact.html" target="_blank">Kontakt</a></li>
        <li><a href="content.html" target="_blank">Episoden</a></li>
        <li><a href="imprint.html" target="_blank">Impressum</a></li>
        <li><a href="privacy.html" target="_blank">Datenschutz</a></li>
    </ul> 
</nav>

</body>
</html>

I would be extremely grateful if someone would take care of this issue. On an end note, please remember I'm a beginner with this all and I like to learn, so any general suggestions for code improvements are highly welcomed.
 
No CSS cracks here at the moment? Well, I guess people have other things to do right now like engaging in their pre-christmas activities. Just in case someone does come along, this thread is still valid. In case I find a solution by myself I'll notify this thread. Happy christmas days anyway for everybody!
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom