html - HTML格式的问题
问题描述
字体大小会发生变化,headertext
但不会居中。刚刚开始学习 HTML,所以这可能是一个新手错误。任何建议表示赞赏,谢谢!
.main {
margin-left: 220px; /* Same as the width of the sidenav */
margin-top: 20px; /* Same as the width of the sidenav */
font-size: 20px; /* Increased text to enable scrolling */
}
.main headertext {
font-size: 45px;
text-align: center;
}
<div class="main">
<headertext>ExampleTitle</headertext>
<p>Welcome to my website.</p>
</div>
解决方案
headertext
不是有效的 HTML 元素。将其更改为div
a 类,headertext
我认为可以解决您的问题,如下所示:
.main {
margin-left: 220px;
margin-top: 20px;
font-size: 20px;
}
.main .headertext {
font-size: 45px;
text-align: center;
}
<div class="main">
<div class="headertext"> ExampleTitle </div>
<p> Welcome to my website.</p>
</div>
推荐阅读
- regex - 在python中使用正则表达式用两个不同的字符替换两个字符
- vba - 宏在空白时不显示详细信息
- python-3.x - Python Gui 自动化
- c# - 无法将路由映射到操作,ASP.NET Core Web API
- json - 获取本地目录路径和内部的所有文件名(Swift)
- javascript - 浅渲染找不到组件
- python - ImportError - 在 CircleCI 上测试失败但在本地通过
- serial-port - 配置 TeraTerm 以等待“Enter”键击?或者解决 PuTTY COM 连接错误
- ssis - SQL任务选择参数中的变量在哪里?
- java - 尝试在 Google Play 中重命名时应用被暂停