开发者

is it possible to center a span in a div while positioning an anchor in the same div?

With markup like this:

<div id='titlebar'>
  <a><img src='foo.png'></a>
  <span>Title</span>
<开发者_JAVA百科;/div>

is it possible to center "Title" while positioning the anchored image?

   ... [foo] .....................Title ...............................

Thanks


#titlebar {
  text-align: center;
}

#titlebar a {
  position: relative;
  left: -40em;
}

Try that.

The title text will be slightly off center due to the original positioning of the image in the anchor, so you can apply a relative position to that as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜