Picture with bordered corners - area underneath the image

Looking to create an image with borders in opposite corners, using ::after and ::before. Almost there - but the image isn't covering the whole space in the div. There is some weird empty space below the image (marked red in the jsfiddle). I'm stumped on what's causing this. The image's height changing the width is key for me. Any insights on where I went wrong? :)

Here's my code: https://jsfiddle.net/ndy79hvo/1/

Answer №1

The reason for this behavior is the default vertical alignment of images, known as the baseline, which results in some empty space below it to accommodate descenders from letters like j, p, and y. To rectify this issue, simply add display: block; to the CSS rule for your image.

Visit this link for more information!

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

On the same line, there are two divs with different characteristics - one dynamically changing width and the

I am facing an issue with arranging two divs under one parent div. The parent div is set to have a width of 100%: <div id="parent"> <div class="left"></div> <div class="right"></div> </div> The specific conditions ...

Need help speeding up website load times?

My website is loading incredibly slow, even though it has minimal content. I suspect that the high number of images and JavaScript elements on the page are contributing to this issue. Is there a method available to diagnose what exactly is causing the ext ...

Tips for creating a responsive graphic using Bootstrap CSS

I am currently trying to determine how to create individual graphics that can be directly loaded via CSS and made responsive. When I resize the screen, the graphics also adjust accordingly. However, on smaller displays such as mobile phones, the graphics ...

Displaying posts in a specified proximity using HTML5 and JavaScript geolocation

Despite my efforts to search the internet for solutions to my problem, I have come up short and feel a bit hesitant requesting help. I am not well-versed in JavaScript but it is required for what I am working on. I am creating something that involves user ...

How can I prevent katex from overflowing?

Currently, I am facing a challenge in handling katex equations that overflow in a react native webview. I am attempting to dynamically break the equations into multiple lines to prevent scrolling and display them separately. Any assistance on this matter ...

I am looking to create a feature that will pause the current song when I press the play button for a new one

Allowing the function to receive a variable that determines which song will play (for multiple buttons redirecting to multiple songs) has caused an issue. Pressing one button and then another results in two songs playing simultaneously. The current challen ...

Is there a way to organize a specific column based on user selection from a drop down menu on the client side?

When selecting Timestamp from the drop-down menu, I expect the TimeStamp to be sorted in either ascending or descending order. Similarly, if I choose Host, the Host should be sorted accordingly. Despite using the Tablesorter plugin, sorting doesn't s ...

Maintained grid column stability amidst various modifications

I have a complex 2-column grid layout, and the example shown here is just one part of it. The complete code follows a similar structure. I am looking for a way to ensure that the green box always stays close to the red box in the layout, without having a ...

Is there a way to apply a scaling transformation to an element in react native that is relative to the window size by a percentage?

One method that can be used to achieve a similar result is by following this formula: const { width } = useWindowDimension(); const percentage = width * 0.8; // 80% of the window <ComponentOrElement style={ width: percentage } /> However, this calc ...

I encountered a height discrepancy when attempting to style an unordered list to resemble a table

I have created a set of ul lists that appear as a 2-column table, just as I needed. However, an issue arises when the content of any list increases. The problem is that equal height is not being applied, causing the table to look broken. Here is my Fiddle ...

Did my code effectively block an XSS attack?

Recently, I was informed that my website has vulnerabilities to XSS attacks. In an effort to improve security, I have implemented the htmlspecialchars method as a preventive measure. Here is the function I created: function _e($string){ return htmlsp ...

Creating HTML inputs dynamically using jQuery in an ASP.NET application

I have written this JavaScript code to dynamically generate and add HTML elements within my asp.net webform: var i = 0; function addFields() { i++; var quantity = '<td class="auto-style2"><input type="text" size="3" name= ...

Activate the dropdown menu when ul element is in focus

I am working on creating a dropdown navigation using pure CSS. I want the dropdown menu to appear when clicking on the ul. The issue I am facing is that simple ul:focus > ul does not seem to work, even though there is an anchor within it. However, the : ...

Learning to render a hexagon on an HTML canvas using TypeScript

After drawing a hexagon on canvas in HTML, I encountered an issue with the translate method. Although it works fine with rectangles, the hexagon does not get translated as expected. To address this problem, I defined the canvas and context elements using ...

Execute a JavaScript function triggered by PHP validation and form submission

I have implemented PHP validation for a form where if a user forgets to enter a username, an error message is displayed. Instead of displaying a text error message, I want the input box to be highlighted in red using JavaScript. However, I am encountering ...

XHTML markup error found: missing end tag for "div" element in W3C validation

Just finished validating my web page using the W3C markup validation service. You can find the results here. Here's what was returned: Error Line 112, Column 7: end tag for "div" omitted, but OMITTAG NO was specified </body> Info Line 16, C ...

HTML code for positioning an image after resizing

Within an HTML page, I have an image that has been resized to a width of 400px using CSS. .cropbox { width: 400px; height : auto; } Additionally, there is a JavaScript function associated with the image that allows users to select a point on the image. T ...

Adjust the font color to match the background in a div

I am currently working on a project where I need to place text on a dynamically generated background. To ensure that the text is clear and readable, I want to determine the color of the text based on the background. After some experimentation, I came up w ...

What is the best way to align an extensive text and an image side by side within a table cell?

I am facing an issue with my code. In one of the td elements, I have the user's name image on the left and their first name on the right. The problem arises when the first name is too long, causing the image to disappear. Everything works fine if the ...

I'm encountering issues with adding a div element using Jquery

I've been attempting to insert a div using jQuery, following the code example below. Unfortunately, it's not working as expected. jQuery: $('<div />', { $('<img />', { "src": "/Pages/Images/calendar.png").add ...