Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用这样的标记:
<div id='titlebar'> <a><img src='foo.png'></a> <span>Title</span> </div>
定位锚定图像时是否可以将“标题”居中?
... [foo] .....................Title ...............................
谢谢
#titlebar { text-align: center; } #titlebar a { position: relative; left: -40em; }
试试看。
由于图像在锚点中的原始位置,标题文本将稍微偏离中心,因此您也可以对其应用相对位置。