Reputation: 1180
I have a react js app where 1 page has a table with tbody, tr, and td. The table has only two columns aka td tags. I would like the first column to automatically adjust the screen resolution and content. I tried width:"fit-content", width:"auto", but the width is about 50% of the table width. It only works when I change it to width:"20%" but the width is not correct for different resolution. I read other posts here but have not found anything that works so far. Here is my code so far
<table className="myTable">
<tbody>
<tr>
<td width="fit-content">
<control1/>
<td width="auto" >
<control2/>
</td>
</td>
</tbody>
</table>
//css
.myTable
table-layout: fixed
width: 100%
I tried table-layout: auto but my table runs off the page so I think I need to keep it fixed. but the width on the first td is does not correctly to its content.
Upvotes: 0
Views: 1135
Reputation: 380
You may try <td style="width:20vw">
, to fix the colum width to 20% of the viewport's resolution.
Upvotes: 1