positioning of content on the left, right, and center

My task involves using CSS to adjust the positions of various elements on a webpage. Currently, the right position navigation bar and the liquid layout are working fine, but the positioning of the "content" and "right navigation bar" is not correct. I aim to have the content centered, the left navigation on the left, and the right navigation on the right.

<title>CSS Liquid Layout</title>


 <style type="text/css">

.due {
color: #ff0000;
font-weight: bold;
}

#leftnavigation{
position:absolute;
left:10px;
top:10px;
width:250px;
}

#rightnavigation {
float:right;
width:250px;
height:800px;
} 
#content {
float:center;

}
    </style>
</head>
<body leftmargin="0" topmargin="0" bgcolor="#ccff99">
    <div id="app">
        <div id="rightnavigation">
            <h1>Right Navigation</h1>
            <a href="http://www,google.com">link</a> <a href="http://www,google.com">Instructor</a>
            <a href="http://www,google.com">Course</a> <a href="http://www,google.com">
                Resume
                project
            </a>
        </div>
        <div id="content">
            <h1>Sample Content</h1>
            <p>
                This is the content section of the page. Use structural markup
                like &lt;p&gt;&lt;/p&gt;
                to keep the page valid in XHTML.
            </p>
            <h2>Lorem Ipsum</h2>
        </div>
        <div id="leftnavigation">
            <h1>Left Navigation</h1>
            <p>
                <a href="http://www,google.com">Page 1</a> <a href="http://www,google.com">Page 2</a> <a href="http://www,google.com">
                    Page
                    3
                </a> <a href="http://www,google.com">Page 4</a> <a href="http://www,google.com">Page 5</a> <br />
                Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. Lorem ipsum sit dolor
                amum.
            </p>
            <h2>Lorem Ipsum</h2>
        </div>
    </div>

Answer №1

Give this a shot:

Customized CSS

.app {
    width: 100%
    height: 100%;
}

.due {
    color: #ff0000;
    font-weight: bold;
}

#rightnavigation {
    float: left;
    width: 33.333%;  
} 

#leftnavigation{
    float: left;
    width: 33.333%;

}

#content {
    float: left;
    width: 33.333%;
}

Modified HTML

<div class="app">

    <div id="leftnavigation">
        <h1> Left Navigation </h1>
    </div>

    <div id="content"></div>

    <div id="rightnavigation"> 
        <h1>Right Navigation</h1>
    </div>

</div>

View the live demonstration of this solution here - EXAMPLE

Answer №2

To achieve the desired outcome, it is important to address the errors present in your HTML and CSS before making any style changes.

  1. Within your HTML, there are unclosed tags that need attention. Specifically, the <div id="rightnavigation"> tag remains open, causing styles intended for #rightnavigation to affect the entire page.

  2. In your CSS, a style is applied to div.content, but the div actually has an id of content rather than a class. The correct identifier should be div#content.

  3. Furthermore, the div with the id leftnavigation is assigned a position value of "left" in your CSS, which should be changed to "absolute".

  4. After resolving these issues, you can ensure that the left navigation appears on the left, the content is centered, and the right navigation aligns to the right side. If the center content overlapping the right navigation is unintended, you can adjust the widths and positions of the sections based on their neighboring elements without modifying the HTML any further.

Your HTML:

<div id="rightnavigation"> 
    <h1>Right Navigation</h1>
</div>
<div id="content">
    <h1>Sample Content</h1>
    <p>This is the content section of the page. Use structural markup
    like &lt;p&gt;&lt;/p&gt;
    to keep the page valid in XHTML.</p>
    <p>The styled document should  look like your printed version/screenshot.  
    Add styles to the left navigation links to give them borders and a 
    background color that changes when moused over (hint: Define navigation 
    links as display:block;). For the right side links, use a different 
    background color change and border as ashown.  
    Make the center column "liquid" or "elastic." Use an external (linked) 
    CSS file. Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. 
    Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. Lorem ipsum sit 
    dolor amum. 
    Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. </p>

    <h2>Lorem Ipsum</h2>
    <p> Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. 
    Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. 
    Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. </p>
    <p><span class="due">Due Tuesday, September 22.</span> Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. 
    Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. 
    Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. </p>
</div>
<div id="leftnavigation"> 
    <h1>Left Navigation</h1> 
    <p><br>Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. Lorem ipsum sit dolor amum. </p>
    <h2>Lorem Ipsum</h2>
</div>

Your CSS:

#rightnavigation {
    position: absolute;
    top: 50px;
    right: 0px;
    width: 25%;
} 

#content {
    position: absolute;
    top: 50px;
    left: 25%;
    width: 50%;
}

#leftnavigation{
    position: absolute;
    top: 50px;
    left: 0px;
    width: 25%;
}

.due {
    color: #ff0000;
    font-weight: bold;
}

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

Angular 8 dropdown menu that closes when clicking outside of it

Hello, I am currently using the click function on the p tag. When a user opens the dropdown menu, I want to close it when they click outside of it in Angular. Here is the HTML code: <div class="select_cat"> <p class="cat_name" (click)="openC ...

What is the best way for me to make my hamburger animation play in reverse?

Having trouble achieving smooth animation effects. I've designed a burger icon using three divs: <div class="container"> <div class="burger-contain"> <div id="line-1" class="line"></div> <div id="line-2" class="lin ...

Tips for creating a horizontally scrolling div

Here is the CSS for the div that needs to be able to scroll horizontally: .form-holder{ padding-left: 20px; width: auto; background: ; overflow-x: auto; max-height: 300px; padding-bottom: 30px; } Every ...

The way Chrome and Firefox interpret zoom varies. What is the best approach to manage this discrepancy in my CSS?

Currently, I am in the process of designing a webpage that features a logo and a menu in the header section. However, I have noticed an issue where, upon zooming in or out, some of the menu items shift to a second row instead of remaining on a single row a ...

``There Seems to be an Issue with Loading Content in Tabs

Hey! I'm encountering an issue with my jquery tabs. The first tab content loads fine, but when I select another tab, the content doesn't display. Then, when I try to go back to the first tab, it doesn't load either. Here's the HTML cod ...

steps for executing a Google script

In my program, the structure is as follows: // JavaScript function using Google Script 1. function F1() { ...... return (v1); } // HTML code for Google 1. <script> 2. function F2() { 3. alert ( 1 ); 4. function F2(); 5. alert ( 2 ); 6 ...

Div with sidebar that sticks

I am currently working on setting up a website with a sticky sidebar. If you would like to see the page, click this link: On a specific subpage of the site, I am attempting to make an image Validator sticky, but unfortunately, it's not functioning a ...

Referencing another component in StyledComponents

I'm looking to modify the properties of my parent component's :after selector whenever the child element is focused. It seemed straightforward at first, but for some reason, I just can't seem to make it work. Here's a glimpse of my comp ...

How can I determine the mouse's location relative to the bottom right corner of the

Currently, I am in the process of writing jQuery code that will detect if the mouse is positioned near the bottom or right side of a window, and then adjust the tooltip's position accordingly. This becomes crucial because the table in which these tool ...

Error message in console: AngularJS throws an error saying 'No module found: uiCropper'

Hey there, I'm looking to add an image cropper to my webpage. I came across some code on Codepen, but when I tried using it, the code didn't work and I encountered this error https://i.sstatic.net/h5F4T.png angular.module('app', [&ap ...

Styling elements conditionally with AngularJS-controlled CSS

Looking for some guidance in Angular as a newcomer. I am attempting to adjust a style when clicked. On my page, I have multiple content spaces created using the same template. Upon clicking a "more" link, I desire to expand that specific section. I have ac ...

The forward button is malfunctioning after using history.pushState

I have managed to resolve issues with the back button, however, I am still unable to fix the forward button. Despite the URL changing, the page does not reload. Here is the code snippet that I am currently using: $('.anchor .wrapper').css({ &a ...

Using jQuery to create a div that animates when scrolling

Recently, I came across this interesting code snippet: $(document).ready(function(){ $(window).scroll(function(){ if($("#1").offset().top < $(window).scrollTop()); $("#1").animate({"color":"#efbe5c","font-size":"52pt", "top":"0", "position":"fix ...

grid causing images to display incorrectly in incorrect positions

My project consists of 3 component files and a CSS file, but I am facing an issue where the Tiles are slightly off in their positioning towards the top left corner. Although no errors are being thrown, upon using the view grid feature in Firefox, it is ev ...

Rotating 3D cube with CSS, adjusting height during transition

I'm attempting to create a basic 2-sided cube rotation. Following the rotation, my goal is to click on one of the sides and have its height increase. However, I've run into an issue where the transition occurs from the middle instead of from the ...

Tips on updating CSS styles for navigation bar links in real time

Currently, my homepage displays a CSS content hover effect when the user interacts with the icons. However, I am facing an issue where all icons show the same text "home" on hover. How can I customize the text output for each individual icon/link? Your hel ...

What is the proper way to add comments within CSS code inline?

Can anyone provide instructions on how to comment an inline css property, such as height, in the following code snippet? <div style="width:100%; height:30%;"> Any help is appreciated. Thank you! ...

Tips for maintaining consistent width of a div:

My current project involves designing a website that displays various quotes, with each quote rotating for a specific amount of time. However, I'm facing an issue where upon loading the page, the first quote triggers the appearance of a scrollbar, mak ...

Using XPath in Selenium to locate elements that are siblings and have multiple children

I hope I have presented my problem/question clearly. Below is the HTML code I am working with: <div class="class-div"> <label class="class-label"> <span class="class-span">AAAA</span> </label> <div class="class-div-a"&g ...

How can I make my webpage fill the entire width of an iPhone screen when in landscape mode using Angular or React?

While testing my website on my iPhone, I noticed a significant gap appearing on either side of the app in landscape view in Safari. Is there a solution to fix this issue? The problem occurs in both Angular and React applications, examples of which are disp ...