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

Guide on inserting a row into a table class without unique values using jQuery

I have gathered information on stackoverflow regarding how to use jQuery to add a row to a table. $('.myTable').find('tbody:last').append('WHATEVER CODE'); Although this method seems to be effective, I have come across the i ...

Exploring the impact of JavaScript tags on website performance in accordance with W3

While researching website optimization strategies today, I came across an article discussing the benefits of moving JavaScript scripts to the bottom of the HTML page. I am curious if this approach aligns with W3C's recommendations since traditionally ...

Refreshing ng-model within a radio input

Currently, I am utilizing a jQuery library for radio/checkbox components. Although I am aware that combining jQuery with Angular is not ideal, the decision to use this particular library was out of my control and cannot be altered. One issue I have encount ...

What is causing this animation to malfunction?

Could someone assist me in hiding this div-container for a brief period of 2 seconds? If you have any alternative suggestions, feel free to share them but, please refrain from using jQuery or JavaScript. #vcontainer { height: 450px; width: 100%; ba ...

The content of my menu is concealed within a DIV. It may remain hidden or malfunction

I am in the process of creating master pages. In one of the master pages, I have implemented a dropdown menu using jQuery and CSS. While it works perfectly fine on some pages, it seems to be hidden on others that contain a div element. This is because the ...

Developing an interactive input tab for user engagement

I'm in the process of developing a web application for my current university workplace. Currently, I am seeking guidance on how to create a dynamic user input form for our website using asp.net and c# in visual studio 2017. I'm struggling a bit w ...

Removing data entry from MySQL database table using PDO

I'm facing an issue with deleting a row from my database. Despite trying various methods like PDO and MySQL, the data is not getting deleted, but it shows as if it has been deleted. Can someone please help me identify what might be wrong with my code? ...

Experiencing a problem with Datatables where all columns are being grouped together in a single row

After creating a table with one row using colspan and adding my data to the next row, I encountered an issue with the datatables library. An error message appeared in the console: Uncaught TypeError: Cannot set property '_DT_CellIndex' of unde ...

Tips for embedding Jquery code within Vuejs applications

Trying to code a Vue.js Navbar that changes color when scrolling using Jquery and CSS script. It works, but I encountered an error with Vue.js not supporting the syntax '$' after page refresh, resulting in a "$ not defined" error message. As a ne ...

Custom navigation bar created using Bootstrap 4

My webpage was created using Bootstrap 4, but I am having an issue with the navbar toggler not aligning properly within the navbar on mobile view. You can see the problem in the screenshot below: https://i.sstatic.net/aBejI.png If you visit the url for t ...

Steer your keyboard attention towards the parent element that embodies a list

My implementation focuses on making drop down menus accessible via keyboard input using HTML/CSS and JS/jQuery events. The goal of keyboard accessibility includes: Tab key to navigate the menu elements. Pressing the down arrow key opens a focused menu. ...

Switching the navbar image with HTML and JavaScript when clicked

Looking to change the image upon clicking on any of the navbar items. Emulating the navigation bar behavior from this website : This is my current progress : The HTML file : <html lang="en"> <head> <meta charset="utf-8" /> ...

Display the list box against the masked background

I currently have a masked background and a drop-down hidden behind it. Here is how it appears: However, I want it to look like this: This is the HTML code being used: <div id="suggest" style="position: fixed; border: 1px solid rgb(168, 168, 168); w ...

The process of eliminating body padding in Nuxt.js

I'm considering building a website using Nuxt.js because I've heard it's both cool and user-friendly. While I do have some knowledge of vue.js, I'm stuck on a particular issue: How can I remove the padding from the body? I understand ...

How to ensure an element is always aligned at the end of a line in ReactJS, no matter the screen dimensions

I have a unique element that rotates words at a set interval. <div className="inline-block flex justify-center items-center before:content-['lore_ipsum_dolor_lore_ipsum_dolor'] drop-shadow-[0_3px_3px_rgba(0,0,0,1)] t ...

Using jQuery, is there a way to move an element from one div to another, but only if the destination div is currently empty

<div id="apply"></div> <div id="droppable_slots"> <div class="slot 1">1</div> <div class="slot 2">2</div> <div class="slot 3">3</div> </div> Is there a way to utilize jquery in order ...

What is the best way to ensure a grid remains at 100% width when resizing a browser window?

Within the div element, I have two child divs. One has the class col-md-2 and the other has the class col-md-10.Check out a sample view here In the image provided, the div containing hyperlinks (Database edit, invoice, preview) is not taking up 100% width ...

Is it possible to dynamically load records in real time with the help of PHP and jQuery?

I developed a custom system using PHP that allows users to post status messages, similar to a microblog. The system utilizes a database table structured like this: posts_mst ------------------ post_id_pk post_title post_content date_added Initially, I su ...

What is the best way to use jQuery to display the character represented by an ASCII code &###?

Struggling with printing text? I am trying to append some content to an array, but it's showing special characters like &aacute; instead of the actual accented letters. Any suggestions on how to fix this issue? This is for a select tag, so I&apos ...

Prevent fixed element from scrolling beyond a specific point

I'm working on a fixed sidebar that needs to scroll along with the main content and stop at a specific point when scrolling down, and vice versa when scrolling up. I've created a script that calculates the window height, current scroll position ...