471,582 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

Center image doesn't work

2
I'm trying to get my photo's centered. In my current layout it works, but I'm changing the design of my website.

In the source it calls voor myinlinepicture

In source:

<div class="post-body">
<div>
<p> ......</p>
<div class="myinlinepicture" style="width:400px">
</div>

I searched some forums and set my css like this:

In CSS:

.myinlinepicture {
text-align:center;
margin:0px auto 0px auto;
}

It should center right now, but it doesn't. What else can be the problem?
Sep 30 '07 #1
5 2720
drhowarddrfine
7,435 Expert 4TB
You are applying the margins to the <div> and not the image. <div> is block level while <img> is inline. Apply
img{
margin:0 auto;
display:block;
}
Sep 30 '07 #2
try
<center><table width=98%><tr><td><img src="yourpic.gif" alt="alternate name"></td></tr></table></center>
and just change the % to suit
Oct 1 '07 #3
drhowarddrfine
7,435 Expert 4TB
<center> has been deprecated for years and you should never use tables for layout.
Oct 1 '07 #4
Maaike
2
You are applying the margins to the <div> and not the image. <div> is block level while <img> is inline. Apply
img{
margin:0 auto;
display:block;
}
The problem is I'm using Wordpress with a plugin for the pictures. The suggestion you did, had an effect on the pictures in my gallery, but not on the pictures in my post. So there must be something in my post css that is overruling my picture css.
Is there something else I can try?
Oct 1 '07 #5
drhowarddrfine
7,435 Expert 4TB
.myinlinepicture img{
margin:0 auto;
display:block;
}

That makes it specific to that div. If that doesn't work, a link is necessary to see what it's doing.
Oct 1 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Eric Lindsay | last post: by
1 post views Thread by Troels Arvin | last post: by
roula
19 posts views Thread by roula | last post: by
14 posts views Thread by Summercool | last post: by
14 posts views Thread by gaijinco | last post: by
reply views Thread by Vinnie | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.