Differences in wrapping between IE11 and Chrome/Firefox: <DIV>

Take a look at this jsfiddle link using IE 11, Chrome, and FireFox.

Here is the HTML code I am working with:

<div style="width:120px;background-color:#EE1111;">
<div class="daytext"><b>27</b></div>
<div class="dayitem">
    <div class="dayzoneon">M</div>
    <div class="dayzoneon">P</div>
    <div class="dayzoneoff">S</div>
    <div class="dayzoneon">N</div>
</div>
<div class="daytext"><b>28</b></div>
<div class="dayitem">
    <div class="nozone"></div>
</div>
<div class="daytext"><b>29</b></div>
<div class="dayitem">
    <div class="dayzoneon">M</div>
    <div class="dayzoneon">P</div>
    <div class="dayzoneoff">S</div>
    <div class="dayzoneon">N</div>
</div>
</div>

In Internet Explorer, the layout wraps correctly causing the "29" box to go to the next line compared to other browsers like Chrome and FireFox where it stays on the same line even though it's out of the container.

Here is the CSS for the "29" element:

.daytext{
position: absolute;
font-size: large;
top:10;
left: 10;
width:48px;
background-color: #333333;
border-radius:5px !important;
margin: 2px;
opacity: 0.7;
height:32px;
text-align:center;
z-index: 2;
padding-top:12px;
color: #FFFFFF;
display: inline-block;
}

I have searched extensively online but couldn't find any answers...

Another strange observation is that when I add

overflow:hidden

to the first element, the "29" box should disappear, but it remains visible.

I suspect that IE11 might be setting some CSS properties implicitly or has default values different from Chrome and FireFox.

Answer №1

The default position of your parent container is set to static, which means it does not act as a containing block and the overflow: hidden property has no effect on your absolutely positioned elements. To make the element behave as a containing block, you can add position: relative or transform: translate3d(0,0,0);.

You have specified top:10; and left:10; without units, making them invalid values. As a result, their default values (top: auto and left: auto) are used. This causes the element to behave as if it is positioned static but without taking up any space in the flow since its actual position is absolute. This is why the element with the value 29 should not be moved to the next line (as it has no width for text flow).

In my opinion, Internet Explorer is incorrect in this case, and the results shown by Chrome and Firefox are accurate.

Unfortunately, I do not have access to Internet Explorer at the moment to verify this issue. It could potentially be related to font size or rendering. If you increase the width of the container, does the element with the value 29 stay on the second line until it completely fits on the first line?

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

<fieldset> triggering onChange event in React form

I am facing an issue with my React component where multiple onChange functions are not getting fired. After some debugging, I realized that the problem lies with the fieldset element within the form. Removing the fieldset allows all onChange functions to w ...

Is there a way to create an input field that accepts only numbers and behaves like a password field simultaneously?

I am attempting to develop an input field for entering a PIN. I would like the PIN to be masked on mobile devices, similar to how passwords are obscured in password input fields. I came across a suggestion on stackoverflow regarding this, but unfortunately ...

Detecting changes to DOM elements without using jQueryResponding to DOM element

Suppose I have the following HTML structure: <div id='content'></div> I want to receive an alert when there are height mutations on this element. I thought about using the MutationObserver class for this, but I encountered a specifi ...

Enhance website for Facebook tab using jQuery

I'm currently working on adapting a webpage for a Facebook tab. I've created a new page for the tab and successfully loaded the content from the targeted webpage. Everything is going smoothly, but I'm facing an issue with resizing this conte ...

What is the best way to ensure a NavBar stays at the top of the page when it is not collapsed?

I have integrated a NavBar using Bootstrap 5, which functions flawlessly. However, I am facing a specific issue that I haven't been able to resolve yet: When a user increases their screen size to <300%, it triggers the collapse button to appear. I ...

Is there a potential security flaw in jQuery when using $.get(code_url) to execute the returned code without relying on eval() or appending it to the DOM

As I was debugging my NodeJS application, I stumbled upon a surprising discovery: when using jQuery with a simple $.get(code_url) where code_url is a URL leading to server-side JavaScript code, the code gets executed. The expected behavior should be: $.g ...

FitText.js malfunctioning

I'm currently experimenting with using FitText.js to dynamically adjust the size of headlines to fit within the limits of the browser width. Interestingly, while this script successfully resizes the text in multiple sections of my website, it seems t ...

Utilize flex to position content at the bottom

My layout features a fixed header and footer, positioned at the top and bottom respectively. The content section in between fills the remaining space, with a scrollbar available if the content extends beyond the area. <div id="app"> <d ...

Selenium WebDriver encountered an error where the result of a function call is missing the expected value when trying to use the sendkeys method

Encountering an error while attempting to call the Sendkeys method in Selenium Webdriver: Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value' (Session info: chrome=65.0.3325.1 ...

What is causing the qtip tooltip to show up on buttons with different ids?

I have a requirement to display tooltips only for specific buttons and not for others. I am facing an issue where the tooltip intended for the TAB button is showing up when hovering over other buttons like FOO and BAR as well. Could this be due to them sha ...

Design a Logo-aligned Header using Bootstrap 4 for a professional and sleek look

I'm attempting to design a header using bootstrap 4 that resembles the image shown https://i.sstatic.net/MFVZU.png. However, I'm encountering several issues with this method. The main problem is that the logo is not properly centered in the middl ...

What is the best way to design a dynamic menu using HTML, CSS, and jQuery, where each li element gradually disappears?

Consider this menu structure: <ul class="main-menu"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul> My task is to dynamically hide th ...

Tips for causing text to wrap to a new line when reaching the end of a div element

I am struggling with keeping a text inside a div from overflowing when it reaches the border of the div. I have tried various CSS properties like "word-break" and overflow, but haven't been able to find a solution. <div class="col-lg ...

Modify the standard placement of choices in MUI

Currently, my UI is powered by MUI. I have various options displayed in the image below: https://i.sstatic.net/YKoyV.png Everything looks good so far. However, I wish to reposition the options container further down. (It is currently set at top: 64px ...

Adding to a webpage's URL with PHP prior to rendering the content

Currently, I am investigating how to add a random query string at the end of a URL when someone visits my page for the first time. Let's say an individual goes to my website at www.example.com. If everything proceeds as planned, they will land on my i ...

The Open Graph share debugger encounters a situation where it scrapes through an empty

Having trouble setting up Open Graph meta tags for a website? Even though the tags appear in the source when accessed through a browser, they don't show up in the OG debugger. The website I'm currently working on is located at spurafrika-org.ver ...

What is the best way to loop through ng-repeat with key-value pairs in order to display each

I need to loop through and show the data stored in "detailsController". <div ng-controller="detailsController"> <div ng-repeat="data in details" id="{{data.Id}}"> {{data.Name}} </div> </div> ...

navigation bar icons alignment problem

Help with positioning an icon next to the navbar text Example Code: <ul> <li><a href="#" id="other-color" class="ui-btn ui-shadow ui-btn-icon-left ui-custom-icon ui-arrow ui-nodisc-icon">Set Filter</a></li> <li> ...

What's the best way to add margin or padding to an SVG image within a v-app-bar

Seeking assistance with a seemingly simple question that can help enhance my understanding as I dive into using vue/vuetify for a new front end project. I am starting fresh and utilizing v-app-bar. Below is a snippet from my app.vue file: <template> ...

What is the best way to incorporate an image zoom-in effect into a flexible-sized block?

Having a fluid grid with 3 blocks in one row, each set to width:33.3%. The images within these blocks are set to width: 100% and height: auto. I am looking to implement a zoom-in effect on hover for these images without changing the height of the blocks. I ...