heapoverflow
heapoverflow

Reputation: 121

how to set height by percentage in tbody vertical scroll in javascript?

I use vertical scrollbar in tbody. Below is my css style.

 table > tbody
{
 display: block;
 max-height: 400px;
 overflow-y:scroll;
}

table > thead, tbody tr {
  display: table;
  width: 100%;
  table-layout:fixed;
}

But the table container has dynamic size, so i want to set it's height to 100%. ( max-height: 100%;) But it does not work with percentage. It must work with pixel. How should i gonna set tbody's height (all maxheight) 100%?

This table has wrapped by parent div container and the height 100% means that i want to fill 100% the div container by this table , and i want to put vertical scroll in tbody.

P.S Maybe the javascript will the way.. but is there have any way to use only css?

Upvotes: 0

Views: 915

Answers (1)

Kuldip Solanki
Kuldip Solanki

Reputation: 44

This is not possible with HTML or CSS because <div> will provide the height based on its content whether you provide any particular height or not.

Upvotes: 1

Related Questions