Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

trying to place image in center (in responsive fashion)

trying to place image in center (in responsive fashion)

Problem

I have tried the following approaches but they do not seem to work for me (I'm sure I am doing something wrong - I need help in figuring out what it is). The image is in the HTML header section (not body).

  1. I have bootstrap in the HEAD section (before the image and it gets picked up from the browser cache so hopefully it gets used for the image in the header)

  2. I have tried adding the following to the CSS for the image (and when it did not work, I tried adding a div around the image and assigned the class to the div):

    display:inline; text-align:center; margin:auto;

  3. I also tried the following in the CSS when option 2 did not work:

    display:inline; margin:auto; horizontal-align:center;

I tried display:block in place of display:inline as well. Any thoughts on fixing this (specially without relying on bootstrap would be quite welcome). Thanks in advance!

Problem courtesy of: ali haider

Solution

First, you can't set a margin on an element that is set to display:inline.

Here is a great guide that you should read:

http://www.tipue.com/blog/center-a-div/

Solution courtesy of: Eduardo Bautista

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

trying to place image in center (in responsive fashion)

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×