我相信我今天花了很多时间试图将这些超链接与我的页面中心对齐,但没有成功。请帮助我注意工作,由于某种我无法理解的原因,这些是左对齐的:
/* Custom links*/
.cmenu a {
padding: 5px;
margin: 5px;
font-size: 14px;
margin-left: auto;
margin-right: auto;
display: inline-block;
text-align:center;
}
.cmenu a:link {
color: #0000Ea;
}
.cmenu a:hover {
color: #2e8acc;
}
在 HTML 中,我有:
<p class="cmenu">
<a href="../home">Home </a>
<a href="../about">About Us</a>
<a href="../forums">Forums</a>
<a href="../contact">Contact</a>
</p>
请注意,我没有尝试过:
margin-left: auto;
margin-right: auto;
但是没有用。感谢您的帮助。
当我使用检查元素时,我可以看到:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0px;
padding: 0px;
border: 0px none;
font-size: 100%;
vertical-align: baseline;
}
如果我将代码 text-align:center;
添加到上面的代码(最后一个)。我会让他们居中。但我不能。我该怎么办?
最佳答案
text-align:center;
将始终应用于应用样式的容器的子级
p.cmenu {
text-align: center;
}
是你要找的
关于html - 以 HTML (wordpress) 居中超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30413426/