简体   繁体   English

如何制作适合整个容器宽度的图像?

[英]How to make an image to fit the whole container width?

I'm trying to make my image to fit the whole container width. 我正在尝试使我的图像适合整个容器的宽度。

在此处输入图片说明

I've tried : 我试过了 :

  • give my image of width="100%" 给我的图片width="100%"
  • place my image within a div that have width of 100% 将我的图片放在宽度为100%的div中

None of those work. 这些都不起作用。

<div class="container" style="background-color:gray;">
    <div width="100%">
        <img width="100%" src="http://s6.postimg.org/7ic0egypt/report_nav.png">
    </div>
</div

JSFiddle JSFiddle

此处将其添加到您的CSS中,默认情况下,正文的边距为8px。

body{margin: 0px;}

Set the container padding to 0 . 将容器填充设置为0 I rewrote your fiddle using CSS 我用CSS重写了你的小提琴

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

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