`` I am experiencing a problem with CSS display block in Internet Explorer

Looking to implement a basic tab menu using a combination of tables and div elements. The goal is to have the tabs switch styles when clicked, giving the appearance of being toggled, while also swapping out the corresponding content in separate div blocks by manipulating the CSS properties (display:block and display:none). This functionality behaves as expected in Firefox; however, in IE 11, there seems to be an issue with the sizing of the tabs when they are switched.

For reference, here is the page: Tab Example

function tabClick(tab, bodyId) {

  // arrays for tabs and bodies
  var tabCol = [document.getElementById('tab1'), document.getElementById('tab2'), document.getElementById('tab3')];
  var bodyCol = [document.getElementById('body1'), document.getElementById('body2'), document.getElementById('body3')];

  for (var i = 0; i < tabCol.length; i++) {

    // identify the clicked tab and update its status
    if (tab === tabCol[i]) {
      tabCol[i].className = 'tabSel';
    } else {
      tabCol[i].className = 'tabUnsel';
    }

    // show the selected body and hide the rest
    if (bodyCol[i].id == bodyId) {
      bodyCol[i].style.display = 'block';
    } else {
      bodyCol[i].style.display = 'none';
    }

  }

}
.tabUnsel:hover {
  text-decoration: underline;
}
.tabUnsel {
  text-align: center;
  vertical-align: central;
  padding: 5px 10px 5px 10px;
  white-space: nowrap;
  cursor: pointer;
  background-color: #f0f0f0;
  border: #898c95 solid 1px;
  border-radius: 5px 5px 0px 0px;
}
.tabSel {
  text-align: center;
  vertical-align: central;
  padding: 5px 10px 5px 10px;
  white-space: nowrap;
  background-color: #ffffff;
  border: #898c95 solid 1px;
  border-bottom: 0;
  border-radius: 5px 5px 0px 0px;
}
<table style="width: 500px; font-family: verdana; font-size: 11px;" cellspacing="0">
  <tr>
    <td style="border-bottom: #898c95 solid 1px;">&nbsp;&nbsp;</td>
    <td id="tab1" class="tabSel" onclick="tabClick(this,'body1');">Tab 1</td>
    <td style="border-bottom: #898c95 solid 1px;">&nbsp;</td>
    <td id="tab2" class="tabUnsel" onclick="tabClick(this,'body2');">Tab 2</td>
    <td style="border-bottom: #898c95 solid 1px;">&nbsp;</td>
    <td id="tab3" class="tabUnsel" onclick="tabClick(this,'body3');">Tab 3</td>
    <td style="width: 100%; border-bottom: #898c95 solid 1px;">&nbsp;</td>
  </tr>
  <tr>
    <td style="border: #898c95 solid 1px; border-top: 0; padding: 10px;" colspan="7">
      <div id="body1" style="width:100%; min-height: 300px;">
        Tab 1 content
      </div>
      <div id="body2" style="width:100%; min-height: 300px; display: none;">
        Tab 2 content
        <br/>
        <img src="http://tropicalfarm.byethost13.com/tabs/img1.jpg" />
        <img src="http://tropicalfarm.byethost13.com/tabs/img2.jpg" />
      </div>
      <div id="body3" style="width:100%; min-height: 300px; display: none;">
        Tab 3 content
      </div>
    </td>
  </tr>
</table>

Answer №1

Consider incorporating this snippet into your CSS for an empty tap styling:

.empty-tap {
  min-height: 500px; 
   height:auto !important; 
   height: 500px;
}

You can find the original source 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

Using a conditional statement in a JavaScript loop

Here is the data I have: companyList: [ { company_name: 'company1', item: 'item1' }, { company_name: 'company1', item: 'item2' }, { company_n ...

extract information from a document and store it in an array

As I delve into the realm of programming, I find myself grappling with the best approach to extract data from a file and store it in an array. My ultimate aim is to establish a dictionary for a game that can verify words provided by players. Despite my no ...

Sharing images on a web app using Express and MongoDB

My objective is to develop a portfolio-style web application that allows administrators to upload images for other users to view. I am considering using Express and MongoDB for this project. I am uncertain about the best approach to accomplish this. Some ...

What is the best way to horizontally align an image beneath a navigation menu that is built using <ul> tags?

Seeking a way to center an arrow graphic under the selected item in a simple CSS drop-down menu? Considering using the :after selector, but currently being used for drawing dividing lines between menu options: HTML: <ul> <li>Option Zero&l ...

This code encountered an Uncaught SyntaxError due to an invalid or unexpected token

Hey there, I've been struggling with an Uncaught SyntaxError: Invalid or unexpected token issue whenever I try to click on the edit or delete button. Can someone please help me figure out what's wrong with this code? I've spent hours looking ...

Tips for efficiently webscraping multiple pages with Beautiful Soup

I have been running my web-scraping script for quite some time, but it seems to be stuck on scraping only one URL. I intend to scrape five different URLs, and I am wondering if the issue lies with my loop getting stuck in an infinite loop. Furthermore, I ...

Looking for assistance with implementing a jQuery function for an onClick event on

I've been diving into learning jquery and managed to create a basic checkbox feature with a function that allows you to set all options as read-only by checking the "None of the above" button. <html> <body> <form id="diagnos ...

Unexpected error when using Slack SDK's `client.conversations.open()` function: "User Not Found"

I am currently utilizing the Slack node SDK in an attempt to send private messages through a bot using user IDs: const client = new WebClient(process.env.SLACK_TOKEN); const sendMessage = async (userId) => { try { await client.conversations.open( ...

What are the best scenarios for implementing jQuery-ui plugin as opposed to Backbone View?

I am feeling uncertain about the concept of "componentization" in web UI development. When I need a component, should I develop my own jQuery-UI plugin or opt for creating a MarionetteComponent if I am using Backbone.Marionette? Both options provide reusa ...

Expanding a wrapper to fit the entire width of its content

I am facing an issue where the background color of a wrapper does not adjust to the overflowing content within it. How can I make sure that the background stretches behind all the content, regardless of its size? <div style="background-color: black;m ...

I am attempting to assign a default value to a TextField by retrieving data from a GetMapping call in React, however, the value is not being successfully set

I am facing an issue with setting a default value for a TextField in my code. Even though I am trying to populate it with data from a GetMapping call, the value is not being set as expected. Here is the JSON response I receive from the API call: { "id": 1 ...

unable to perform a specific binary operation

Is there an efficient method to achieve the following using binary operations? First byte : 1001 1110 Second byte : 0001 0011 Desired outcome : 1000 1100 I am looking to reset all bits in the first byte that correspond to bit values of 1 in the secon ...

Managing time-intensive web service operations using JavaScript callbacks

One of the operations in my Web application involves a function that returns a value, which then needs to be passed to a web service method running separately from the application. This web service operation takes some time to complete and therefore must r ...

Is there a way to retrieve JSON data from a different domain and incorporate it into my own website?

I am attempting to utilize JSON data from "" and display the data on my website. My goal is to extract the JSON field name "Stats" and retrieve the sub-field name '\"v\"'. You can refer to the documentation provided by purpleair here: h ...

Positioning of vertical linear gradients in CSS

Check out this live demonstration: http://jsfiddle.net/nnrgu/1/ I then adjusted the background position to 0px -70px and observed the changes here: http://jsfiddle.net/nnrgu/2/ The linear gradient seems to disappear! Am I doing something wrong, or is ...

Tips for utilizing node.io for HTML parsing with node.js?

Struggling to utilize node.io with node.js for parsing an HTML page stored as a string in a variable. Encountering difficulties passing the HTML string as an argument to my node.io job. Snippet from my node file nodeiotest.js: var nodeIOJob = requi ...

Calculating the depth of a webpage with Python

I need help determining the depth of a website through Python. The depth of a subwebsite is defined as the number of clicks needed to reach it from the main website (e.g. www.ualberta.ca). For example, if a subwebsite like www.ualberta.ca/beartracks requir ...

An array in Javascript that contains sub-arrays within its keys

I am encountering an issue with my array structure. The main array contains sub-arrays and uses custom keys as identifiers. However, I am unable to access the array using these keys. For example, when I try to get the length of the array, it returns 0 even ...

Each time I attempt to alter the color based on the count, an error is thrown: "TypeError: Cannot read property 'style' of null"

If the count is equal to zero, I want to change the color to black in the code below: if(Count === 0){ document.getElementById('value').style.color = 'black'; } return( <div className='container_new'> < ...

Creating a Rest API URL in Vue.js by extracting form values

I just finished coding this Vue component: <template> <div> <h2>Search User By ID</h2> <input v-model="userId" type="number" placeholder="modify me" /> <br /> <p v-if="userId.length != 0"> ...