The positioning of the "inline-block" element varies between IE and Microsoft Edge

I came across a similar question on Stack Overflow about IE rendering inline-block div differently than FF/Chrome, but unfortunately it didn't provide the solution I needed.

Below is the CSS code for my element (which appears as an invisible square link in HTML):

#box-scenario {
position: absolute;
margin-top: 43%;
margin-left: 37%;
background-color: rgba(255, 0, 0, 0);
width: 11%;
height: 21%;
display: inline-block; }

The positioning of this invisible square link seems to be around 200px higher compared to FF/Chrome.

Answer №1

Check out this Fiddle in various browsers. I included a striped parent div and added a red outline around the invisible link for reference.

The position of the invisible square link is approximately 200px higher in FF/Chrome.

In my observation, across all browsers, the link appears at 3.5 bars above the bottom. Where does it appear for you?

#parent {
  outline: thin solid black;
  position: relative;
  height: 180px;
  width: 180px;
  background: repeating-linear-gradient(to top, white, white 10px, yellow 10px, yellow 20px);
}
#box-scenario {
  position: absolute;
  margin-top: 43%;
  margin-left: 37%;
  background-color: rgba(255, 0, 0, 0);
  width: 11%;
  height: 21%;
  display: inline-block;
  outline: thin solid red;
}
<div id="parent">
  <a id="box-scenario"></a>
</div>

Answer №2

If you're struggling with inconsistencies in your design, a simple solution could be to reset all padding and margin in your CSS using the following code snippet:

* { 
  margin: 0; 
  padding: 0; 
}

By applying this rule, you will eliminate any default spacing applied by browsers, creating a uniform starting point for your design. This approach ensures that your layout is clean, intentional, and consistent across different browsers. It's a best practice that can greatly improve the visual coherence of your website.

Additionally, consider utilizing -webkit-margin(s) and -moz-margin properties for browser-specific adjustments as needed.

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

JavaScript - Uncaught TypeError: type[totypeIndex] is not defined

After following a tutorial and successfully completing the project, I encountered a JavaScript error saying "Uncaught TypeError: totype[totypeIndex] is undefined". When I tried to log the type of totype[totypeIndex], it initially showed as String, but late ...

Align images to the bottom of the gallery only if their heights differ

I'm currently working on an image gallery project and have encountered a problem. When all the image labels are of the same length, they align perfectly. However, if the label is longer than one line, it causes the image to move up instead of creating ...

What is the process for altering fonts in a Chrome OS application?

After extensive research on the Internet, I have been unable to find clear instructions on how to modify the text font in a Chrome OS application. Most search results pertain to adjusting the font for the OS user rather than the developer of the app. My i ...

Execute javascript function upon user scrolling to a designated section in the webpage

Is there a method to trigger a unique function every time a user scrolls to a different div or section of the page? ...

The <span> element stubbornly resists aligning inline within a flexbox container

Within a flexbox a element, I have a div that contains a span with the class .time-pretext: <a class="option-container option-edit-time" href="#"> <div class="option-icon"><canvas id="time-canvas" width="128" height="128"></canvas&g ...

How to position a textarea alongside a checkbox using CSS with Bootstrap

I'm having an issue aligning a text area next to a checkbox in my Bootstrap HTML. Here's the code snippet: <div class="form-group row"> <div class="col-12 form-check"> <label class="col-3 col-form-label" for="check15"& ...

Tips for creating a custom design for Material UI TextField using Modular CSS

I'm having trouble updating the border color of the Material UI TextField component using Modular CSS. Despite my efforts, I can't seem to get it to work. CSS (In Styles.module.css): .formInput { font-size: 18px !important; font-family: ...

"Enhance your website with captivating Javascript hover effects for

Can anyone assist me with incorporating the navigation hover effect seen on this website into my HTML/CSS project? The example site is built using a WordPress theme, but I am looking to apply that green effect to my own webpage and have the ability to cust ...

Tips for maintaining responsive resizing in Bootstrap 4 when the screen size decreases for an image that doubles as a hyperlink

Is there a way to make the images in the second container switch from a vertical layout on the right to a horizontal layout under the first container as the screen size decreases? The images should also resize to get smaller accordingly. The issue seems to ...

Alter the background image of items upon hovering over an item in a dropdown menu

Hey there! I'm currently working on a project using Bootstrap and have a simple navbar header that contains two dropdown menus with items. However, I now need to modify it to include sub-menu items with associated content, similar to the example below ...

Tips for Customizing the StrongLoop LoopBack Explorer CSS

Our team is currently utilizing Strongloop's LoopBack framework for our REST APIs and we are looking to customize the CSS of the LoopBack Explorer. Unfortunately, it seems unclear which CSS files are being employed (LoopBack vs Swagger) and their exac ...

Is a single f.select impacting another f.select in the same form? (undesired)

I am facing an issue where adding a new HTML element like: <%= f.date_select :date, { id: "date-select"} %> is impacting my existing collection select: <%= f.collection_select :id, Customer.where(business_id: current_c ...

Merge multiple list groups into one with a single active selection using Bootstrap List group functionality

Currently, I am experimenting with merging Bootstrap's accordion and list group with JS behavior. My goal is to create a set of list groups where only one option can be active at a time within each accordion. <link rel="stylesheet" href="https:/ ...

What is the best way to postpone the rendering of a table?

My table is bogged down by an excessive number of rows, causing a sluggish rendering process. I'm curious about the best method to address this issue. Are there any existing libraries specifically designed for this purpose? ...

PHP Code to Implement Toggle Bold on Click for References

I've been attempting to create a toggle effect on a reference tag by making it bold when clicked. Despite trying various examples I found online, I keep encountering this error: Uncaught TypeError: Cannot read property 'click' of null My a ...

Disabling vertical scrolling is achieved by binding this mousewheel event handler

On my website, I have implemented vertical scrolling without a scrollbar and one specific div also has horizontal scrolling without a scrollbar. The code I am using is as follows: (function() { function scrollHorizontally(e) { e = window.event || e ...

Selenium is detecting a textbox as hidden, despite it being visible in the browser on my end

My password textbox code is as follows: <input class="blahblah" id="someId" type="password"></input> While I can manually interact with this textbox in the browser, when attempting to automate testing using selenium, an error is thrown sayin ...

How to make a list with a scroll bar in an HTML table cell

Having trouble creating a scrollable list in a dynamically appended HTML table cell using JavaScript? You're not alone. Even after assigning the list to the cell parent, it seems that the list is not behaving as expected - it's not scrollable and ...

Verifying whether the file is an HTML image file type

My goal is to have a file input field where users can only select images. If an image is selected, the form should submit successfully, but if any other type of file is chosen, I want to display an error message. Here's what I have so far: $(document ...

How to interact with dropdown menu using Rselenium

Greetings, I am currently attempting to utilize Rselenium in order to interact with a dropdown menu. Specifically, the item I wish to click on within the dropdown menu is labeled Date Range. Upon inspecting the html code (refer to the image below), I iden ...