Madhavan Kumar Madhavan Kumar - 2 years ago 202
HTML Question

Dropdown inside table cell toggles table row height on every click

I have a drop down inside a table cell. On a click, the dropdown expands to show the menu items. But, the table row height also changes whenever the menu expands/collapses.

How can i keep the table row height constant and the dropdown gets displayed over the table. I tried setting higher z-index for dropdown container but it didn't work. As,

background-color: #ea7600;

Plunker code is here.

enter image description here

Table height must not fall below the second dark horizontal line.

Answer Source

You need to use absolute positioning, but that requires some minor html changes as well:

add span to th and td:

<th><span>lonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnng header</span></th>

<td><span>lonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnng content</span></td>

change css:

   position: relative;
   border: solid black 2px;
   padding: 5px;
   text-align: center;

  td span,th span{
      text-overflow: ellipsis;
   overflow : hidden;
   white-space: nowrap;
   display: block;

     position: absolute;
     width: 100%;

Updates plunker:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download