display the inner div adjacent to the outer div

I am trying to create a vertical menu with submenus, and I need the submenu to appear next to its parent div.

Has anyone encountered this issue before? I searched on Google but could only find solutions for placing two divs next to each other. I specifically need the child div to be positioned next to its parent.

This is my current code:

HTML

<div id="menuCont">
    <div class="menuItem">
        Application Development
        <div class="subMenuCont">
            <div class="subMenuItem">HTML</div>
            <div class="subMenuItem">CSS</div>
            <div class="subMenuItem">jQuery</div>
        </div>
    </div>
    <div class="menuItem">
        Network Management
    </div>
    <div class="menuItem">
        Server Administration
    </div>
</div>


CSS

#menuCont {
    width: 17.5%;
    text-align: center;
}

.menuItem {
    width: 100%;
    padding: 1em;
    background-color: #ffffff;
    color: #000000;
    font-family: Lato;
    font-size: 125%;
    border: 1px solid #7266ff;
    border-bottom: 0;
    cursor: pointer;
}

.menuItem:first-child {
    border-top-left-radius: 1.5em;
}

.menuItem:last-child {
    border-bottom: 1px solid #7266ff;
    border-bottom-right-radius: 1.5em;
}

.menuItem:hover {
    background-color: #7266ff;
    color: white;
}

.subMenuCont {
    /*display: none;*/
    position: relative;
    /*left: 100%;*/
    /*width: 90%;*/
}

.subMenuItem {
    border: 1px solid #7266ff;
    border-bottom: 0;
}

.subMenuItem:last-child {
    border-bottom: 1px solid #7266ff;
}

If you require any additional information, please let me know. As of now, I am unsure about what more details to provide.

Answer №1

Your CSS has been updated to ensure the element is placed precisely where needed by changing the position property to absolute:

.subMenuCont {
    position: absolute;
    top: 0;
    left: 17.5%;
    width: 17.5%;
}

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 for customizing icons when hovering in CSS

I'm trying to make a default icon light up on hover using CSS, but I'm having trouble getting it to work. Any suggestions on how I can achieve this effect? Thank you! HTML <ul class='nav nav-main nav-sidebar'> <li role=&apos ...

Extract the data from an HTML form and transfer the values into variables within a node.js function

Issue Description: I am facing a challenge in my project where I need to take three numbers as input from the user through an HTML form. Upon submission, I want these values to be passed to a node.js file and stored in variables. Here is the HTML code sni ...

The Challenge of CSS Transition and Checkbox Label Discrepancies

I'm looking to adjust the position of my label when a checkbox is checked. Everything works smoothly if I don't include a transition for the top offset property in the CSS of my label. However, when this transition is added (as seen in the commen ...

Is there a way to control the visibility of two divs depending on which one a user hovers on?

Having two stacked div elements containing images, I want the div with id = "features3_HDS_image" to become visible when a user hovers over the div with id = "HDS_Blurb", and the div with id = "features3_FH_image" to be displayed when hovering over the div ...

Issue with SmartNavigation in ASP.NET application using .NET 1.1

I am encountering an issue with a .Net 1.1 webapp where I have an aspx page with the attribute SmartNavigation=true set. Within this page, there is an anchor tag structured like this: <a href='#' onclick="$.copy('ANNUAL PAID OZ');" ...

What is the correlation between $container-max-width and $grid-breakpoint in Bootstrap version 4?

Query: I am working with Bootstrap v4 in a project and I am curious about the connection between the default values assigned to the keys in the $container-max-width and $grid-breakpoint SASS maps. Is there a correlation between them in Bootstrap v4? Bac ...

Attempting to create a div element that automatically adjusts itself horizontally in the center through the utilization of margins

I searched through examples on stack overflow that had similar problems to mine, but unfortunately, I couldn't find a solution. I'm not sure what I'm doing wrong, but the div is not aligning horizontally center as expected. It seems to work ...

Exploring the relationship between CSS z-index values and a canvas

http://jsfiddle.net/y2q3yLpj/ In my example, I tried setting the z-index of a canvas to 0 and the z-index of a div to 1. However, despite this configuration, the canvas appeared higher than the div. Surprisingly, when I set the z-index of the canvas to -1 ...

Can a Chrome App access a user's files on their hard drive with proper permissions?

I'm currently working on a Chrome Packaged App that includes video playback functionality. My main goal is to enable users to stream online media (such as MP4 videos) while also giving them the option to save the video to a location of their choice. ...

Creating a seamless top border that remains unaffected by border radius

I'm currently working on mimicking the style of Google Calendar, and I've encountered an issue with the text input box. When clicked, it should look like this: https://ibb.co/6Hqrnt4 However, what I've created ends up looking like this: htt ...

"Fixing the Vertical Order of Divs with Jquery: A Step-by-

Before I completely lose my mind, I need some help with a coding issue. Right now, I have two initial divs displayed. The user should be able to add these divs below the original ones as many times as they want, or remove them if needed. I've been att ...

utilizing AJAX to send a POST request and display the response in HTML using Django

I am looking to input a number into a text box and retrieve all the even numbers using ajax with Django. Here is my view: load_template @csrf_exempt def load_template(request): if request.method == 'POST': num1 = request.POST[&a ...

Having trouble with changing the selected value in JQuery?

I'm attempting to use jQuery to set the select option, but I'm encountering an issue. It is setting the value properly, but the text is not being updated. I've experimented with .prop('selected',true), .attr('selected',t ...

"During the Angular Controller operation, the variable $scope.fId is displaying a

I need help using the input value fId in my Angular controller FollowBtnCtrl. I have created a button that calls the followMe() function, which is defined inside the FollowBtnCtrl controller. However, when I try to access the $scope.fId value within the co ...

`<a> The value does not appear upon page load`

As a newcomer to development, I am currently experimenting and creating a sample dashboard. However, I am facing an issue where the sidebar value does not display upon loading the page. I have to manually click on a list in my sidebar for it to appear. Th ...

What is the best way to extract specific content from HTML and display it within a specific HTML tag using

#!/usr/bin/env python import requests, bs4 res = requests.get('https://betaunityapi.webrootcloudav.com/Docs/APIDoc/APIReference') web_page = bs4.BeautifulSoup(res.text, "lxml") for d in web_page.findAll("div",{"class":"actionCol ...

The issue of JQuery mobile customizing horizontal radio buttons failing to function on physical devices has been identified

Not long ago, I posed a query on Stackoverflow regarding the customization of horizontal jQuery-mobile radio buttons. You can find the original post by following this link How to customize horizontal jQuery-mobile radio buttons. A developer promptly respon ...

Learn the process of utilizing Uglify.js to combine JavaScript files for individual views within Express.js

My website is currently built on express.js and I am looking to optimize my JavaScript files using uglify.js in the build process. An example of a typical view on my site appears as follows: extend layout block head script(src="/js/polyfills/html5s ...

How to turn off and on all elements within a Div tag

Is there a way to disable all elements within a Div tag? I've managed to disable input types successfully, but I'm struggling with links. I attempted the solution provided here, but it didn't work. Here's the code snippet that worked f ...

Guide to navigating through a webpage to locate the specified element with Selenium

Is there a way to ensure that when scrolling to an element in selenium, it appears at the very top of the browser window rather than just being visible on the page? What steps can be taken to make sure that the element being scrolled to is positioned at t ...