繁体   English   中英

设置HTML表的列宽

[英]setting HTML table column width

我有一张简单的桌子。

<table border="1" width="100%">
        <tr>
                <th>Select</th>
                <th>Name</th>
                <th>Preview</th>
        </tr>

如何设置宽度,以便“选择”和“预览”为15px,“名称”为剩余的剩余宽度?

嘿,现在您可以像这样在CSS中定义

的CSS

   .some{
    width:15px;
    }

的HTML

<table border="1" width="100%">
        <tr>
                <th class="some">Select</th>
                <th>Name</th>
                <th  class="some">Preview</th>
        </tr>
</table>

现场演示http://tinkerbin.com/n4Q1NOXW

<table border="1" width="100%">
        <tr>
                <th width="15">Select</th>
                <th>Name</th>
                <th width="15">Preview</th>
        </tr>

您可以用作

<table border="1" width="100%">
   <tr>
        <th width="15px">Select</th>
        <th>Name</th>
        <th width="15px">Preview</th>
   </tr>
<table border="1px" width="100%">
   <tr>
        <th width="15px">Select</th>
        <th>Name</th>
        <th width="15px">Preview</th>
   </tr>
</table>​​​​​​​​​​​​​​​​​​​​​

如果要根据尺寸在任何尺寸的屏幕上预览,请使用'%'确定尺寸。 对于前

<table border="1px" width="100%">
   <tr>
        <th width="15%">Select</th>
        <th>Name</th>
        <th width="15%">Preview</th>
   </tr>
</table>​​​​​​​​​​​​​​​​​​​​​

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM