In Internet Explorer, adjusting the margin-top to -15px causes the icon to shift downward, while setting it to -16px moves it

I am looking to add an icon to the right of the input field to create a combo effect. In order for it to work properly, I need to use position relative and write a jQuery plugin to make it reusable.

The code works fine in Firefox and Chrome, but there is an issue in IE-9. Adjusting the icon's margin-top to -15px makes it go slightly lower, while setting it to -16px moves it to the top of the input field.

How can I resolve this problem?

<!DOCTYPE HTL>
<html>

<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="robots" content="noindex, nofollow">
  <meta name="googlebot" content="noindex">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

<body>
  <div style="width:50%; position:relative; top:0; left:0; height:0; background-color:#ccc;">
    <input class="rounded" type="text" style="width:100%;">
    <img src="https://placehold.it/77" style="position:relative; z-index:2; float:right; margin-top:-16px; padding-right:5px;" />
  </div>
</body>

</html>

Answer №1

Have you considered using top:-value; as an alternative? It may be more beneficial for your needs.

If you decide to go with margin-top, remember to include the following code specifically for ie9:

margin-top/*\**/:-16px\9; while keeping the other browsers in mind as well.

This suggestion could potentially be helpful for you.

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

Choose each day's time slot on the jQuery FullCalendar version 2.x

The code snippet below is a segment of the code generated by the FullCalendar jQuery plugin version 2. It has undergone some changes from version 1.x in terms of the classes it utilizes. <div class="fc-slats"> <table> <tbody> ...

When scrolling, custom cursor object disappears from view as it moves along with the mouse

My goal is to have a custom object follow the mouse by changing the translate property and assigning x and y values to it. Everything works fine initially, the object appears and moves within the first frame. However, when scrolling down, the transform pro ...

Tips on eliminating excess white space or margins beneath a flexible video player

My issue is with a video and some content underneath. When I reduce the height of the video on mobile, there is too much white space below it. @media only screen and (max-width: 600px) { video { height: 80%; } Instead of adding margin-bottom ...

Tips for effectively utilizing tabs to showcase information for a particular user rather than solely the initial one

I am fetching multiple user data from an API call, and all users are rendered using the same HTML and CSS. However, when I switch between tabs for each user, only the first user's information changes instead of the specific user I clicked on. I have a ...

Hide the scrollbar when scrolling is unnecessary

After applying the CSS below, a div I have now has a scrollbar. The issue is that even when scrolling isn't necessary, the bar still appears empty. Is there a method to only display the scrollbar if the content overflows? Any suggestions would be appr ...

Showing information in Django

Currently, I have a template that utilizes the {% for object in objects %} tag to display all objects from my data. However, it seems like each object is enclosed within a <p> tag when converted to HTML. My goal is to showcase these objects in pair ...

Steps for removing all inline styles within an element:1. Access the element's

I have a group of span elements containing texts generated by tinymce. <span class="ArticleSummary"> This content is produced using a text editor and may include various inline styles. </span> Typically, this text includes numerous inline s ...

What techniques can I use to format my blockquotes in this particular style?

I'm struggling to figure out how to incorporate yellow blockquotes into my quotes without the formatting causing unwanted indents and line heights. My goal is to achieve something like this: https://i.sstatic.net/4O1NR.png This is what I've at ...

Refresh the content of an iframe (local HTML) by clicking on buttons

When a user clicks on a button, I am loading an HTML file into a DIV (iframe). The issue arises when the user clicks another button and wants to reload the iframe with a different HTML file. This is the current code snippet: <script type="text/javasc ...

I'm attempting to arrange the movieCards in a horizontal row, but they keep stacking up vertically instead

I have created a movie list component with different attributes in the div section to display the cards in a row. However, all the cards are currently aligned in a column. Should I use flex or grid to achieve the desired layout? If so, how can I implement ...

No information available at the moment

When the data is not present, it displays as "display none"... However, I want it to show "no data found" This is the current code if (a.innerHTML.toUpperCase().indexOf(filter) > -1) { li[i].style.display = ""; } else { li[i].styl ...

Content Security Policy (CSP) recommendations for CSS files that are

I am facing an issue where a third-party JavaScript file is being loaded into my application, which then injects an iframe onto the page. This iframe subsequently loads its own JavaScript that creates an inline style tag in the parent window. Due to this ...

Eliminating the gray background using CSS

How can I remove the gray background that automatically appears in my CSS header? .header { padding: 60px; margin: 20px auto auto auto; width: 1400px; border-radius: 10px; text-align: center; background: # ...

Issues arise when incorporating background images with bootstrap 3

Currently working on designing a responsive layout for an online clothing store using Bootstrap 3. One of the requirements is to use background images inline styles for product containers. However, facing difficulty styling the containers and images to ach ...

What is the best way to line up two forms side by side?

Looking to create a login view for a webpage with two forms (one for registration and one for login) aligned side by side. Initially attempted using a table, then tried using bootstrap form groups (rows and cols) without success. Finally, aligned them in t ...

Position the read more buttons in JavaScript at the bottom of the div

I designed three boxes in this section with content inside. To enhance the functionality, I added a feature that made the boxes smaller. Everything was functioning perfectly, but I encountered an issue with the alignment of the buttons at the bottom. Is th ...

Allow frontend JavaScript to retrieve a text file that is restricted to individual users

Trying to articulate my goal is challenging, but I'll do my best to clarify. My objective is to enable JavaScript (or an alternative solution) to retrieve data from a text file on a static site and utilize that data in some way. The challenge here is ...

Achieve a top position in CSS layout without resorting to negative values

This may seem like a simple thing, but I'm struggling to achieve it without using negative values for padding-top. Here's how my site looks: Here is the CSS code I am using: .center { width: 1030px; margin: 0 auto; } .top-panel { backgr ...

The CSS property object-fit: contain; ensures that the original image width is maintained in the layout

I am attempting to create responsive images within flexbox containers using the CSS property object-fit: contain. While the images are resizing, the layout seems to be maintaining the original size of the image, resulting in a scrollbar appearing. Upon in ...

Navigate to a precise section of the webpage, positioned at a specific distance from the top

When scrolling on my page, the static header moves along with the user. However, when I link to a specific div using the standard method, the div appears behind the header. I would like to utilize: <a href="#css-tutorials">Cascading Style Sheet Tut ...