Tips for Optimal Dropdown Menu Placement

The tabs in my menu seem to be refusing to move closer to the left side of the menu. I've tried removing padding elements and adjusting other settings, but there still remains an awkward space between the edge of the menu and the tab text.

Additionally, I want the dropdown to have padding only around the parent tab, not the child tabs inside. The current project can be viewed on the left side here, and the desired outcome is shown on the right side in this image.

ul{list-style:none;}
a{ text-decoration: none;color: black;}

.ul-li {position: relative;}

ul li {padding:10px;}

.ul-li > .ul-li-ul {max-height: 0;transform: scaleY(0);}

.ul-li > input[type="checkbox"] {
  opacity: 0;
  display: block;
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.ul-li > input[type="checkbox"]:checked ~ .ul-li-ul {
  max-height: 9999px;
  display: block;
  -moz-transform: scaleY(1);
  -ms-transform: scaleY(1);
  -webkit-transform: scaleY(1);
  transform: scaleY(1);
}

... 
(remaining code snippets omitted for brevity)

Answer №1

The issue you are facing is as follows:

ul li {padding:10px;}

To resolve this problem, you can specify this style only for the parent element and everything should function correctly. Tip: Utilize the inspection tool in Google Chrome to enable or disable CSS styles.

Answer №2

Give this a try, add the following code snippet to the end of your CSS file:

https://jsfiddle.net/AnnaSmith123/1aBcDeFg/

.ul-li-ul > li> a{
  color:blue;
  margin-left:-15px;
  margin-top:-15px;
  line-height: 15px;
  vertical-align:middle;
}

Hope this solution works for you!

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

Fixing the issue with CSS scrollbar swapping

I'm currently working on a template and facing a challenge that I can't quite comprehend. More specifically, I understand why it's happening, but I'm struggling to implement a cross-browser solution. The issue revolves around a fixed b ...

Interacting with the column tags within HTML tables through the .NET WebControls Table in a programmatic way

As per the information provided on this website: The HTML5 table contains col tags... <table width="100%"> <col style="width:40%"> <col style="width:30%"> <col style="width:30%"> <tbody> ...

Is it possible to have an iframe set in the background with a specific z-index but without

Currently, I am working on a webpage where I have inserted an iframe in the background because other div elements on the page "interact with it". Even though I have used z-index to make it visible in the background, I am facing issues with controlling it s ...

Is there a glitch with CSS skew, shadow, and hover effects in Chrome browser?

   I am facing an interesting problem where hovering over a skewed li element with a CSS3 transform and a shadow applied causes the generated shadow to display incorrectly. You can see the issue for yourself here - http://jsfiddle.net/mabbage/BLD5Z/1/ ...

Developing jpg/png images from .ppt/pptx files with Django

I currently have a PowerPoint file saved on Dropbox at "". My goal is to convert this presentation file into individual slide images (jpg/png..) within my Django template or using a Django def function. Once I have converted the slides, I plan to utilize ...

How can jQuery determine if multiple selectors are disabled and return true?

I am currently working on a form in which all fields are disabled except for the "textarea" field. The goal is to enable the "valid" button when the user types anything into the textarea while keeping all other inputs disabled. I initially attempted using ...

Problem with CSS multi-level dropdown navigation in a vertical layout

I am in the process of creating a navigation menu with dropdown menus, which are working correctly. Now, I would like to add another sub-menu drop down inside dropdown 1, but I am having trouble getting it to function properly. How can I make Sub Menu 1 ac ...

"Woops! An error occurred with the message: "SassError: Could not locate the specified target selector" while working with SCSS Modules and incorporating

Currently, I am working with Next.js and utilizing SCSS Modules. To incorporate Bootstrap into my project, I opted to install it using the command npm install bootstrap. Following this installation, I went ahead and created a new file titled common.scss wi ...

"What is the best way to display an image from a table and then enlarge it to full size when a button is clicked, all

1. Understanding the Concept In my page, I have a table listing various images with unique names that are successfully displayed in the table. My goal is to display the selected image in full screen within a popup window when a button is clicked. 2. Que ...

How can I invoke a TypeScript function within HTML code?

Currently, I am working on an Angular project where I have implemented two straightforward methods in a TypeScript file: findForm(text: string, forms: Array<string>) { for (let form of this.forms) { if (text.includes(form)) { retur ...

Achieving CSS transition effects using the .appendChild function in JavaScript

When using the mouseenter event, I have a JavaScript function applied to an svg path element: const fadeIn = (event, locale) => { event.target.style.fill = 'hwb(' + (120 - score[locale] * 1.2) + ' 0% 0% / 1)' } This function wor ...

Using HTML formatting in the Visual Studio 2010 editor

When I reformat HTML source code in Visual Studio using Ctrl-K, Ctrl-D, it rearranges my code like this: <p> text</p> <p> more text</p> Is there a way to make it format the code like this instead? <p> text </ ...

What is the process for sending an email to a designated recipient through an HTML form and then storing it as a record in an HTML table?

<!-- Placeorder part --> <div data-ng-show = "isPlaceOrder"> <div class = "col-lg-10" style = "margin-top:80px"> <div class="panel panel-primary"> <div class = "panel-heading">Drug Request Mail Sender</div&g ...

The combination of two tags can create a powerful and impactful presence

My task is to place two <h3> tags in the same line or paragraph. <h3>This is the first paragraph. </h3> <h3>This is the second paragraph.</h3> I would like the output to look like this: This is the first paragraph. This is Se ...

Hover effects on the navigation bar combined with an image featuring a sub navigation menu

Looking to craft a dynamic navigation bar that switches out subcategory images on hover. (subcategories come pre-loaded with images) ...

Issue with displaying dropdown menu icon in Bootstrap 5

Currently utilizing Angular 14 alongside Bootstrap 5. The code snippet below showcases a simple Bootstrap dropdown menu: <div class="dropdown"> <button class="btn btn-secondary dropdown-toggle" type="button" id=&quo ...

Issue with the overall layout in Bootstrap 4 involving the main content area and sidebar

I am encountering challenges with the overall design of my website, particularly with how the main content area and sidebar are positioned. The layout I have in mind is: https://i.sstatic.net/PYphE.jpg Below is the code snippet I am using to implement th ...

Having trouble with compiling SCSS code

While diving into the world of SCSS, I decided to compile my SCSS into CSS using npm. So I entered npm run compile: sass as defined in my package.json as follows: "scripts": { "compile:sass": "node-sass sass/main.scss css/style ...

Is there a way to dynamically adjust the modal header based on the chosen option?

Discussing the following inquiry: Passing data to Bootstrap 3 Modal Typically, the data-id is transferred to a text box in various scenarios by using this line: <input type="text" name="bookId" id="bookId" value="" /> Is there a way to send the da ...

Maintain the basic structure while ensuring divs are properly aligned

Behold, my div structure! ONE // at the top level TWO THREE // two divs side by side in the middle level FOUR // residing at the bottom <div id="ONE"> <div></div> <div><img src="logo.png"></div> </div> < ...