无法文字对齐:以CSS为中心 [英] Can't text-align:center on css
本文介绍了无法文字对齐:以CSS为中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎无法让我的主页按钮到达中心。我有我的htm和css链接像这样:
html:
< html>
< head>
< link rel =stylesheettype =text / csshref =background.css/>
< / head>
< body>
< h1>无欺区< / h1>
< h2>在线骚扰具有离线影响< / h2>
< a href =New.htmlclass =nav-link>主页< / a>
< / body>
< / html>
Css:
a.nav-link:link
{
颜色:黑色;
text-decoration:下划线;
font-family:broadway;
font-size:30px;
text-align:center;
}
a.nav-link:visited
{
color:black;
text-decoration:none;
}
a.nav-link:hover
{
颜色:黑色;
text-decoration:none;
}
a.nav-link:活动
{
颜色:黑色;
text-decoration:none;
解决方案
div
:
< div align =center>
< a href =New.htmlclass =nav-link>主页< / a>
< / div>
或者您可以为 div
:
HTML:
< div class =myDiv >
< a href =New.htmlclass =nav-link>主页< / a>
< / div>
CSS:
.myDiv {
text-align:center;
width:300px;
}
I can't seem to get my "Home" buttons to the center. The home text is at the left instead of the center.I have my htm and css linked like this: html:
<html>
<head>
<link rel="stylesheet" type="text/css" href="background.css"/>
</head>
<body>
<h1>Bully-Free Zone</h1>
<h2>"Online harassment has an off-line impact"</h2>
<a href="New.html" class="nav-link">Home</a>
</body>
</html>
Css:
a.nav-link:link
{
color: black;
text-decoration: underline;
font-family:broadway;
font-size:30px;
text-align:center;
}
a.nav-link:visited
{
color: black;
text-decoration: none;
}
a.nav-link:hover
{
color: black;
text-decoration: none;
}
a.nav-link:active
{
color: black;
text-decoration: none;
}
解决方案
You could wrap it in a div
:
<div align="center">
<a href="New.html" class="nav-link">Home</a>
</div>
Or you can create a class for the div
:
HTML:
<div class="myDiv">
<a href="New.html" class="nav-link">Home</a>
</div>
CSS:
.myDiv {
text-align: center;
width: 300px;
}
这篇关于无法文字对齐:以CSS为中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文