In an HTML setup, would you consider using a two-column layout with the #navigation located on the right side, but

On my website, I have a 2 column layout and I want the navigation section to appear below the main content for SEO purposes in HTML.

However, I encountered an issue - on certain pages, I need to hide the navigation section which results in the content not stretching to 100% width as desired..

Below is the basic code structure:

Page Type 1:

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

Page Type 2:

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

CSS Styling:

#wrap{
   position:relative;
}
#content{
   margin-right:200px;
}
#navigation{
   width:200px;
   position:absolute;
   right:0px;
   top:0px;
}

If you'd like to experiment with it:

http://jsfiddle.net/fWrAu/3/

I managed to resolve this issue using JavaScript, but users without JS enabled may still see the right margin on page type 2.

Answer №1

Typical HTML page structure looks like this:

<div id="wrap">
    <div id="content">CONTENT</div>
    <div id="navigation">NAVIGATION</div>
</div>

CSS:

#wrap{
    position:relative;
    background-color:red;
    }
    #content{
        margin-right:200px;
        background-color:green;
    }
    #navigation{
        width:200px;
        position:absolute;
        right:0px;
        top:0px;
        background-color:blue; 
    }
    #content, #navigation {
        height:700px;
        font-size:24px;
    }

If the navigation is removed, for example on an "about us page" html:

<div id="wrap">
    <div id="content" class="aboutUs">CONTENT</div>
</div>

Then add this css:

.aboutUs {margin-right:0 !important}

demo

Answer №2

Is it possible to make the content width 100% and raise the z-index above the navigation?

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

Excessive CSS overflowing content may result in the appearance of horizontal scrollbars

Looking for help with building a jQuery panel slider on my website. I am not very experienced with JS/Javascript and cannot seem to get rid of the horizontal scrollbar on my site. Check out the demos here! The sliders are located within the Gallery and F ...

The concept of transparency in CSS being utilized on a nested div element

Seeking clarity on the opacity property in CSS. My dilemma involves a header with a title, tinted with an opacity of .3 (in addition to a transition effect - irrelevant to the inquiry). Referencing the gif below: https://i.sstatic.net/LXwPv.gif I apprec ...

What causes a scroll bar to appear when using position:absolute with images?

How can I ensure that an image at the top of a page functions as a background with 100% width on large screens, maintains a minimum width of 1000px, and doesn't display a scroll bar on screens smaller than 1000px? Below is the code I have been workin ...

Having trouble with linking an external JavaScript file inside the head tag?

I've connected my script.js file to my index.html file, and both files are located in the same directory. I initially linked the script.js file in the <head> section, but it wasn't working as expected. Upon checking the console, I encounter ...

Find the number of nested ng-repeats within the outermost ng-repeat and adjust it automatically based on the value of ng-model

Having three nested ng-repeat to showcase the drives, their respective folders, and files. An example data set is illustrated below Drives=[ { name:'C Drive', folders:[ { name:'personal', ...

CSS Transform animation does not work when a class is added programmatically, although it functions properly when toggling the class in Chrome

Attempting to create an animation for the transform of a div. Below is the code with transition and transform properties in Safari: #mydiv{ transition: all 2.3s cubic-bezier(1, 0, 0, 1); transform: scale(0.5); background:white; padding:30 ...

Creating a multi-line form in Python Django involves defining a form

Brand new to Django and currently working on creating a form within a page. The form consists of multiple fields, all of which are currently displayed in a single line on the page. This is the code snippet I am using in the template: <form action=&apos ...

What is the best way to customize a ruby select using Bootstrap?

Every attempt I make to style this line of ruby within a select element in Bootstrap results in it breaking and displaying all the options generated outside of the form. Below is the code snippet that I am struggling to wrap: <%= f.label :user_descrip ...

The jQuery dropdown menu smoothly expands to reveal all hidden submenu options

I'm currently encountering an issue with jQuery. I am trying to create a responsive drop-down menu with sub-menus. The behavior I want is that if the window width is less than 700px, the submenus will trigger onClick. And if the window is wider than 7 ...

Trouble with z-index | initial div out of four malfunctioning

Currently, I am attempting to practice by replicating the design shown in this image: https://i.sstatic.net/iIA2q.jpg However, I have encountered an issue that has been persisting for some time: https://i.sstatic.net/grABz.png I'm struggling to un ...

.cshtml fusion turns sour

My attempt to create a loop that displays small boxes led me to the following code snippet with unexpected results: (code) : <div class="row"> <div class="col-lg-3 col-xs-6"> <!-- small box --> <!-- please change the addr ...

How to smoothly reveal a popup form in jQuery mobile on an iOS device by scrolling up

A popup containing a form was created using jquery mobile. Below is the code for the form. <div data-role="popup" id="popupDetailles" data-theme="a" data-overlay-theme="b" style="width:100%;" data-transition="pop" class="ui-corner-all ui-popup ui-body ...

How can you emphasize text in a code block with a background color?

In my quest for customization, I aim to achieve a specific display format: My desire is to highlight a segment of code within a code block that already has syntax highlighting. This task pertains to a markdown file residing on Github and being served via ...

Automatically proceed to the following page after the video in the Qualtrics iframe comes to an end

I'm attempting to integrate a vimeo video using an iframe in my Qualtrics survey. Once the video is finished, I want it to automatically move on to the next page by pressing the "next button". Previously, I had my videos stored on Dropbox and used the ...

Tips for minimizing the width of a form in CSS/HTML

I created an HTML page with the following code: <div class="panel panel-default"> <div class="panel-heading"> <h1>Users</h1> </div> <div class="panel-body"> <table class="table table-strip ...

Fixing the error message "page attempting to load scripts from an unauthenticated source"

Can you help me troubleshoot an issue on my PHP page with ad scripts? I recently switched my site from HTTP to HTTPS and now the scripts are not appearing. Here is the error I found in the dev console: Failed to load resource: the server responded with ...

Creating a diverse layout by dynamically adding divs without achieving uniformity in the grid

I'm working on dynamically generating a grid of divs with a specific size using the code below: function createGrid(gridSize) { var container = document.getElementById('container'); for (var i = 0; i < gridSize; i++) { va ...

Improved method for managing hash URLs in AJAX-enabled websites

When dealing with pages that have a hash mark in the URL address bar, it can be inconvenient unless using HTML 5 and history.pushState() for AJAX loads. For example, when item1.html is loaded and then the user clicks to view item2.html, the URL changes to ...

Show a SweetAlert message if a specific Div Class is not found within the page

Seeking assistance with displaying a SweetAlert popup only if a certain div class is not found on the page. It appears to work when using an ID, but not with classes. Any suggestions on how to trigger this popup if the specified div class is absent? < ...

Tips for addressing the issue of button flickering due to CSS transitions

Is there a solution to prevent flickering without compromising the intended design? The issue arises when hovering over a moving or animated element and accidentally un-hovering because it moves beneath the cursor. <!DOCTYPE html> <html> &l ...