Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
May 23, 2026 - @977.50 (what is this?)
Activity rating: Three Stars Posts & Arts: 41/1k.beats Random | Recent Posts | Guild Recents
News: ozwomp is requesting your location :ozwomp: [Agree] Guild Events: Spring Themed Projects

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  how to... make a sidebar!


« previous next »
Pages: [1] Print Embed
Author Topic: how to... make a sidebar!  (Read 792 times)
fairyrune
Full Member ⚓︎
***
View Profile WWWArt


we live to make the impossible possible!
⛺︎ My Room
iMood: fairyrune
Matrix: Chat!

Guild Memberships:
Artifacts:
Dino FossilJoined 2025!
« on: November 04, 2025 @509.10 » Embed

hello everyone! i'm adding a nav bar to my site, but i'm wondering what the best way to do this would be...

so i'm using a main page div, centered, to make all my elements stay in the middle (the flex boxes, headers,etc). what i did with my previous layout was i made a larger flex box with 3 divs inside. say my sidebar wants a div to be 200px wide, and my middle div with all my content wants to be 900px wide. i'd have a div on the opposite side to the sidebar that's also 200px, and center the flexbox i'm using - which makes the middle bit with all the content stay in the centre of the page even with a sidebar!

hope that makes sense. :ozwomp:

but is there a better way to do this? i want my content to remain exactly where it is, but with a navbar to the side of it, like this.

thanks in advance! i feel like there's something else i can do that would be simpler, but i'm not sure what! :drat:


* Screenshot 2025-11-04 111120.png (415.08 kB, 600x298 - viewed 58 times.)
Logged

☾ "you want to run - i'll run with you" ☼
https://files.catbox.moe/ivdca8.gifhttps://files.catbox.moe/qlgdtd.gifhttps://files.catbox.moe/ji1nvt.gifhttps://files.catbox.moe/9ypmrn.gifhttps://files.catbox.moe/3im96c.gif
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
Artifacts:
The Worm is creeping around Melonland profiles!
« Reply #1 on: November 04, 2025 @566.45 » Embed

What you've described sounds like a perfect way to do what you're aiming for.

An alternative might be a grid layout: this would mean that you didn't need the empty "left-hand side" mirror of the sidebar. E.g. assuming you have a <div class="container"> containing a <main> and an <aside> you could do something like this:


Code
.container {
  display: grid;
  grid-template: "unused center sidebar" / 200px 400px 200px;
}

main {
  grid-area: center;
}

aside {
  grid-area: sidebar;
}

This creates an 800px-wide container, reserving 200px for each of two sidebars (called "unused" and "sidebar") and 400px for the "center" column... but then it only attaches things to the "center"  and "sidebar" columns.

I did you a CodePen if that helps explain it.

The end result is basically the same as what you're talking about, though, so just do what makes you most-comfortable!
Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!Polyamorousradio polyBouncy Egg!Rainbow ConnectionJoined 2025!LurbyMessage Buddy
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
Artifacts:
The Worm is creeping around Melonland profiles!
« Reply #2 on: November 04, 2025 @573.83 » Embed

Oh, one more option for you if you either (a) don't care about responsive design or (b) are willing to write some media queries to handle mobiles: you could place the sidebar at an exact position using position: absolute.

E.g. with the same HTML, the CSS could be:


Code
.container {
  position: relative;
}

main {
  width: 400px;
}

aside {
  position: absolute;
  right: -200px;
  top: 0;
  width: 200px;
}

Here's how that works:

  • It sets position: relative on the container so that any inner position: absolute is relative to the container
  • Then it sets position: absolute on the sidebar element
  • Finally, it uses a negative-offset for of right: -200px, which is the width of the sidebar but negative (you can made it a larger negative value to move the sidebar "away" from the main content)

I did you another CodePen.

Just another option to consider!
Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!Polyamorousradio polyBouncy Egg!Rainbow ConnectionJoined 2025!LurbyMessage Buddy
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
Artifacts:
The Worm is creeping around Melonland profiles!
« Reply #3 on: November 04, 2025 @584.90 » Embed

I gave my second suggestion a go with your website (screenshot attached). Here's how I did it:

I added <nav>this is your new nav!</nav> inside your <div class="flexbox">, right at the top.

Then I added this CSS:


Code
.flexbox {
  position: relative;
}

nav {
  position: absolute;
  top: 0;
  right: -225px;
  width: 200px;
  background: #fff7;
  border: 2px solid #19e119;
  min-height: 400px;
  font-size: 24px;
}


* deerlore-sidebar-nav-demo.jpg (159.76 kB, 1167x821 - viewed 47 times.)
Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: I met Dan Q on Melonland!Polyamorousradio polyBouncy Egg!Rainbow ConnectionJoined 2025!LurbyMessage Buddy
fairyrune
Full Member ⚓︎
***
View Profile WWWArt


we live to make the impossible possible!
⛺︎ My Room
iMood: fairyrune
Matrix: Chat!

Guild Memberships:
Artifacts:
Dino FossilJoined 2025!
« Reply #4 on: November 04, 2025 @615.66 » Embed



i guess i was doing something right then :ok: that's good to know! i'll have a test myself with these options and see how it goes. i learn this kind of coding piecemeal as and when i need it, so i thought i might have missed something about how to optimise this.

thank you so much for your time and suggestions!
Logged

☾ "you want to run - i'll run with you" ☼
https://files.catbox.moe/ivdca8.gifhttps://files.catbox.moe/qlgdtd.gifhttps://files.catbox.moe/ji1nvt.gifhttps://files.catbox.moe/9ypmrn.gifhttps://files.catbox.moe/3im96c.gif
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
MelonLand @000

Want to Login or Join ?

Minecraft: Online
Join: craft.melonking.net