# Centre an img in a div!

**URL:** <https://forum.kirupa.com/t/centre-an-img-in-a-div/312290>\
**Category:** Uncategorized\
**Created:** [July 29, 2010, 7:55pm UTC](https://forum.kirupa.com/t/centre-an-img-in-a-div/312290 "2010-07-29T19:55:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [July 29, 2010, 7:55pm UTC](https://forum.kirupa.com/t/centre-an-img-in-a-div/312290/1 "2010-07-29T19:55:54Z")

</div>

Hey ya …

nb. ! without \<center\> tags please ! 😉

I have a div set to a certain width. It has rounded edges.  
Inside the div I want a picture to sit inside it centered.

As I am repeating the use of this div, The pictures I will put inside them will either be portrait or landscape … which is why the importance of them sitting centered.

Finally - i wish the image to have rounded edges too.

For some reason … i cant get it to work …  
Am using firefox, so no wors about code for other browsers.

this is the html setup

```auto
<div id="gallery">
<div id="frame">
<img src="my.jpg" class="crop" />
</div>
</div>

```

my CSS

```auto
#gallery{
margin:0 auto;
}
#frame{
background:red;
-moz-border-radius:7px; 
padding:10px;
}
.crop{
margin:0 auto;
-moz-border-radius:7px; 
}

```

alas - nothothings really happening… is my code really all that bad??

thanks
