The child's size exceeds the parent's dimensions due to its padding

I am facing difficulty in making the size of my <a> tag match the parent div (#logo) without exceeding its boundaries.

HTML

<div id="header">
    <div id="logo">
        <a href="#"></a>
    </div>
    <div class="hide" id="navigation">
        <ul>
            <li><a href="#">About</a></li>
            <li><a href="#">Examples</a></li>
            <li><a href="#">Form</a></li>
            <li><a href="#">Contact</a></li>
      </ul>
  </div>
</div>

CSS

div#logo {
    background: url(https://i.imgur.com/sHTtXk4.png) no-repeat center center;
    background-size: cover;
    float: left;
    line-height: 80px;
    width: 10%;
    height: 80px;
    text-align: center;
}

div#logo a {
    background: #fff;
    width: 100%;
    height: 100%;
    padding: 100%;

https://jsfiddle.net/vwbo9exg/

Answer №1

Eliminate the padding property and include the display property for the a element

div#logo a {
    background: #fff; 
    width: 100%;
    height: 100%;
    /* padding: 100%; */
    display: inline-block; /*This line is new*/
}

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

What is the best way to create a set of buttons that function like an accordion, displaying only one dropdown at a time?

Looking to design a user-friendly restaurant menu with categorized buttons that reveal information when clicked. The goal is to display one category at a time, so when a new button is pressed, the previous category disappears. Struggling to find a solutio ...

Is it possible to open a new tab window using a radio button?

Looking for assistance with radio buttons. I want users to be redirected to a new window when they click the submit button beneath the radio buttons. If anyone has a solution, please help! I have tried using window.location.href and window.open but the c ...

Is there a way to confirm the presence of the username and password in my websql database for the login page?

Take a look at the code snippet below for my login page: <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> <script type="text/javascript" src="C:\Use ...

Is it advisable to restrict ajax requests?

Is using ajax requests more resource-intensive than a traditional page load? Consider a basic menu with standard links where clicking a link takes you to a new page. By using ajax, I can avoid this default behavior and instead fetch the linked page' ...

Removing a background by linking a CSS file

Issue Resolved: I have found the solution. The problem was that the css document still contained html tags. Thank you to everyone who provided assistance. While designing a website using css, I encountered a situation where the site worked perfectly when ...

Verifying Text Presence in an Element with Selenium: A Step-by-Step Guide

HTML: <span class="A" style="color: rgb(10, 133, 154);">3 </span> Selenium: let total = await driver.findElement(By.css(".A")).getText(); Scenario: In my Selenium script, I've implemented a method to capt ...

Updating a conditional statement in jQuery

Understanding jQuery has always been a challenge for me. I find myself spending hours reading documentation every time I try to implement it, only to achieve very little progress. Here's the code I'm currently working on with live-editing availab ...

Nested CSS selector within a parent element

How can I change the color of both elements inside a custom button when the button is active? The first color is defined by the class of the button, and the second color is defined by the class of the span inside that button. CSS: .buttonClass{ color:b ...

Is there a way to verify the content of a span and automatically guide the user elsewhere if it meets certain criteria?

Currently, I am facing an issue with adding Google authentication to my website as the redirect function is not working properly. As a solution, I plan to implement manual redirection using JavaScript in case the value of the span element is <span id= ...

Develop a tree structure that showcases various directory paths

I have a multidimensional array containing various folder paths. My goal is to create a single tree structure from this array, similar to what you see when using the "tree" command in the terminal. Please excuse any mistakes in my English and forgive my li ...

What are some effective methods for organizing HTML in a clean and orderly manner?

I have limited experience with HTML, but I need to layout a form in a precise manner similar to WinForms. Here is my attempt using the little CSS and HTML knowledge I possess: The issue lies in everything inside the white area being ABSOLUTELY LAID OUT .. ...

Stop text from breaking out of the flexbox container

I am trying to integrate an image with a text link into a flexbox container. However, I am encountering an issue where the container breaks and appears incorrectly on smaller screens: https://i.sstatic.net/4DvY1.png <el-container> <el-main& ...

Problem encountered with Blueimp gallery and Twitter Bootstrap

Blueimp gallery is being used to showcase a set of 8 images on a website, divided into two rows. The 5th thumbnail (first image on the second row) appears broken, even though it can be seen in the carousel presentation. Here's the link to view the th ...

Transform colored svg:image elements into grayscale when clicked upon by utilizing d3

Visit this site I'm attempting to change all SVG images created using d3.select to grayscale by using the following function: JavaScript: <script> function convert() { d3.selectAll("image") .style('filter', 'graysc ...

Automated suggest feature similar to Stack Overflow's tag completion

Can you explain the concept behind using a tagging system similar to Stack Overflow? Specifically, I am interested in the front-end implementation. Are there any specific libraries that offer features such as auto-complete and tag separation, similar to ...

jQuery's outerHeight() and height functions may experience flickering or fail to update properly when the window is resized to an odd number

Two elements are placed side by side on a webpage. One element, with a fixed size of 100vh, is named .hero-half, while the other element, holding text of varying lengths, is fluid and labeled as .project-details. When the text container extends beyond the ...

Execute Django code post webpage loading

Looking for a way to have the python code on the web page update every second if the database has changed, but currently it only runs on page load due to django functionality. function refresh(){ //Clear info boxes {% for TrackedObject in ...

Generate a list of users using Angular in an efficient manner

I am working on creating a user list similar to the image provided below. I am using Angular and Bootstrap for the basics of this project. However, my concern is how to efficiently handle a large number of users. If the user count exceeds 10k, what would b ...

Creating a dynamic CSS hover animation for an input element with jQuery to ensure compatibility with Microsoft Edge

I am facing an issue where I have a row of six to nine switches with the <input type="checkbox"> element, and each switch animates when hovered over. In this animation, the knob slides down, and both the knob and track fill with colors or gradients. ...

What could be the reason for the compatibility issues between CSS/SASS modules and a third-party library?

I am puzzled by the fact that my sass modules do not affect the third-party component I am using, specifically react-horizontal-scrolling-menu <ScrollMenu selected={selected} scrollToSelected={true} data={items && items.map((item: any) ...