What is the best way to expand the navigation bar: should I add a side div or incorporate a background image?

I am encountering two issues that I need help solving.

My first problem involves stretching out the navigation bar to fill the height and length of the adjacent div (div#textarea) while also keeping the text of the menu centered within that div.

The second problem pertains to creating a side bar on the right side of the page. I'm unsure whether I should use another div for this or opt for a full background image with a different color for the side bar against a white backdrop.

Attached is an image demonstrating what I have accomplished so far, featuring red lines indicating my desired layout:

(The purple div at the bottom was originally intended as the side bar; I added some text inside for visibility)

To sum it up, I have the following questions:

  1. How can I extend the navigation bar in terms of length and height?
  2. Should I use a separate side div, a background image, or perhaps consider alternative options? (Please note that the logo image on the top right corner is only partially visible)

body {
  background-color: gray;
}
#page {
  margin: 0 auto;
  word-wrap: break-word;
}
#nav,
#textarea,
#contactallpages {
  display: inline-block;
}
#containerpage {
  display: inline-block;
  margin: auto;
  text-align: center;
}
#centercontainer {
  background-color: lightblue;
  width: 85%;
  margin: 0 auto;
  padding: 0.5%;
}
#nav {
  background: #aaaaaa;
  width: 10%;
  padding: 1%;
  border-radius: 25% 0% 0% 0%;
  text-align: center;
  vertical-align: bottom;
}
#textarea {
  background: #cccccc;
  height: 70%;
  width: 60%;
  padding-top: 5%;
  padding: 3%;
  border-radius: 0% 10% 0% 0%;
  text-align: left;
}
#contactallpages {
  background: #bbbbbb;
  vertical-align: bottom;
  width: 10%;
  padding: 1%;
  font-size: 0.8em;
  border-radius: 0% 5% 25% 0%;
}
#purplebanner {
  background-color: purple;
}
<div id="containerpage">
  <div id="centercontainer">
    <div id="nav">
      <ul>
        <li><a href="index.html" class="selected">Home</a>
        </li>
        <li><a href="#">About me</a>
        </li>
        <li><a href="#">more</a>
        </li>
        <li><a href="#">links</a>
        </li>
        <li><a href="#">in menut</a>
        </li>
      </ul>
    </div>
    <!--

        -->
    <div id="textarea">
      <header>
        <h1>Welcome</h1>
      </header>
      <p>
        text text text
      </p>
      <p>
        text text text
      </p>
    </div>
    <!--

        -->
    <div id="contactallpages">
      Contact info
      <br>Name person
      <br>
      <br>Address
      <br>more lines
      <br>
      <br>
      <u>Telephone:</u>
      <br>numbers
      <br>
      <u>E-mail:</u>
      <br>address thingey
    </div>

  </div>

  <div id="purplebanner">
    text
  </div>

</div>

Answer №1

If you're looking to tackle question 1, one approach could be adding an overflow: hidden; property to your main page container, and then dividing the second container (#centercontainer) into separate sections. Consider placing navigation elements in their own container (perhaps #container_left) with a float: left; style. Next, organize remaining content in another container (maybe #container_right) and apply float: left; to it as well.

For visual assistance, try applying border: 1px solid red; to all containers to visually see the position of each div.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm having trouble getting my HTML to scroll properly

Apologies for asking a common question, but I'm facing a specific issue with scrolling that I can't seem to figure out. Below is the code snippet: * { font-family: Arial, Helvetica, sans-serif; text-align: center; font-size: 40px; } < ...

Creating Transparent Rounded Backgrounds in Google Chrome Packaged Apps: Achieving the same look as Google Hangout app

Looking at the screenshot below, it is evident that the Hangout app has a fully transparent design with background shadow effect applied to it. I have tried various methods in vain, such as applying CSS styling to the "html" and "body" tags of the page, a ...

How come my gifs appear tiny even though I've adjusted their width to 32% each?

I am trying to display three gifs in a row, each taking up one-third of the width of the page. However, when I preview the page, the gifs appear tiny. I have set the divs to 32% each and the gifs should fill 100% of their respective div. Here is the code s ...

Automated logout feature will be enabled if no user interaction is detected, prompting a notification dialog box

Here is my working script that I found on this site. After a period of idle time, an alert message will pop up and direct the user to a specific page. However, instead of just the alert message, I would like to implement a dialog box where the user can ch ...

How can jQuery help me load a lengthy webpage with various backgrounds that change according to the vertical scroll value?

I have been given a design that is 960px wide and approximately 7000px tall, divided into five segments stacked vertically at random points. There is a fixed sidebar that scrolls to each segment when a navigation link is clicked. The layout includes slider ...

The feature in Chrome that automatically reloads generated CSS is failing to refresh the page after SASS recompiles the CSS

I'm attempting to set up Chrome's DevTools to automatically reload a page when I save changes to a watched SCSS file that compiles and updates the CSS file. Although I have checked the Auto-reload generated CSS option, it is unfortunately not fu ...

utilizing a dynamic value within CSS modules for class naming

Struggling to incorporate a variable into a CSS module class name in Next.js. Finding it challenging to determine the correct syntax. The variable is fetched from the API: const type = red Here's how I'm attempting to achieve it: <div clas ...

Guide on generating a child element in a React application using server response

I have developed a react application with multiple nested routes. One of the nested routes utilizes a backend API that returns complete HTML content. My goal is to display this HTML content with the same styling in my UI without directly manipulating the ...

The modal box should adjust its height to perfectly accommodate the content within

I'm in the process of developing a straightforward modal (popup) window, using as few lines of code as possible... just the basics. The modal has a maximum width of 650px and its height adjusts to fit the content. In case the content exceeds the avai ...

The functionality of CSS columns is not supported in Firefox browser

Currently, I am working on a web page design inspired by Pinterest. However, I have encountered an issue where the columns property is not functioning properly in Firefox. You can find the example I am trying to replicate here. Feel free to test it in Fir ...

Looking to incorporate multiple accordion drop down menus on your website? Utilize a combination of HTML, CSS, and JavaScript to

I am experiencing a challenge with implementing multiple accordion menus on my website. Whenever I attempt to duplicate the code, the new accordion menu appears but clicking on the first bar simply scrolls me back to the top of the webpage. Below is the H ...

Exploring Data in a Tree View Format on a PHP Website

Looking for advice on displaying categories and corresponding subcategories on the left side of my website (built using Php and Javascript). I would like the tree to be movable, similar to the functionality featured on this link: Any suggestions on how I ...

Tips for Eliminating Unnecessary Space Above the Navigation Bar

I have a problem with the top navbar on my test site. There is some extra space above it that I want to remove so that the navigation extends all the way up to cover the viewport. Here is an image of what I'm trying to achieve: https://i.stack.imgur.c ...

Linking children to their parents in a mat tree structure

I'm looking to create a mat tree based on the provided diagram. So far, I've managed to design the icons and boxes, but I'm struggling with drawing the connecting lines. Can anyone assist me with this part? I'm using a mat nested tree ...

Using the Croppie plugin to crop an image before uploading via jQuery Ajax in PHP

I've successfully implemented a code snippet that allows image cropping using PHP, jQuery, and Ajax with the Croppie plugin. Currently, I'm facing an issue while trying to include additional input values along with the image upload process. I ...

Methods to maintain the select2 dropdown event open while interacting with another select2 dropdown

I have a situation where I need to dynamically add a class to a div whenever a select2 dropdown is open. To achieve this functionality, I am utilizing the open and close events of select2. The current code successfully adds the class when opening a selec ...

What is the best way to disable stacking toasts in bootstrap?

I have been experimenting with stacking Bootstrap toasts, but I am encountering an issue with the close buttons not functioning as expected. Currently, I am only able to close the most recent toast and none of the others. My attempt at adding an event lis ...

Adjusting CSS Div Blocks for Different Screen Sizes

I am currently working on designing a page layout that includes two sidebars and a main article area. My goal is to have the sidebars stack vertically beside the main area when viewed on a tablet or phone, with both eventually moving below it. However, I a ...

What should be done in Android when the app crashes due to incoming HTML content?

If I register using an email and password, the process is successful if the email exists within the domain. However, if a malformed email address like [email protected] is used, it returns HTML and crashes my app. How can I handle this issue? publi ...

Uncovering Twig's Power: Navigating JSON Key Values

In my current project, I am utilizing OctoberCMS and Twig to fetch dynamic data and translations from JSON files for the front end. Here is an example snippet of code: <div class="wrapper items"> <div class="items"> {% for suggestion in ...