CSS,div内居中链接 [英] CSS, centering links inside div

查看:133
本文介绍了CSS,div内居中链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何像这样使我的链接居中?它们都位于 div 的中心,但是它们从相同的距离开始。

how can I center my links like this? They all are centered inside a div, but they begin from the same distance.

i am link 1
i am a longer link than link 1
i am a short link
we are all centered in div

如果我应用 text-align:center ,我会得到:

If I apply text-align: center, I get:

         i am link 1
i am a longer link than link 1
      i am a short link
   we are all centered in div

谢谢;)

我有一张桌子:

< td valign ='top'>< a href ='{url}'title ='{title}'target = '_blank'> {anchor}< / a>< / td>

链接必须以我的方式居中,每个都有自己的 td 。不确定是否可行。

The links need to be centered in my way, each in its own td. Not sure it's possible.

推荐答案

将链接换成另一个< div style = width:300px ; margin:0 auto;> 组合在一起。

Wrap the links in another <div style="width: 300px; margin: 0 auto;"> to group them together.

http://jsfiddle.net/NcEpe/1/

编辑动态宽度: http:// matthewjamestaylor。 com / blog / beautiful-css-centered-menus-no-hacks-full-cross-browser-support

这篇关于CSS,div内居中链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆