Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • I tried that too. It does align the image in middle but the top margin is still 0. Only the left margin gets adjusted. Commented Jun 19, 2014 at 10:12
  • Just add left: 50%; and margin-left: -116px; to the code also, i've updated the link for you. Commented Jun 19, 2014 at 10:14
  • this does work but the image inside the div tag can change. It could be of varying width and height Commented Jun 19, 2014 at 10:20
  • You could try making the margins in percentages as well, i've updated the link, and split the CSS and HTML which is good practise :) Commented Jun 19, 2014 at 10:24
  • #y { border: 3px solid #000000; background: #b4ef05; border-radius: 25px; width: 300px; height:200px; } change the width and height and it again displaces the image Commented Jun 19, 2014 at 10:31