Scaling images using SCSS in Internet Explorer 11

I am encountering an issue with displaying an image in IE11. The image appears correctly in all other browsers, but in IE11, the bottom and right side of the image are cut off. Here is the SCSS code for the image:

 &__container {
    text-align: center;
  }

  &__logo {
    img {
      background: transparent;
      height: 13.5em;
    }
  }

To address this problem in IE11, I have added custom CSS specifically for this browser:

&__logo {
    img {
      background: transparent;
      height: 13.5em;
      @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
        width: 30%;
        height: 30%;
      }
}

While this solution displays the entire image in IE11, it still renders larger than expected compared to other browsers and introduces some padding below it. Additionally, it disrupts the text-align:center property, causing the alignment to shift slightly towards the left.

I have experimented with adjusting the height and width properties independently, but without success. Any guidance or suggestions on how to resolve this issue would be greatly appreciated!

Answer №1

It seems like you've added a piece of code without any HTML structure, making it difficult to determine if it will be effective. Try adding display: block; to the img element, as it may help with compatibility in IE11.

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  padding: 0;
}

body {
  padding: 0;
  border: 1px solid #000;
}

.logo {
  display: block;
  margin: auto;
  width: 800px;
  border: 3px solid #ff0000;
}

.logo img {
  display: block;
  background: transparent;
  height: 13.5em;
}
<div class="container">
  <div class="logo">
    <img src="https://dummyimage.com/600x400/000/fff" alt="">
  </div>
</div>

Answer №2

Interestingly, deleting the height property and including the max-width attribute resolved the problem.

&__logo {
    img {
      background: transparent;
      max-width: 12em;
    }
  }

If someone has insight into why this worked, please share in the comments for future reference!

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 iPad, CSS styling will not be visible if an element's width exceeds 920 pixels

I recently developed a website optimized for monitors, but when I viewed it on an iPad, the right corner was missing some CSS styles. Take a look: Here is the HTML code: <div id="nav-top"> <div class="wrapper"> <!-- To ...

Steps to eliminate the select all checkbox from mui data grid header

Is there a way to remove the Select All checkbox that appears at the top of the checkbox data column in my table? checkboxSelection The checkboxSelection feature adds checkboxes for every row, including the Select All checkbox in the header. How can I ...

Eliminating the final space in CSS flexbox layout

When I set the display of an element to flex, I noticed that the last space in a text string gets removed. <div class="has_flex"> Some text <a href="link">Link</a></div> After setting display to flex: <div class="has_flex"> ...

Contrasts between space and the greater than selector

Can you explain the distinction between selector 6 and selector 7 as outlined on the w3 website? Inquiring minds want to know. ...

Efficiently Aligning Elements in CSS both Vertically and Horizontally

I'm struggling to align my form both vertically and horizontally. It's okay if this doesn't work on IE - I will include an IE detection script to prompt users to switch browsers. However, Firefox and Chrome support is essential. Below is m ...

Utilize vuejs transition-group with Bootstrap's grid system

I'm currently attempting to implement vuejs transitions with Bootstrap grids, but it seems to be causing some issues with the grid system. This is because the transition-group feature alters the DOM structure by inserting a new tag between the row and ...

"Centralize your online store with the Woocommerce products shortcode

Looking for help centering a Woocommerce shortcode product object like the 'Chanel printed logo shopper' example found here: Woocommerce provides this code: [product id="6606"]. I've attempted to use standard Wordpress align center, as wel ...

Is there a way to make the fixed table header scroll along with the table body data?

I am facing an issue with my table where I have multiple columns. I have managed to fix the table header successfully, however, when I scroll horizontally through the table body columns, the header remains fixed and does not move accordingly. How can I res ...

Adjust the text placement on the toggle switch to turn it On or Off

I am looking to create a toggle switch with a small size. I found some code on Stack Overflow that I tried but it didn't work as expected. The code snippet I attempted to use is from another helpful post. My goal is to have the "on" text align to th ...

Modify the CSS formatting of a specific element with its designated ID

On my HTML page, I have an element that looks like this: <label id="lb">Label1</label> In my corresponding CSS file, I have defined the following style for it: #lb{ width:100px; } I want to override this style. What would be the most effect ...

Is there a way to dynamically adjust the background box size to fit the inner boxes using node.js?

click here for the screenshot of the webpage I'm working on Hey there! I'm currently working on a school project for my assignment. I'm having some trouble adjusting the size of the background grey box to fit with the content inside, such a ...

What are some methods for customizing the calendar icon displayed in an input field with type date?

Is there a way to customize the calendar logo without relying on jquery? The desired appearance should resemble the image shown below: https://i.sstatic.net/G06iZ.png input { width: 50%; padding: 8px; border-radius: 10px; ...

Experiencing the Pause: A Fresh Take on

I'm currently using this slideshow for a project, and I need to understand if it's possible to resume its interval. The current issue is that when you hover over the slideshow, the progress bar stops. But once you remove the mouse, it continues f ...

The modal window does not display a scroll bar

I'm currently facing an issue where the scroll bar is not appearing on my page when more elements are added. In addition, I have a modal that covers the entire page when clicking on an item. However, changing the CSS position: fixed property affects ...

Create stunning HTML emails by incorporating a transparent background color behind images and text

Is there a way to add text on a transparent background layer placed over an image without using the background-image property? In my case, I am working on an HTML Emailer and must utilize the img tag instead. Any suggestions on how to achieve this? < ...

Pop-up modal from Bootstrap appearing on top of the page header

I'm working on a website layout where the header always stays on top of everything. However, whenever I add a bootstrap modal that pops up, it ends up covering the header with a grey area. I've attempted to adjust the z-index values for both the ...

The highlight_row function seems to be delayed, as it does not trigger on the initial onClick but works on subsequent clicks. How can I ensure it works properly right from the first click?

I developed an application using the Google JavaScript Maps API to calculate distances between addresses. I've encountered a bug where the row in the table is not highlighted on the first click, requiring a second click for the highlighting to take ef ...

How can I navigate to column 3 of an HTML table using XPATH with Selenium Webdriver in Python?

I have extracted the text from the Name column of an HTML table using XPATH, which corresponds to column index [1]. Now, I need to navigate to the 3rd column with index [3] using XPATH, but I'm not sure how to proceed. Here is my current XPATH: //ta ...

Strategies for identifying CSS properties within a div element

I am attempting to identify the CSS property display of a div. If it is set to display:block, I want to change the icon to -. If it is set to display:none, I want to change the icon to +. I have tried using the following code but it does not seem to work: ...

"Add a new style sheet to the homepage of your WordPress site using the

I have been attempting to utilize a separate style sheet in order to customize the front page of my wordpress website. Despite several attempts, I have not had any success. Below is the current code that I am working with: add_action('wp_enqueue_styl ...