简体   繁体   English

ie7的浮动表行不起作用

[英]ie7 float table row left isn't working

I am working on a table that I cannot edit, I cannot add any HTML, I cannot add any JS. 我正在处理无法编辑的表,不能添加任何HTML,不能添加任何JS。 Everything has been pre-generated and all I can do is add CSS to it. 一切都已经预先生成,我所能做的就是向其中添加CSS。

So table has 2 rows, one is sidebar, second is center content. 所以表有两行,一是侧边栏,第二是中心内容。 I wanted to make the sidebar 210px wide and float it left, the same I did to center content. 我想将侧边栏的宽度设为210px并向左浮动,就像我将内容居中放置一样。 All works fine in all browsers but IE7. 除了IE7,其他所有浏览器都可以正常运行。 When I inspect it with IE7 developer tools, I can see that the row and the TD under it are always 100% wide and there is no way to assign a width value to it. 当我使用IE7开发人员工具检查它时,我可以看到它下面的行和TD总是100%宽,并且无法为它分配宽度值。

Is there a work around to this problem? 是否有解决此问题的方法?

Sample code. 样例代码。

<table>
<tr id="sidebar"><td>Some data</td></tr>
<tr id="main"><td>Some data 2</td></tr>
</table>

CSS:
#sidebar
{
display:block;
width:210px;
float:left;
}
#main
{
display:block;
width:730px;
float:left;
}

Please advise 请指教

i don't have ie7, but setting the rows display:table-cell; 我没有ie7,但设置行display:table-cell; and putting a width on the table works in chrome in this example. 在此示例中,将宽度放置在表格上适用于chrome。 http://jsfiddle.net/jalbertbowdenii/7Wuku/ http://jsfiddle.net/jalbertbowdenii/7Wuku/

I think a good way of doing it is without the second row... Of course if you can make your markup like this: 我认为这样做的一种好方法是不用第二行...当然,如果您可以像这样进行标记:

<table>
    <tr>
        <td id="sidebar">Sidebar content</td>
        <td class="main_cont">Main content</td>
    </tr>
</table>

In this markup you won't need to float the td s, simply state the width. 在此标记中,您无需浮动td ,只需声明宽度即可。 A live example is here: http://jsfiddle.net/skip405/QySz2/1/ 一个实时示例在这里: http : //jsfiddle.net/skip405/QySz2/1/

But if you can't change the markup - I'm afraid you'll never teach IE7 to float table rows)) 但是,如果您不能更改标记-恐怕您永远不会教IE7来浮动表格行))

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

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