I have created a table in PHP but the cells size is not fixed it expends when the input is long. Here is the Code.
echo "<div style=\"overflow-y: scroll; white-space: nowrap; height: 190px;\">\n";
echo "<table cellspacing=\"1\" cellpadding=\"1\" align=\"center\" width=\"100%\" id=\"clients\">\n";
echo "<tr bgcolor=\"2b2d5d\">\n";
echo "<th align=\"left\" style=\"color: FFFFFF; font-size: 12px; font-weight: normal; font-family: Arial; padding: 5\"> </th>\n";
echo "<th align=\"left\" style=\"color: FFFFFF; font-size: 12px; font-weight: normal; font-family: Arial; padding: 5\">Name</th>\n";
echo "<th align=\"left\" style=\"color: FFFFFF; font-size: 12px; font-weight: normal; font-family: Arial; padding: 5\">Address</th>\n";
echo "<th align=\"left\" style=\"color: FFFFFF; font-size: 12px; font-weight: normal; font-family: Arial; padding: 5\">Phone</th>\n";
echo "<th align=\"left\" style=\"color: FFFFFF; font-size: 12px; font-weight: normal; font-family: Arial; padding: 5\">Fax</th>\n";
I want to fixed the cells width please need help. Thanks
Just set % widths on the th tags .
<th style="width:20%;">
or you could just set a fixed width on certain columns if you preffered that design.
I would also advice you to move the inline css into a class to save you repeating the same code, and place it in a seperate css stylesheet. Incase your unfamiliar (or anyone who is reading) attach a stylesheet by placing the below in the head of the page:
<link rel="stylesheet" href="default.css">
example class:
.myTableColumn{color: FFFFFF; font-size: 12px; font-weight: normal; font-family: Arial; padding: 5;width:20%;}
Call it from the column:
<th class="myTableColumn">
<th width="50"></th>
should do. If it doesn't
<th style="max-width: 50px;"></th>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.