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.

Adding a nav issues

Edrol97

Silver Coder
Hi all, I've made a Jokes page for my site, but it aligns a navbar to the left when I try and add it in the body. Does anyone know how I can prevent this?


CSS:
@font-face {
  font-family: Eliot;
  src: url(Fonts/Eliothand2-Regular.otf);
}

@font-face {
  font-family: Eliot Headline;
  src: url(Fonts/EliotHeadline-Regular.ttf);
}

body {
  margin: 0;
  background-image: url(img/background/Laugh.svg);
  background-repeat: repeat;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: monospace;
}

button {
  cursor: url(img/background/cursors/pointer1.png), pointer;
}

.jokecontainer {
  background-color: rgba(255, 255, 255, 0.8);
  padding: 20px;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 1);
  border-radius: 15px;
  width: 85%;
  text-align: center;
  color: black;
}

.heading {
  font-size: 25px;
  font-weight: 200;
  font-family: Eliot Headline;
  text-shadow: 5px 5px 2px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
}

.joke {
  font-family: Eliot;
  font-size: 40px;
  font-weight: 500;
  margin: 40px;
}

.btn {
  font-size: 18px;
  font-weight: 700;
  border-radius: 5px;
  cursor: pointer;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  width: 300px;
  color: darkgreen;
}

.btn:hover {
  background-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.3);
  transition: all 300ms ease;
  cursor: url(img/background/cursors/pointer1.png), pointer;
}

Here's a link with minimal JS on it and no JSON
 
Last edited:
@Edrol97 A bit tough without a page to inspect, but a quick look makes me thing it's because you have display: flex; on the body and by default, flex-direction is row.
Taking off flex mucks it up though with the body. This is how it should look. Screenshot 2025-03-17 at 16.55.55.webp
And this is what it becomes when taking flex off the even if the same settings are added to the individual divs
Screenshot 2025-03-17 at 16.55.35.webp
The former is how I want it to look, although I don't know how I get this without the navbar going wrong.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom