Optimal Placement of ASP Menu

As a novice in web page coding, I am seeking assistance with centering elements on my master page. The layout includes a banner at the top and an ASP menu control on the left side. To achieve center alignment, I have created an "outer_div" with CSS attributes: text-align:center, margin-left:auto, margin-right:auto.

Within this "outer_div," the "menu" div (which contains the ASP menu control) is set to text-align:left. However, I am facing challenges positioning the menu control to the left of the outer div; it either aligns extreme left or centers on the screen.

I have included the .master file and relevant CSS below. Any guidance would be greatly appreciated!

<body>
<div id="outer_div" class="bxcen cenx">
    <form id="form1" runat="server">
    <div id="header">
        <asp:Label ID="lblHeader" runat="server" CssClass="header_image" Width="1024px" Height="121px"></asp:Label>
        <div id="branding">
            <span id="companyName" class="redText">Arcadia</span>&nbsp;<br />
            <span id="slogan">Reference Data Load Manager</span>
        </div>
    </div>
    <div id="divTopPanel">
        <asp:Label ID="lblPageName" runat="server" CssClass="top_panel" Width="1024" Height="30"></asp:Label>
    </div>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
    <div id="holder">
        <div id="menu" class="left_align">
            <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" DynamicHorizontalOffset="2"
                Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98" Orientation="Vertical"
                StaticSubMenuIndent="10px" StaticDisplayLevels="5">
                <DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
                <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <DynamicMenuStyle BackColor="#B5C7DE" />
                <DynamicSelectedStyle BackColor="#507CD1" />
                <StaticHoverStyle BackColor="#284E98" ForeColor="White" />
                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <StaticSelectedStyle BackColor="#507CD1" />
            </asp:Menu>
        </div>
        <div id="content" align="left">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </div>
    </div>
    </form>
</div>

Here is the relevant CSS...

body
{
    font-family: Verdana;
    font-size: small;
    background-color: #808080;
}

#standard
{
    font-family: Verdana;
    font-size: small;
    background-color: #FFCC99;
}


#menu {
    background-color: #FDA343;
    position:relative;
    left:0px;
    top:0;
    width: 161px;
}

#content
{
    width: 600px;
    float: left;
    text-align: left;
}

.button
{
    font-family: Verdana;
    font-size: small;
    background-color: #6699FF;
    color: #FFFFFF;
}

.top_panel
{
    background-color: #FDA343;
    font-family: Tahoma;
    font-size: large;
    text-align: center;
}

.header_image
{
    background-color: #B5C7DE;
    font-family: Tahoma;
    font-size: large;
    text-align: left;
    vertical-align: middle;
    background-image: url('Images/SmallOrangeRig.jpg');
    color: #FFFFFF;
}

.cenx
{
    text-align: center;
}
.ceni
{
    clear: both;
}
.bxcen
{
    margin-left: auto;
    margin-right: auto;
    border: none;
    padding: 0;
}

.left_align
{
    text-align:left;
}


#branding {
    position: absolute;
    right: 20px;
    top: 20px;
    z-index: 1000;
    text-align: left;
    color: #9f0f0e;
    font-family: "Arial", Courier, monospace;
}

#companyName {
    color: #FFF9E9;
    font-size: 40px;
}

Answer №1

I recently realized that my CSS code was overly complicated and difficult to manage. Seeking a solution, I came across a highly recommended book titled "Getting StartED with CSS" by David Powers. In Chapter 11 of this book, there is a sample CSS code provided for creating a simple two-column layout page. This sample served as a foundation for me to construct exactly what I needed.

The key components of the basic CSS code are:

#wrapper {
  width: 760px;
  margin: 0 auto;
}
#sidebar {
  width: 220px;
  padding: 10px;
  float: left;
}
#mainContent {
  margin-left: 240px;
}

One crucial element that significantly improved my layout design was utilizing the 'float' property effectively.

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

What factors should be taken into account when employing Global Variables on Webforms Pages for Security?

In my webforms application, I have defined several global variables in this manner: public partial class Default : System.Web.UI.Page { protected string testvar; } These variables are utilized by various functions to exchange values and perform operati ...

Guide on extracting PDF file bookmarks with c#

What is the most effective way to extract bookmarks from a pdf document using the C# programming language? Can anyone recommend a reliable library for accomplishing this task? ...

The height of the division is either inadequate or excessive when set at 100%

After making progress, I hit a roadblock that has me stumped. The issue I'm facing is with the wrapper height setting. If I set it to auto, it stops at the bottom of the content, leaving the background exposed when the content is shorter than the win ...

What is the best way to set a minimum width for websites with relative (%) widths that are compatible with IE6 and above?

I am working on a website where I utilize percentages (%) for widths to create a flexible layout. However, I am encountering an issue where everything breaks at a certain width, such as 800px. Is there a way to set a maximum width of 800px and then displa ...

Tips for effectively showcasing div elements

https://jsfiddle.net/qz8hL574/1/ for (var key in table) { if (table.hasOwnProperty(key)) { $('<div class="element"></div>').appendTo('#list'); document.getElementsByClassName("element")[key].innerHTML = ...

Steps to refresh serialization following every web API request in C#:

I have implemented a custom JSON serialization for a specific API request, but it is conflicting with the global format. I now need to reset this custom serialization either after the particular API call or at the beginning of every other API call. public ...

Utilizing ASP.NET with JavaScript to target elements by ID within an iframe

Struggling to populate my form within an iframe by inputting a value in a textbox and selecting an option from a dropdown menu. webform1 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title ...

Is it possible to align an image that uses position:relative with one that uses position:absolute?

On a webpage, I have placed two images. The first image is set to position:relative and the second image is positioned right below it with position:absolute. How can I ensure that as you zoom in or out, the second image remains aligned with the first ima ...

Are Bootstrap dynamic pills limited to only one use?

I have been working on a login/sign-up form where the display switches between the two forms when clicking on specific buttons. The issue that I'm facing is that the functionality only works once. My client provided me with a website template that the ...

Splitting extensive text within GridView at a comma

Can anyone help me with breaking this text on commas in an asp:GridView? The content looks like this: aaaaaaaaaaa,aaaaa,aaaaaaaaaa,asdsad,aasfasfa,sfasfasfsfasfasfa,afasf. This is causing the field to stretch too much. I've attempted using CSS an ...

Tips on resolving Toolbar and Sidebar issues without making adjustments to the top value

My design includes a fixed Top Toolbar and a fixed Sidebar. I am trying to position the Sidebar just under the Toolbar without using any top value or margin-top. This was achieved with Bootstrap-4 by setting a top value. Is there a way to accomplish this w ...

C# - In ASP.NET MVC, how can I send a model containing another model through an HTML form?

I'm currently working on a form that needs to be passed to my controller. Inside the main model, there is another model that I need to consider. Here is how the models and the form are structured. I'm not sure if the controller will be able to r ...

What is the best way to insert text into a div element using HttpContext?

I have a challenge in my web page where I am trying to insert text inside a div using HttpContext after a button click, without using InnerHtml due to potential browser hang-ups with long text. My current method is printing the text outside the div. Can ...

What is the method for retrieving a public page variable from the master page when there is only one page?

I have a single page that serves as the backbone for my entire website: using System; using System.Text.RegularExpressions; using System.IO; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Sy ...

Ensuring consistent readability in Bootstrap 4 by wrapping text without affecting the height

Referenced from: Twitter Bootstrap Button Text Word Wrap Is there a way to adjust the word wrap of text inside a button in bootstrap 4 without changing the height, or maintaining equal height for all buttons? For example: <div class="container"> ...

the css stylesheet fails to load properly within the Django application

While using static files in my Django app, I encountered a peculiar issue: specifying body{ } in the CSS file can alter the body's attributes, but using the div's id or class name does not affect the div's attributes. Here's an example: ...

Issues with JQuery draggable functionality not functioning as expected

Is there a way to drag bookmarks on a line and have the text above them change to show the percentage from the right edge? Here is a quick snippet that achieves this, along with a demonstration in this fiddle. Check out the code below: HTML <div id=& ...

Expanding Lists in Bootstrap 3: A Step-by-Step Guide

I have been experimenting with Bootstrap's Example accordion code, which can be accessed via this link: http://jsfiddle.net/qba2xgh6/18/ <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <div class="panel ...

modify CSS style once the modal has been hidden

Is there a way to change the default background color of my table row back to normal after closing the modal window that appears when I click on it? <tr class='revisions'> <td>{{ $revision->date_of_revision->format(' ...

Troubleshooting Vertical Centering Issue with Flex in Ionic and ReactJS Not Yielding Results

Feel free to experiment with this Ionic / ReactJS project on Stackblitz: https://stackblitz.com/edit/ionic-react-routing-ctdywr?file=src%2Fpages%2FGreetings.tsx Here is the code snippet: import React from 'react'; import { IonButton, IonContent ...