2012-05-09 95 views

回答

4

.g { 
 
    width:40px; 
 
    height:40px; 
 
} 
 

 
img { 
 
    height:inherit; 
 
    width:inherit; 
 
} 
 

 
td, tr, tbody { 
 
    height:inherit; 
 
    width:inherit; 
 
}
<table class="g" border="0" cellspacing="0" cellpadding="0"> 
 
    <tr> 
 
    <td><img src="http://www.google.com/logos/2012/stgeorge12-hp.png"></td> 
 
    </tr> 
 
</table> 
 

 
<div class="g"><img src="http://www.google.com/logos/2012/stgeorge12-hp.png"></div>

+0

请问为什么你需要它继承? –

+1

不太可能..你可以设置'​​'的宽度,使它真的继承'

'width - http://jsfiddle.net/CgEhg/2/,但正如你所看到的,图像比例缩小它不是方形 –

+0

看看这个:http://jsfiddle.net/CgEhg/3/ –

1

除了上述例子中,以使表延绵自动根据其内容设定为100%。

table 
    { 
     width:40px; 
     height:40px; 
    } 


    td,tr,tbody 
    { 
     height:100%; 
     width:100%; 
    } 
相关问题