The menu format is not functioning as I had anticipated

I am currently working on adding a menu to my website, but I am facing an issue with getting the sub menu items to display smaller text compared to the main menu item. Here is the code snippet I have been using:

<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
        <LevelMenuItemStyles>
            <asp:MenuItemStyle CssClass="subMenuStyle" />
        </LevelMenuItemStyles>
        <LevelSubMenuStyles>
            <asp:SubMenuStyle CssClass="masterBannerMenu" />
        </LevelSubMenuStyles>
            <Items>
                <asp:MenuItem Text="WHERE I'VE BEEN" NavigateUrl="~/whereivebeen.aspx">
                    <asp:MenuItem Text="UNESCO Sites" NavigateUrl="~/unesco.aspx" />
                    <asp:MenuItem Text="Places" NavigateUrl="~/BlogPosts.aspx" />
                </asp:MenuItem>
            </Items>
        </asp:Menu>

Upon inspecting the rendered HTML:

<a href="#Menu1_SkipLink"><img alt="Skip Navigation Links" src="/TravelJoansBlog/WebResource.axd?d=i8kPrDg0W2gPsNdgiFoKNbdLkjHOBO6T-YtC_Usb-id70m3Q7jX8wpftWKKoZFCuuiThX_JLEnw1KCG7FBKqB3_JiRZTcYRUnLGsCYCvOwo1&amp;t=634970873020000000" width="0" height="0" style="border-width:0px;" /></a><div id="Menu1">
    <ul class="level1 masterBannerMenu">
    <li><a class="popout level1 subMenuStyle" href="whereivebeen.aspx">WHERE I'VE BEEN</a><ul class="level2">
        <li><a class="level2" href="unesco.aspx">UNESCO Sites</a></li><li><a class="level2" href="BlogPosts.aspx">Places</a></li>
    </ul></li>
</ul>

Additionally, here is the CSS styling that is relevant to this structure:

.masterBannerMenu a
    {
        font-family:"Century Gothic";
        font-size: 16pt;
        width: auto;
        text-align: left;  
        color: Black;
        text-decoration: none;   
    }
    .subMenuStyle a
    {
        font-family:"Century Gothic";
        font-size: 12pt;
        width: auto;
        text-align: left;  
        color: Black;
        text-decoration: none;   
    }

The problem occurs where only the styles within the SubMenuStyles element are being applied. I've attempted various solutions such as swapping CSS classes, setting font sizes in the asp:Menu control and then applying CSS styles, yet nothing seems to work. My aim is to have the sub menu item text (such as UNESCO Sites and Places) displayed in a smaller font size compared to the main menu item (WHERE I'VE BEEN)

Answer №1

To create a similar HTML structure, you'll need to adjust your .NET markup and code-behind like this:

<a href="#Menu2_SkipLink"><img alt="Skip Navigation Links" src="/TravelBlogs/WebResource.axd?d=i8kPrDg0W2gPsNdgiFoKNbdLkjHOBO6T-YtC_Usb-id70m3Q7jX8wpftWKKoZFCuuiThX_JLEnw1KCG7FBKqB3_JiRZTcYRUnLGsCYCvOwo1&amp;t=134659023500000000" width="0" height="0" style="border-width:0px;" /></a>
<div id="Menu2">
    <ul class="level1 bannerMenuList">
        <li><a class="popout level1 subMenuFormat" href="explore.aspx">EXPLORE DESTINATIONS</a></li>
    </ul>
    <ul class="level2">
        <li><a class="level2" href="wildlife.aspx">Wildlife Encounters</a></li><li><a class="level2" href="reviews.aspx">Reviews</a></li>
    </ul>

Check out the JSFIDDLE LINK

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

Tips on adjusting my script to focus on particular text within a div in HTML

I'm currently learning how to code and working on a text generator that allows users to edit text and export it as .DOCX. I came across this script called jsfiddl on the website npmjs, which enables exporting HTML to .DOCX. However, I'm having tr ...

Using JavaScript to display a hidden element when clicked within an overflow-auto container

I have a collection of items grouped within a container with overflow-auto applied. When clicked, I want to scroll/place an item all the way to the right if possible. This will trigger the other items to auto-scroll to the left, positioning the clicked it ...

Responsive Bootstrap dropdown menu adjusts its size when clicked

I'm currently in the process of creating a basic navbar that includes a drop-down menu on the far right side, as depicted here: https://i.sstatic.net/hs9us.png The issue I'm facing is that when I click on the dropdown, the navbar automatically ...

How can I display only a horizontal scrollbar on the body content while avoiding an excessively long image header?

Currently, I have a 4000px width image as the header of my website. To hide the horizontal browser scrollbar, I am using the following CSS: html { overflow-x: hidden; } However, this method results in the horizontal scrollbar never appearing. I ac ...

How can you line up various form elements, like pickers, in a row using Material UI?

As someone new to material ui, I haven't come across a solution for my specific issue yet. While there are similar questions, none seem to address the problem of aligning different form field types. My observation is that the material ui date picker ...

Why is it that code that appears identical in the same browser and same size can look different when one version is deployed on localhost and the other remotely?

I've been working on a Material-UI Table where I customized the headers and table styles. While testing it locally with yarn start, it looked like this: https://i.stack.imgur.com/7yU2H.png However, when I viewed it on the remote system, it appeared ...

How to Decode JSON Object in C# Using Json.net and Extract Inner Data

I am reaching out here because I feel like I have exhausted all resources available to me. There seems to be something fundamentally wrong with my approach or abstraction because I am unable to get it to function properly. The task at hand is fairly straig ...

``There is an issue with elements not remaining within the boundaries of the div that has

http://codepen.io/apswak/pen/qNQxgA Has anyone encountered issues with nesting elements inside a header with a background image? I'm facing the problem where every element I place inside gets pushed above the background image. Is there a more effecti ...

Retrieve the session initiation details when the session is disabled in ASP .NET

Currently, my ASP .NET application has session state disabled, preventing me from accessing the session start event in Global.asax. I am looking for a way to retrieve data when a user visits the site and would typically trigger a session start event. Is ...

Ways to modify the font style of Python comments in JupyterLab's code cells and code editor:

Many resources discuss how to change font families for all content, but I am seeking guidance on making syntax-specific changes. For example, I would like to switch the font style of Python comments from italic to normal. Can anyone offer assistance? Thank ...

Tips for resolving issues with media queries in CSS

After deciding to create both desktop and mobile versions of my site, I attempted to utilize media queries in CSS. Unfortunately, after coding them, I discovered that they were not functioning as expected. Seeking a solution, I turned to Youtube where I ca ...

How do we handle the reception of document.form.submit() in the code behind?

I have a JavaScript function document.form1.submit() and I am wondering how to receive it in the code behind. In which class and method should I be looking? I need to get the value from a textbox and store it in session, but I'm not sure if I need an ...

How to manipulate wrapping behavior in flexbox

My flex container holds three divs, arranged in two rows: First row: One div with a fixed width Another div that should stretch to fill the remaining space Second row: Just one item However, the first div stretches to 100% width and pushes the seco ...

Is employing Task.Run() advisable for an I/O-intensive BackgroundService?

In my ASP.NET Core 5 API, I need to implement continuous background tasks that involve reading azure queues and may spend a lot of time idle. While traditional wisdom advises against using Task.Run() for I/O operations due to inefficiency, in my scenario ...

Retrieve the form identification in jQuery Mobile on the 'pageshow' event

Is there a way to retrieve the form ID of the current page using 'pageshow' in jQuery Mobile? I am currently able to obtain the ID of the active page by following this method. $(document).on('pageshow', function () { var id = $.mobile. ...

Is it possible to create custom Membership, Role, and Profile providers without relying on inheriting from MembershipProvider, RoleProvider, etc

Is there a reason why I can't create a completely custom membership, roles, and profiles system without inheriting from abstract classes like MembershipProvider? According to MSDN: "When implementing a custom role provider, you are required to inheri ...

Tips for centering a bootstrap card on the screen using reactjs

I've been struggling to keep my card centered on the screen despite using align-items and justify-content. I've researched on various websites to find a solution. //Login.js import React, { Component } from 'react'; import './App ...

Ninject seamlessly integrates a service interface into a web application service

In my project, I have a web service that is responsible for returning JSON data to AJAX calls. While injecting my ClientService works perfectly fine on regular pages, I am facing difficulties making it work in the web service environment. In my NinjectWe ...

Is there a way to refresh the animation on dougtesting.net?

I'm working with the dougtesting.net library to create a spinning wheel. I've been trying to figure out how to reset the animation once it finishes, but I can't seem to find any information on it. My goal is to completely clear all states so ...

Does Google Chrome have a strange way of interpreting CSS?

Almost done with my website and it looks great on Firefox and IE 8, but Chrome is causing issues. Here's how it appears on FF: And here's Chrome: Notice how Chrome resizes the first image even though the code is the same as the one below? Che ...