将浮动链接置于 div 内居中
我有一个只有最小宽度的 div,它可以像 100% 宽度一样扩展自身。
在它里面我有一个浮动的链接,我正在疯狂地寻找一种方法将它放在 div 中居中。
我怎样才能做到这一点而不改变它的浮动?
哦,链接没有用
编辑定义:
我尝试过:
我给了容器一个文本对齐:居中, 删除了浮动,它居中但不与其他元素对齐,我尝试使用显示:内联和垂直对齐。
对于代码,我试图将“项目名称”集中在此处http://twitter。 github.com/bootstrap/examples/fluid.html
I've a div with only a min-width that extends itself like it is 100% width.
Inside it i have a link left floated and I'm going crazy finding a way to center it inside the div.
How can i do this without changin it's float?
Oh and the link hasn't a defined with
EDIT:
I've tried with:
I gave the container a text-align: center,
removed the float nad it gets centerd but not aligned with others element and i've tried using display: inline and vertical-align.
For the code i'm trying to center the "Project name" here http://twitter.github.com/bootstrap/examples/fluid.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
希望这有帮助:
编辑
http://jsfiddle.net/cU2ff/1/
我想出了这个,不知道有没有帮助。 float: left 属性没有做任何事情,但我把它留在那里
编辑
http://jsfiddle.net/cU2ff/ 2/
用 div 包裹它并给它 id projectName
Hope this helps:
EDIT
http://jsfiddle.net/cU2ff/1/
I came up with this, don't know if it's gonna help. The float: left property doesn't do anything but I left it there
EDIT
http://jsfiddle.net/cU2ff/2/
wrap it with a div and give it the id projectName
我通常也使用它来将链接置于 div 的中心。
I usually used this too center my links within the div.
如果无法看到您正在谈论的 html,则很难给您答案,但如果它只是链接内的文本,请尝试此操作。
Without being able to see the html you are talking about it is a little difficult to give you an answer, but try this if it is just text inside the link.
尝试使用这个
Try to use this