1

earlier it was good but now when I put width and height 100% it doesn't really displays 100% instead a 10 px margin come on all four sides here's what I tried

 <html>
    <head>


    <style>

    .cont img {
        display: inline-block;
        width :100%;
        height : 100%;
        margin:0;
    padding:0;



    }    


    </style>




    </head>
    <body>
       <div class="cont">
    <img src="IMG_5913-2.jpg" class="imgmy" name="imgmy">

    </div>
    </body>
</html>

what can I do to make it 100% with in any browser?

Nigam Chavda
  • 57
  • 1
  • 7

4 Answers4

1

have a look at this code, set margin:0px on body tag

<html>
<body style="margin:0px; ">
<div style="background-color:red; width:100%;">
hello
</div>
</body>
</html>
shreyansh
  • 1,637
  • 4
  • 26
  • 46
0

Assuming HTML

<body>
<div class="cont">
<img src="IMG_5913-2.jpg" class="imgmy" name="imgmy">

</div>
</body>

CSS

  .cont img {
    max-width: 100%;
    max-height: 100%;
}
Ritesh Karwa
  • 2,196
  • 1
  • 13
  • 17
0

Question is not 100% clear, but are you looking for a solution like this?

.container {
    height:100%;
    width: 100%;
    border: 1px red solid;
    margin:0;
    padding:0;
    line-height: 0;
}
.container .imgmy{
   height:100%;
    width: 100%;
    margin:0;
    padding:0;
}
gamini2006
  • 299
  • 3
  • 17
  • i updated with your html [here](https://jsfiddle.net/myL3v5f5/6/). set line-height: 0 on perant element ie div element – gamini2006 Jun 04 '15 at 07:49
0

Are you sure it was good earlier?

The margins around the image have nothing to do with the image itself.

Browsers define default styles in a so called User Agent Stylesheet. In this case, the white border is the 8px margin (that is in Chrome) on the body.

Luckily you can easily override these user agent stylesheets, and you should in this case.

You can add margin:0 to the body, as mentioned above by Shreya. But to avoid similar 'errors' it is a good idea to include a reset.css or normalize.css. These files "make browsers render all elements consistently and in line with modern standards" (http://cdnjs.com/libraries/normalize). You don't have to write one yourself, others have done this for you, like Nicolas Gallagher: http://necolas.github.io/normalize.css/

Read more about User Agent Stylesheets here: What is user agent stylesheet

Community
  • 1
  • 1