text-align:center 不起作用,但其他所有属性都起作用
text-align:center doesn't work but every other properties do
我是 HTML 的新手,想创建一个简单的页面,但是当我想对齐我的文本时,它不遵循文本对齐指令,而是遵循其他所有指令,这里是 HTML 文件:
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" />
<title>Freelancers!</title>
</head>
<body>
<h1>
<t class="center">Bienvenido a Freelancers!</t>
<p>Para saber qué es un "freelancer", presiona
<a href="https://en.wikipedia.org/wiki/Freelancer">
<strong>aqui</strong>
</a>.
</p>
<st class="center">¿Quiénes somos?</st>
<p>
Somos un grupo de estudiantes de la
<a href="https://ucsp.edu.pe/"><strong>UCSP</strong></a>
que aspiran a tener una página web donde las personas puedan acudir cuando necesiten de la ayuda de profesionales independientes, o "freelancers".
</p>
</h1>
</body>
</html>
CSS 在这里:
body{
background-color: lavenderblush;
}
.center{
text-align:center;
}
t{
text-align:center;
font-weight:bold;
font-family:Cambria,Courier, monospace;
font-size:56px;
}
h1 st{
color:rgb(148, 87, 87);
font-weight:bold;
font-family:Cambria,Courier, monospace;
font-size:28px;
}
p{
text-align:left;
font-weight:normal;
font-family:"Times New Roman", Arial;
font-size:14px;
}
如果代码对您来说很混乱,我很抱歉,但我只是想学习这门语言,如果您有任何建议,我将不胜感激。
这里有几个问题:
您的 </h1>
*远低于应有的水平。它应该直接在标题之后。我已经修复了这个 fiddle.
- 您不能只定义 html 标签。我将您的副标题设为 h3,并删除了
<t>
类型,它似乎运行良好。
body{
background-color: lavenderblush;
}
.center{
text-align:center;
}
t{
text-align:center;
font-weight:bold;
font-family:Cambria,Courier, monospace;
font-size:56px;
}
h1 {
color:rgb(148, 87, 87);
font-weight:bold;
font-family:Cambria,Courier, monospace;
font-size:28px;
}
p{
text-align:left;
font-weight:normal;
font-family:"Times New Roman", Arial;
font-size:14px;
}
<h1 class="center">Bienvenido a Freelancers!</h1>
<p>Para saber qué es un "freelancer", presiona
<a href="https://en.wikipedia.org/wiki/Freelancer">
<strong>aqui</strong>
</a>.
</p>
<h3 class="center">¿Quiénes somos?</h3>
<p>
Somos un grupo de estudiantes de la
<a href="https://ucsp.edu.pe/"><strong>UCSP</strong></a>
que aspiran a tener una página web donde las personas puedan acudir cuando necesiten de la ayuda de profesionales independientes, o "freelancers".
</p>
我是 HTML 的新手,想创建一个简单的页面,但是当我想对齐我的文本时,它不遵循文本对齐指令,而是遵循其他所有指令,这里是 HTML 文件:
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" />
<title>Freelancers!</title>
</head>
<body>
<h1>
<t class="center">Bienvenido a Freelancers!</t>
<p>Para saber qué es un "freelancer", presiona
<a href="https://en.wikipedia.org/wiki/Freelancer">
<strong>aqui</strong>
</a>.
</p>
<st class="center">¿Quiénes somos?</st>
<p>
Somos un grupo de estudiantes de la
<a href="https://ucsp.edu.pe/"><strong>UCSP</strong></a>
que aspiran a tener una página web donde las personas puedan acudir cuando necesiten de la ayuda de profesionales independientes, o "freelancers".
</p>
</h1>
</body>
</html>
CSS 在这里:
body{
background-color: lavenderblush;
}
.center{
text-align:center;
}
t{
text-align:center;
font-weight:bold;
font-family:Cambria,Courier, monospace;
font-size:56px;
}
h1 st{
color:rgb(148, 87, 87);
font-weight:bold;
font-family:Cambria,Courier, monospace;
font-size:28px;
}
p{
text-align:left;
font-weight:normal;
font-family:"Times New Roman", Arial;
font-size:14px;
}
如果代码对您来说很混乱,我很抱歉,但我只是想学习这门语言,如果您有任何建议,我将不胜感激。
这里有几个问题:
您的
</h1>
*远低于应有的水平。它应该直接在标题之后。我已经修复了这个 fiddle.- 您不能只定义 html 标签。我将您的副标题设为 h3,并删除了
<t>
类型,它似乎运行良好。
- 您不能只定义 html 标签。我将您的副标题设为 h3,并删除了
body{
background-color: lavenderblush;
}
.center{
text-align:center;
}
t{
text-align:center;
font-weight:bold;
font-family:Cambria,Courier, monospace;
font-size:56px;
}
h1 {
color:rgb(148, 87, 87);
font-weight:bold;
font-family:Cambria,Courier, monospace;
font-size:28px;
}
p{
text-align:left;
font-weight:normal;
font-family:"Times New Roman", Arial;
font-size:14px;
}
<h1 class="center">Bienvenido a Freelancers!</h1>
<p>Para saber qué es un "freelancer", presiona
<a href="https://en.wikipedia.org/wiki/Freelancer">
<strong>aqui</strong>
</a>.
</p>
<h3 class="center">¿Quiénes somos?</h3>
<p>
Somos un grupo de estudiantes de la
<a href="https://ucsp.edu.pe/"><strong>UCSP</strong></a>
que aspiran a tener una página web donde las personas puedan acudir cuando necesiten de la ayuda de profesionales independientes, o "freelancers".
</p>