html - 如何将两种不同字体大小的文本放在网页的中心?
问题描述
这是我的 HTML 代码:
span {
font-family: 'Lovehearts XYZ';
text-align: center;
}
@font-face {
font-family: 'Lovehearts XYZ';
src: url('LoveheartsXYZ.woff2') format('woff2'),
url('LoveheartsXYZ.woff') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
<span style = "font-size: 70px;">Hi, I am *Name*</span></br>
<span style = "font-size: 40px;">*Occupation*</br>
*Hobbies*</br>
*Facts about me*
</span>
如您所见,我使用了两个“跨度”,但它们的字体大小不同。我希望将这段文本放在网页的中心。我该如何修改代码来做到这一点?
解决方案
span {
font-family: 'Lovehearts XYZ';
display:block;
text-align: center;
}
<span style = "font-size: 70px;">Hi, I am *Name*</span></br>
<span style = "font-size: 40px;">*Occupation*</br>
*Hobbies*</br>
*Facts about me*</span>
span {
font-family: 'Lovehearts XYZ';
text-align: center;
}
推荐阅读
- java - 如何将打印功能合并到计算周长和识别形状的程序中?
- lotus-notes - @command([ToolsRefreshAllDocs]) 在 Lotus Notes 中不起作用
- mongodb - FindById 并根据找到的内容更新或推送
- angular - Angular Forms,需要一些简单的例子
- node.js - 使用 Node.js RESTful 路由,如何在编辑后更改某物的颜色?
- javascript - 如何更改此所有帖子列表代码以列出特定标签?
- python - 我想从使用scrapy刮取的数据中打印一个合适的表格
- powershell - NuGet 混乱 - 你能赢得比赛吗
- javascript - 如何从文件中调用和重用函数?
- vb.net - 将 stringbuilder 行转换为数组,然后对其进行洗牌