2016-08-02 42 views
0

内的图像大小。当我在缩小CSS的图形的大小,它里面的图像仍保持原始大小改变CSS的图形的大小并不影响它

HTML:

<!DOCTYPE html> 
<html> 
    <link href="style.css" rel="stylesheet"> 

<head> 

</head> 

<body> 
    <div id="wrapper" style="text-align: center"> 
     <p>   
      Piece of text inside a 500px width div centered on the page 
     </p> 

     <figure> 
      <img src="https://www.newton.ac.uk/files/covers/968361.jpg"> 
     </figure> 
    </div><!--wrapper--> 
</body> 
</html> 

CSS:

#wrapper { 
    width: 900px; 
    margin: 0 auto; 
} 

figure { 
    float: left; 
    display: inline-block; 
    width: 12px; 
    height: auto; 
} 

p { 
    clear: both; 
} 

当我修改的CSS width属性,它不会影响该网站上显示的图像的大小。

回答

0

试试这个

figure > img { 
    width: 12px; 
} 
+0

谢谢,这完美! – Jake

1

尝试在图像上应用最大宽度。

img { 
    max-width:100%; 
} 
0

分配widthheightimg。现在,只要你改变你figureheightwidth这要根据它而改变。

figure > img{ 
    width:100%; 
    min-height:100%; 
}