The height of the first item in the navigation menu seems oddly disproportionate

I've been struggling for nearly an hour to make my navigation menu visually appealing. I'm utilizing Twitter Bootstrap's flat CSS menu.

Oddly, the first item in the menu appears taller than all the other items in the list - you can see it here:

Is there a way to ensure that the height of the first item matches all the other items in the list?

I've attempted the following solutions:

  1. Setting the height of the first list item explicitly. No changes occur.
  2. Removing the padding from the menu. Still no change.
  3. Eliminating the margins from the menu. Unfortunately, nothing happens.

Here's a jsfiddle demonstrating my issue. The code may not be clean right now, but I'll clean it up after resolving this problem.

Code snippet taken from the fiddle:

HTML:

<img id="profile_circle" style="height:25px;width:25px;;border-radius: 16px;float:right;margin-top:10px;border:2px solid #DDD8CE;cursor:pointer;" src="https://secure.gravatar.com/avatar/3ab5cad18247b67090e61f59b47ef7c4?size=20" alt="">

<div style="width:160px;min-height:100px;background-color:white;z-index:3;position:relative;top:40px;left:240px;-moz-box-shadow: 0px 0px 5px rgba(0,0,0,0.2),inset 0 0 0 #000;-webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2),inset 0 0 0 #000;box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2),inset 0 0 0 #000;" class="grey_box">
                                    <ul class="dropdown-menu">
                                        <li><a href="https://domain.com//profile/jjmpsp">My profile</a></li>
                                        <li><a href="https://domain.com//universities/">My university</a></li>
                                        <li><a href="https://domain.com//dumps/">My dumps</a></li>
                                        <li><a href="https://domain.com//notes/">My notes</a></li>
                                        <li class="divider"></li>
                                        <li><a href="https://domain.com//logout/">Logout</a></li>
                                    </ul>
                                </div>

CSS:

.dropdown-toggle:focus{outline:0;}
.dropdown-menu{z-index:1000;display:block;padding:5px 0;list-style:none;font-size:14px;background-color:#ffffff;background-clip:padding-box;margin:0px !important;}
.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5;}
.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.428571429;color:#333333;white-space:nowrap;}
.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{text-decoration:none;color:#ffffff;background-color:#428bca;}
.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#ffffff;text-decoration:none;outline:0;background-color:#428bca;}

.grey_box {
background-color: #FFF;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 3px solid #DDD8CE;
}

Answer №1

Your first item appears taller due to the presence of your profile picture (profile_circle). This image is using the float:right style, causing the div containing your menu to align next to it. However, the CSS rule .dropdown-menu>li>a specifies a block layout along with clear:both for the menu links, forcing the entire menu to be positioned below the image.

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

When using the resize property in monaco-editor, it may result in editor popups being obscured or

My current task involves utilizing the deltaDecorations method to display errors in my editor. Feel free to check out my code here: https://gist.github.com/dinager/41578bd658b60cc912a6023f80431810 Below is the output: https://i.sstatic.net/Dtj9A.png ...

Creative CSS spinners design

Seeking assistance to modify my spinner design. I want one end to be thicker and the other end to be thin. My attempts so far have been unsuccessful. <div id="data-loader"> <div class="loader"> <div class="blue"></div& ...

Having trouble adding animation to button element following the application of :after pseudo-element styling

I've been grappling with pseudo elements, but I just can't seem to make a simple button animation work using them. My goal is to have a panel move from bottom to top on hover. Similar to the button found on this page (1st row, 2nd button). From ...

Rotate Chevron icon downwards on mobile devices in a Multilevel Dropdown Bootstrap 4

Bootstrap 4 is being utilized for my current project, I am looking to modify the rotation of the chevron icon in a multi-level dropdown menu specifically on mobile devices when the parent link is tapped, Here is the code snippet for the multi-level dropd ...

Why isn't the Mat error functioning properly in this Angular code?

Could someone explain why the Mat error does not seem to be functioning properly in this Angular code snippet? <div class="form-group"> <mat-form-field class="row-styling"> <mat-label for="aplctnName"> Application Name <sp ...

What is the best way to make ng-style append to a pre-existing style?

I am facing an issue with my custom popover directive and another custom directive that uses it. I am attempting to use ng-style to adjust the width of the popover. Below is a code snippet from the directive's html template: <div my-custom-popover ...

Safari (mac) experiencing issues with loading material icons properly on initial attempt

Upon my initial visit to the website, I noticed that the font appeared distorted. https://i.sstatic.net/BtUxI.png However, when I right-clicked and chose "reload page", the fonts were displayed correctly. https://i.sstatic.net/3XUcA.png This issue seem ...

Struggling with the Nivo slider not loading properly?

Check out my personal website. I'm having an issue with my Nivo slider not displaying properly - it just keeps loading. Any ideas on why this is happening and how I can fix it? Below is the CSS I am using: #slider { position:relative; width: ...

Chrome failing to recalculate the width of an element as required

When attempting to size an element's width based on its height, I discovered what seemed like a clever solution using the transparent img trick: http://jsfiddle.net/6yc8a2yj/ The pink div displays correctly at a 1:2 ratio, but it fails to resize whe ...

Trouble with CSS in a WordPress theme utilizing a two-column layout

After setting up my wordpress blog (http://raptor.hk), I encountered an issue with aligning the right sidebar correctly. It seems like I have overlooked something in the CSS code. The div responsible for the sidebar has been assigned the name "rightbar". I ...

Error: The value being evaluated in document.getElementById(x).style is not an object and is not supported

Desired Outcome for my Javascript: I am working with a div that includes an "onmouseover='getPosition(x)'" attribute which can be dynamically added and removed through my javascript by clicking a specific button. The function 'getPosition() ...

When utilizing state in ReactJS to modify the color of my button, the change does not take effect on the first click. How can I troub

Whenever I click the button that routes to different locations via an API, the route works fine but the button color doesn't change on the first click. To address this issue, I implemented the useState hook and CSS to dynamically change the button co ...

Is it possible to utilize retina images with CSS3's :before selector?

Can I adjust the size of an image inserted using :before? For example, if I want to use a high resolution image in the content below - how can I specify the dimensions? .buy_tickets_btn:before{ content: url(../images/buttons/pink_ticket_btn_bg.pn ...

What is causing the content to overflow outside of the navbar on smaller screens or mobile devices?

/* *{ font-family: sans-serif; box-sizing: border-box; margin: 0; padding: 0; overflow-x: hidden; } */ .main { min-height: calc(100vh - 10rem); display: grid; place-items: center; } p { font-size: 4rem; line-height: 1.6; } nav ...

What strategies can be implemented to enhance the performance of this jQuery slider?

I have successfully created an image carousel. https://i.sstatic.net/CbypXxRr.png Encountered Challenges: The last slide is displayed, but the counter shows the first slide. How can I resolve this issue? When clicking play, it continues to advance ...

Ratios for Sizing Bootstrap Columns

The Bootstrap grid system consists of 12 columns in total. I am looking to utilize all 12 columns on the page. However, my goal is to have the first 6 columns on the left side be half the width (50%) of the columns on the right side. This means that the ...

Click here for more information in JavaScript Reading Link

I am trying to implement a feature where I only display half of the text from a Biography field on the first page, and have a continue reading link that reveals the rest of the text when clicked. I would like to accomplish this using HTML. Can anyone p ...

issue encountered while attaching css file / css styles not rendering

Here is the css link I am using: <link rel="stylesheet" type="text/html" href="/public/assets/lib/css/style.css" /> Despite trying various solutions such as removing "rel="stylesheet"", changing to "text/html", checking paths, placing it in the pu ...

Control the playback of multiple HTML5 videos with the ability to pause and resume, while also adding a

Trying to achieve the functionality of playing and pausing multiple videos. When one video is played, the others should automatically pause. The videos should appear blurred, except when actively playing. Does this make sense? http://jsfiddle.net/1frjov8e ...

Carousel Image Alignment Issue on iPhone SE Portrait Mode: All Images Centered Except One

Check out this website: It functions perfectly on Desktop browsers at all scales and works on Mobile devices in Landscape mode. However, I noticed that when using Portrait mode on my iPhone SE, the first image in the carousel appears off center in Chrome ...