无法将图像放在div的中间

时间:2022-07-01 21:05:41

I am trying to follow this tutorial for getting an image to be aligned at the center of a div:

我正在尝试按照本教程使图像在div的中心对齐:

http://www.w3.org/Style/Examples/007/center#vertical

http://www.w3.org/Style/Examples/007/center#vertical

and here is the page I am working on:

这是我正在处理的页面:

http://www.comehike.com/hikes/hiking_group.php?hiking_group_id=2

http://www.comehike.com/hikes/hiking_group.php?hiking_group_id=2

You see how on the right side, the button for "join group" is not centered vertically?

你看到右边的“连接组”按钮是不是垂直居中?

I am doing this css:

我正在做这个css:

width: 280px; 
float: right; 
border: 1px solid; 
margin-bottom: 5px; 
vertical-align: middle;  
display: block; 
display: table-cell;

And I thought the part about vertical-align: middle; would do the trick, but it isn't. Any way I can center the button there vertically?

我认为关于垂直对齐的部分:中间;会做的伎俩,但事实并非如此。我可以用任何方式将按钮垂直放在那里吗?

Thanks!

谢谢!

2 个解决方案

#1


1  

http://www.brunildo.org/test/img_center.html is the best I could find.

http://www.brunildo.org/test/img_center.html是我能找到的最好的。

#2


0  

Would this work?

这会有用吗?

a.login_link img {
    display: block; 
    margin:auto;
}
a.create_profile_link img {
    display: block; 
    margin:auto;
}

#1


1  

http://www.brunildo.org/test/img_center.html is the best I could find.

http://www.brunildo.org/test/img_center.html是我能找到的最好的。

#2


0  

Would this work?

这会有用吗?

a.login_link img {
    display: block; 
    margin:auto;
}
a.create_profile_link img {
    display: block; 
    margin:auto;
}