CSS- Creating a left-aligned child menu

Hello everyone, my objective is to expand the child menu towards the left side instead of the default right side placement. Below is the CSS code for achieving this,

    /*<![CDATA[*/

/* page styling, unimportant for the menu. only makes the page looks nicer */

/* - - - ADxMenu: BASIC styles - - - */

/* remove all list stylings */
.menu, .menu ul {
    margin: 0;
    padding: 0;
    border: 0;
    list-style-type: none;
    display: block;
}

/* move all list items into one row, by floating them */
.menu li {
    margin: 0;
    padding: 0;
    border: 1px solid #000000;
    display: block;
    float: left;                /* modified by poornima. (default float :right ) */
    position:relative;
    z-index:5;
}

/* define new starting point for the nested UL, thus making positioning it a piece of cake */
.menu li:hover {
    position: relative;
}

/* align the submenus with the right edge */
.menu li ul {
    right: 0;
    margin-left:-385px;       /* already setted value: -363px;*/    /* IE 7 & 8 Problem to bring the submenu for left side */
}

/* force the submenu items into separate rows, while still keeping float:left (which resolves IE6 white-gap problem) */
.menu li li {
    width: 100%;
}

/* fix the position for 2nd level submenus.
    first make sure no horizontal scrollbars are visible on initial page load by sliding them all into top-left corner  */
.menu li li ul {
    top: 0;
}

/* ...and then place the submenu where it should be when shown */
.menu li li:hover ul {
    right: 100%;
    padding-right:52px; /*Newly added property for submenu hover properly*/
}

/* initialy hide all sub menus */
.menu ul {
    visibility: hidden;
    position: absolute;
    z-index: 10;
}

/* display them on hover */
.menu li:hover>ul {
    visibility: visible;
}

/* -- float.clear -- force containment of floated LIs inside of UL */
.menu:after, .menu ul:after {
    content: ".";
    height: 0;
    display: block;
    visibility: hidden;
    overflow: hidden;
    clear: both;
}
/* IE7 float clear: */
.menu, .menu ul {
    min-height: 0;
}
/* -- float.clear.END --  */

/* sticky submenu: it should not disappear when your mouse moves a bit outside the submenu
    YOU SHOULD NOT STYLE the background of the ".menu UL" or this feature may not work properly!
    if you do it, make sure you 110% know what you do */
.menu ul {
    background-image: url(empty.gif);/* required for sticky to work in IE6 and IE7 - due to their (different) hover bugs */
    padding: 10px 30px 30px 30px;
    margin: -10px -30px 0 0;
    /*background: #f00;*/       /* uncomment this if you want to see the "safe" area. you can also use to adjust the safe area to your requirement */
}


/* - - - ADxMenu: DESIGN styles - - - */

.menu, .menu ul li {
    color: #fff;

    background:transparent url(../../Images/Modern/bgnd_sel_2.jpg) repeat scroll 0 0;}

.menu li li {
    text-align: right;
}

.menu ul {
    width: 15em;
}

.menu li:hover>a {
    color: #000;
}

.menu a {
    text-decoration: none;
    color: #000000;
    padding: .2em .3em;/*padding: .2em .4em;*/
    display: block;
    position:relative;
}

li.inactive {
    text-decoration: none;
    color: #fff;
    padding: .3em 1em;
    display: block;
    position: relative;
    background-color: #000000;
}

li.inactive {color:#cccccc;}

.menu a:hover, .menu li:hover>a {
    color: #000;
    background:transparent url(../../Images/Modern/bgnd_sel_4.png) repeat scroll 0 0;
}

.menu li li {   /* create borders around each item */
    border: 1px solid #BBBBBB !Important;
    margin-left:22px;      /*Move menu to right side*/
    text-align:right;      /*Move menu to right side and the text align right*/
}

.menu ul>li + li {  /* and remove the top border on all but first item in the list */
    border-top: 0;
}

.menu li li:hover>ul {  /* inset 2nd+ submenus, to show off overlapping */
    top: 5px;
    right: 100%;
    visibility:visible; /* IE 7 & 8 Problem add visibility for 2nd+ submenus */
}

/* Fix for IE5/Mac \*//*/
.menu a {
    float: left;
}
.menu {
    display: inline-block;
}
/* End Fix */

/*]]>*/
</style>

<!--[if lte IE 6]>
<style type="text/css" media="screen, tv, projection">
/*<![CDATA[*/

/* - - - ADxMenu: BASIC styles - - - */
.menu, .menu ul {
    height: 1%;
}

/* this style must be exact copy of: ".menu li li:hover ul" style above  */
.menu li li.adxmhover ul {
    right: 100%;
}

/* the following two rules simulate li:hover>ul selector
    repeat enough times to cover all nested levels
    look at www.aplus.co.yu/adxmenu/trouble/ if some of your submenus do now show up */
.adxmhover ul,
.adxmhover .adxmhover ul {
    visibility: visible;
}
.adxmhover li ul, 
.adxmhover .adxmhover li ul {
    visibility: hidden;
}

/* - - - ADxMenu: DESIGN styles - - - */
.menu ul a {    /* fix clickability-area problem */
    zoom: 1;
}

.menu li li {   /* fix white gap problem */
    float: left;
    width: 100%;
}

.menu li li {   /* prevent double-line between items */
    margin-top: -1px;
}

.menu a:hover, .menu .adxmhoverA {      /* li:hover>a selector */
    color: #000;
    background:transparent url(../../Images/Modern/bgnd_sel_4.png) repeat scroll 0 0;
}

.adxmhover a, .adxmhover .adxmhover a {
    color: #000;
}
.adxmhover li a, .adxmhover .adxmhover li a {
    color: #000;
}

.menu .adxmhoverUL .adxmhoverUL {   /* inset 2nd+ submenus, to show off overlapping */
    top: 5px;
    left: 100%;
}

/*]]>*/
/*</style>*/

<script type="text/javascript" src="../code/ADxMenu.v4.02.js"></script>
<![endif]-->

The screenshot of the page looks as follows

When hovering over the "user management" menu, the "create user" submenu should expand towards the left side. Any assistance on achieving this would be greatly appreciated.

Thank you

Answer №1

There is a note regarding your code that suggests:

/* ...and then place the submenu where it should be when shown */

Following this, you have the following snippet of code:

.menu li li:hover ul {
    right: 100%;
    padding-right:52px;
}

It seems like changing padding-right to padding-left, and right:100% to left:100% could potentially alter the menu.

To assist you better, consider providing a live demonstration on jsbin.com

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

How can I transform a series of list items within a unordered list into an array?

After retrieving some data, it appears in the following format: > denialReasonContent: { denialReason: "<ul>\n <li>denial reason > 1</li>\n <li>denial reason 2</li>\n</ul>" }; I am attem ...

coding with javascript and css

Essentially, I am trying to add padding specifically to the left side of this code snippet: if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("live ...

Tips for increasing the height of a div as rows are dynamically added to a table

I am facing an issue with a div main containing a table grid. Rows are dynamically added to the table, causing it to increase in height. However, the height of the div main remains unchanged, resulting in the table overlapping the footer content. What chan ...

Is it possible to assign a class to a br element?

Do you think the following HTML code is valid? <br class="something"> While it seems like a valid HTML element, I personally haven't come across it being used before. ...

Display additional input field using Jquery when text is entered in the textbox

Is there a way to display the input field #f_past_data when the text field #f_past_farmaco is filled out? The field #f_past_farmaco is for entering text. I attempted the following solution but it did not work as expected. $('label[for=f_past_data], ...

Creating aesthetically pleasing and uniform rows of responsive Bootstrap 4 cards with consistent heights

I'm a beginner in the world of design and Bootstrap, so please be patient with me. My goal is to create a series of cards that have equal height and width (responsive, not fixed) in each row. In other words, I want all the cards to be as tall and wid ...

Please provide the text enclosed within the h1 tags

Is there a way to extract the content between <h2> </h2> tags in PHP or jQuery from each page and use it as the title of the pages to ensure uniqueness? Example: <section class="sub_header"> <h2>Contact</h2> < ...

Ways to output HTML from a function

I'm struggling to get my HTML function to work properly, even though it seems like a simple task. For some reason, the content isn't displaying when I return it, but things work fine when using console.log. Could someone please assist me with th ...

How come a child element with a lower z-index than its parent doesn't appear behind the parent?

I'm currently investigating why a child element fails to appear behind its parent element when it has a lower z-index value than the parent. The issue seems to arise only when the default z-index value of the parent is modified. Let's consider a ...

Struggling to retrieve the image URL from a TypeScript file

I'm currently developing a basic app in Ionic that will include a feature to display a list of registered users along with their profile pictures. These profile images are stored in Firebase storage. Although I have successfully retrieved the URLs fo ...

Adjust the HTML Canvas to cover the entire screen

I am trying to adjust the HTML Canvas element so that its width matches the width of the browser window and its height matches the height of the browser window. Below is the code snippet I am using: HTML: <body> <canvas id="gameCanvas" ...

What could be the reason why the .click function is not functioning as

I'm completely new to jQuery and I'm working with an HTML element that looks like this: <input type="button" value="Cancel" class="supportButton" id="whitelist.onCancelUploadButton" onclick="whitelist.onCancelUpload();"> By using the foll ...

How to create a scrollable table using HTML and CSS

I created a Dashboard, but I'm having trouble making my mailPage scrollable. If you have some time to spare, could you please take a look at my website and help me with this issue? Here is my code: window.addEventListener("load", function () { ...

What is the best way to show an error message on a webpage using jQuery within a PHP environment?

I have a form in HTML that includes a submit button for posting status on a page. When a user clicks the submit button without entering anything into the form field, I want PHP to display a simple error message on the same page saying "This status update s ...

Showing content from a JavaScript variable once a button has been clicked

Imagine you are using express.js and have a JavaScript variable embedded in an ejs file like this: <%= someVariable %> How can you display the value from this variable on the same page, for instance within a bootstrap modal element (check out https: ...

"Enhance your mobile user experience with swipeJS integration in jQuery

Trying to incorporate swipeJS into my jQuery Mobile application has been challenging. Below is the code snippet from the page where I attempted to implement swipeJS: FULL CODE: http://jsfiddle.net/unTHs/ (output on jsfiddle may vary) <div id="slider" ...

Transforming website content into HTML code

I am in need of a solution to convert a webpage into an HTML page programmatically. I have researched several websites, but the information provided only covers converting pages into PDF formats. Currently, my program involves saving a page as .html and th ...

JavaScript event/Rails app encounters surprising outcome

I have encountered a strange bug in my JavaScript code. When I translate the page to another language by clicking on "English | Русский" using simple I18n translation, my menu buttons stop working until I reload the page. I suspect that the issue ...

Developing a form using ASP.NET with dual models

I am currently using Visual Studio 2017 with all the latest updates installed. I am facing a challenge where I need to create a form with text box answer questions and a checkbox answer question, and then store all the answers in a single database entry. M ...

Place a material-ui React component at the center of a footer section

I'm facing a challenge with centering a material-ui Simple Breadcrumbs component within a footer as opposed to having it aligned to the left. Even though I'm new to this, I thought it would be straightforward but I can't seem to figure it ou ...