Jump to content

Centering Image Within A Percentage Defined Div, On Different Resolutions


coco243

Recommended Posts

Hi, I have an issue, I don't know how to center an image, or a div if it is necessary, within my page container, my page container has it's margins sets in percentages. I tried to center it with margin-left in percentage, it's working on my screen resolution, but when I check on other PC's, it's not centered, or when I resize the browser dimensions, the image it's wrong positioned. I tried to stick the image in a paragraph, and to center the paragraph with align="center", without a result. I would be grateful if you guys can help me.Thx.

Link to comment
Share on other sites

If your element has a defined width, set the margins to "auto" to center the element: .element { margin: auto; } The align attribute is deprecated.

Link to comment
Share on other sites

My key in resolving these problems, was first and the most important thing to asociate percentage dimensions to my images. In the image tags I specified the margin-left in percent, then I put this images in divs. Something like this: <div><img src="link to my image" style="margin-left: x%" width="x1%"; height="x2%" /></div> And this resolved my problem, now, my images are resizing with the screen resolution. Once again, the most import thing was to associate percentage dimensions at images.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...