The display:block links are not properly positioned within the absolute div

I'm having trouble figuring out why my links are not working for the .pushMenu divs on the left and right side,

html:

<header class="header">
    <div class="pushMenu" id="left">
        <a href="" title=""><p>l</p></a>
    </div>
    <div class="pushMenu" id="right">
        <a href="" title=""><p>r</p></a>
    </div>
    <div>
        <span class="myTitle">title</span>
        <span class="myBy">(by me)</span>
    </div>

css:

header {
    text-align: center !important;
    line-height: 60px;
    font-weight: bold;
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 60px;
    color: #ffffff;
}
header div.pushMenu {
    position: absolute;
    width: 30px;
    height: 30px;
    top: 10px;
    border: 1px solid white;
}
header div.pushMenu#left {left: 10px;}
header div.pushMenu#right {right: 10px;}
header div.pushMenu a {
    width: 30px;
    height: 30px;
    display: block;
}

see in action: http://jsfiddle.net/GDQdU/4/

what could be causing this issue?

Answer №1

This issue is occurring because the line-height set for the header is also affecting its child elements. See below for a solution.

To resolve this problem, remove the p tag from the a element and adjust the HTML as follows:

<a href="" title="">r</a>
Then, include line-height:30px in the styling of the a element.

header div.pushMenu a{
  line-height:30px;
}

DEMO

OR

If you prefer to keep the p tag within the structure, make the following adjustments to your CSS:

header div.pushMenu p{
  margin:0;
  line-height:30px;
}

DEMO

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

Is there a method to prompt the browser to retain form data when using the back button?

Having a puzzling problem. I've developed a sophisticated quote form for our company that utilizes ajax to display prices for products based on user input. There are 6 hidden fields set up as follows: productname1 productname2 productname3 and the ...

How come my picture is clinging to the bottom of the container?

I am facing an issue where my "vertical rule" is sticking to the bottom of the container when placed to the right of the image. <div> <div style="display:inline-block; width:210px;"> <img src="res/img/PlayBtn.png" style="top:- ...

The options in the drop-down menu appear to be stuck and remain in place

Can someone with expertise lend me a hand? I've been racking my brain over this issue, and while I feel like I'm on the right track, I just can't seem to make my sub-sub menu items drop down to the right on hover. I suspect there might be c ...

Scaling divs proportionately using a container

I have numerous elements enclosed within a <div class="wrapper">. My aim is to resize this outer div and ensure that the inner elements scale proportionately along with it. For instance, when dealing with a group of SVGs, adjusting the transform pro ...

Changing the appearance of the navigation bar

<!-- Bootstrap 5.0.x library --> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3c5e5353484f484e5d4c7c09120c120e">[email protected]</a>/dist/css/bootstrap.min.css" ...

Unable to load AngularJS thumbnails from JSON file? Learn how to showcase a larger image by clicking on the thumbnail

Working with AngularJS to retrieve image data from a JSON file has been successful for me. My next task involves loading all of the thumbnail images into the gallery div and populating the src, alt, and title attributes using ng-repeat. However, this part ...

The feature in Chrome that automatically reloads generated CSS is failing to refresh the page after SASS recompiles the CSS

I'm attempting to set up Chrome's DevTools to automatically reload a page when I save changes to a watched SCSS file that compiles and updates the CSS file. Although I have checked the Auto-reload generated CSS option, it is unfortunately not fu ...

Modifying the HTML text within jQuery is not within my control

I haven't worked with jQuery in a while, and I've forgotten a lot of things about it. I attempted to change the text of an element when clicked, but for some reason it's not working. <!DOCTYPE html> <html lang="en"> < ...

Linked dropdowns with an HTML table feeding data

I have a piece of code that is currently being used to filter user selections. However, I am interested in utilizing an existing HTML table as the data source for the igcombo box instead of the JavaScript array. How can I achieve this? Below is the code s ...

A JointJS element with an HTML button that reveals a form when clicked

How do I bind data to a cell and send it to the server using the toJSon() method when displaying a form on the addDetail button inside this element? // Custom view created for displaying an HTML div above the element. // ---------------------------------- ...

Bootstrap: Issue with padding top and width not being applied correctly, whereas padding-bottom works without any problems

<div class="container-fluid border"> <a href="#" class="name"> John Doe</a> </div> margin and background-color properties of "name" class are not applied correctly. ...

Illustration tucked beneath the menu

I am looking to create a landing page for my project similar to the design on this website. I am using Bootstrap 4 and HTML, but struggling to hide the background image behind the navigation bar. Can anyone help with this issue? ...

Elements are not detected after applying display:none

Within the onLoad event, I implemented a function to hide multiple div elements by setting their CSS property display to "none" and assigning them the class name "invisible": function hideContent() { laElements = document.getElementById("content").chil ...

Modifying HTML attributes using AngularJS

Is there a straightforward method to dynamically alter an HTML attribute? I've used Angular's scope variable and ng-hide to hide a div, but the size of the div remains unchanged. How can I adjust the size of that particular div? I attempted th ...

Position the image, text, and header within a box in uniform alignment

Currently, I am working on a design that includes an image, a header, and some text inside a box. However, I am facing an issue with aligning the header so that it appears above the rest of the text. The layout is not turning out as expected. https://i.ss ...

Set the class of an element dynamically using ng-class and detect changes with ng-change

I want the input field to initially have the class .form-control-error. When the user clicks on the field and starts typing, I would like it to change to .form-control-success. I attempted the following code but couldn't get it to update. The ng-chan ...

Include an iframe with hidden overflow specifically for Safari browsers

I have a situation where I'm using a third-party iframe to display specific content. The iframe is enclosed within a div container that has border-radius and overflow: hidden properties applied. Strangely, the content inside the iframe doesn't se ...

What is the best way to post an image using nodejs and express?

Recently, I've been working on a CMS for a food automation system and one feature I want to incorporate is the ability to upload pictures of different foods: <form method="post" enctype="multipart/form-data" action="/upload"> <td>< ...

Modify the width of a div within another div using CSS dynamically

I am working on creating a unique custom div that contains input text and two buttons inside it. Here is the initial design: https://i.sstatic.net/WIzrN.png However, when I resize the screen, the layout shifts as shown here: https://i.sstatic.net/ziO08.pn ...

Calculate the sum of a column in a table that is dynamically populated

I'm using jQuery to load a table with data: function getSales(customerId, fromDate, toDate){ $.ajax({ type: 'POST', url: 'ajax/sale_pl.php', data:{customer_id:customerId, from_date:fromD ...