2013-09-01 149 views
0

我有一個div,其CSS將所有圖像設置爲一定的寬度。我想添加另一個小孩div,但它的圖像不受限制 - 無論它們的大小如何。如何禁用子元素的父元素的設置寬度?

我不確定如何'重置'這些子元素的寬度屬性,所以它不會繼承父母?

有人會知道這是怎麼完成的嗎?

<div id='parent'> 
    <img src='image.jpg'> 

    <div id='child'> 
    <img src='image.jpg'> 
    </div> 

</div> 

CSS

#parent img { 
    width: 200px; 
    } 

    #child img { 
    width: do not inherit #parent img css??? 
    } 

回答

1

auto做什麼,我什麼:

#child img { 
    width: auto; 
    } 
0

只需添加你自己的寬度。

#parent img { 
    width: 200px; 
    } 

    #child img { 
    width: 100px; 
    } 
相關問題