When using IE10 and Opera 12, setting the opacity to less than 1 and display to inline may result in an unusual cropping effect

For this inquiry, with the approval of the staff and community, I would like to address two separate bugs that occur in different browsers under similar conditions.

The bugs manifest when an element with display:inline (and a box-shadow, although this is primarily for demonstration purposes) has an opacity less than 1. In these cases:

  1. IE 10 (at least) cuts off the box-shadow as if "overflow:hidden" was applied.
  2. Opera 12.15 only displays the box shadow on the first line of text.

To showcase the issue, here is the HTML snippet:

<span class="inline opaque">
    <span>Some text.</span>
</span>

CSS styles:

.inline{
    display:inline;
    background:red;
    box-shadow:0 0 0 10px red;
}
.inline.opaque{
    opacity:.5;
}

View a live example. It's quite frustrating dealing with this issue. It seems very odd and unfamiliar to me. Any assistance would be highly appreciated.

Thank you!


UPDATE: I think I have found a workaround for IE. It appears that we can adjust the box-shadow by moving it to the left and top (the directions where cropping does not occur). To visually maintain the same space occupied by the element, we can utilize transform. You can see it more clearly here.

@media screen and (-ms-high-contrast:active),(-ms-high-contrast:none){
    .block{
        -ms-transform:translate(5px, 5px);
        transform:translate(5px, 5px);
    }
    .inline{
        box-shadow:-5px -5px 0 5px #c0c;
    }
}

Keep in mind that we may also need to shift (potentially with translate) the contents of .inline.

Answer №1

Every single line within a display:inline element serves as its own little box. This becomes apparent if you were to add a border:1px solid black style to your text.

Because of this, it makes sense for the browser to display shadows individually, even if that means positioning them on top of elements (aka lines) that come before them.

As for why the "cropping" issue is only seen in specific browsers and when opacity is set to less than 1... well, that's more about how each browser interprets things. Nonetheless, the cropping behavior can actually be considered technically correct.

The simple solution here is to just apply the opacity to a parent container, like demonstrated here.

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

Formatting Text in CSS and HTML

I need help aligning three images horizontally with text underneath, using CSS. Despite trying multiple methods, the images remain vertically aligned and the text does not align properly with the images. #img_cont { display: table; width: 90%; ...

A design featuring two columns and a fixed footer

I'm struggling to make my 2-column layout display properly with a footer that sticks to the bottom of the page. Despite following all the usual advice, my columns keep expanding beyond their container div, which causes the footer to get pushed off the ...

Which CSS property is utilized to position the parent level of a menu below the children when they are shown on the screen?

Recently, my Drupal superfish menu has been acting up after updating the module. The issue I encountered was that the children no longer appear above their parent items. Can anyone help me figure out which setting dictates the order in which they are dis ...

Bootstrap 3.2.0 Grid Column Creation Problem Identified

On my webpage using Bootstrap 3.2.0, I have a layout that includes dynamic column generation and content within those columns. However, I am facing an issue with this setup. Can anyone advise me on how to resolve it? Your help is greatly appreciated. ...

Modifying the Dropdown height in Angular: A step-by-step guide

Currently, I am utilizing Angular, Angular Material, and css I'm facing difficulties in reducing the height of the mat-select Dropdown and achieving proper vertical alignment for the text inside it. <mat-select class="frequency-dimensions&quo ...

Position anchor images in a horizontal alignment using a vertical CSS sprite

There are 4 images in a vertical sprite that I want to display horizontally on my page as clickable links. The first image should start at position left:250px and top:2px with a padding of 3px between each image. CSS .sprites { background:url('/ ...

Creating a responsive navigation menu by converting overflowing menu items into a dropdown list

I'm currently designing a menu that contains multiple list items. I would like the overflowing li's to collapse and display in a dropdown when resizing the browser to smaller screens, such as laptops and tablets. Original Menu. https://i.sstatic ...

Utilizing Ant Design Icons without an Internet Connection

In my current project, a reactJS application utilizing ant design for the UI was recently deployed to production on locked down computers. These computers lack internet access, causing ant design icons on modals to appear as empty boxes. Upon investigation ...

Menu toggle vanishes suddenly

Whenever I click the toggle button, I notice that the menu (which I have set to appear on toggle) only shows for a brief moment before disappearing. As a beginner in bootstrap, I am sure I might have made some obvious mistakes. Any assistance would be gr ...

Create a smoothly animated skewed div without any unwanted side effects

Recently, I had an idea to create a unique menu using parallelogram containers and animate them with CSS. My concept involved changing the height of the parallelogram when hovering over an item to achieve a visually appealing scaling effect. However, whil ...

When incorporating the Bootstrap 5.3.3 grid with the class 'row w-100', there appears to be a noticeable amount of unused space on the right side

While trying to implement Bootstrap grid, I ran into an issue. When executing the code below: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, i ...

Activating Bootstrap modal when a navigation link is clicked

Just started a site for a client and new to Bootstrap. I've got the layout down - full-width page with "Top Nav" within the nav bar, looking to create a modal effect drop-down. When clicking on "About", it should trigger the .modal function. However, ...

I'm curious about the meaning behind this code snippet: `$Odd = ($Odd == "even") ? "odd" : "even";`. Any ideas?

<?php $Odd = "even"; $query = $MySQLi->query("SELECT id, look, username, motto FROM users WHERE rank = '7'"); if($query->num_rows > 0): while($UserRow = $query->fetch_assoc()) { $Odd = ($Odd == "even") ? "odd" : "even"; ?&g ...

Minimize the gaps between items within a CSS grid design

I'm struggling with adjusting the whitespace between 'Job Role' and 'Company Name' in my grid layout. Here's a snippet of what I have: https://i.sstatic.net/l55oW.png The container css is set up like this: .experience-child ...

Testing out various Xpaths but none seemed to be effective

I am trying to extract a score from the following URLs: shows a score of "10" displayed in an Octagon image, while has a score of "5". Upon inspecting the elements, I found the score represented as: <text y="100" dy="0.32em">& ...

What steps can be taken to resolve the unexpected padding issue in a Bootstrap form?

https://i.sstatic.net/iSz2e.png <form class="form-inline"> <div class="form-group"> <div class="input-daterange input-group" id="datepicker"> <label>Beginning:</label> <input type="text" ...

What are some tips for using CSS display grid to effectively showcase my HTML content?

Visit my About Me page with custom menu styling Any tips on aligning the body with the grid function to achieve this particular design? ...

Having trouble getting buttons to wrap onto a new line instead of spilling over the container

Struggling with getting a JSFiddle to work properly with React and other dependencies, I've decided to share the Github repo link to demonstrate the issue: https://github.com/ishraqiyun77/button-issues/ The main problem arises when a group of button ...

JQuery and CSS can be used to create a div overlay without impacting the positions of other divs on the

Is there a way to make a div overlay other divs (like a dropdown list) without affecting the positions of other divs? I have a #hidden div that appears when you hover over a #HoverMe div, but it moves the position of other divs when hovered. How can I ...

Tips for integrating Sass into a React application with bundle.js and bundle.css

I'm currently working on a React project that uses bundle.js/bundle.css, which are linked in the index.html like this: <script src="/bundle.js"></script> <link rel="stylesheet" href="/bundle.css" /> Ini ...