javascript - css - 无法使用字体样式“幸运的家伙”垂直居中跨度
问题描述
我发现我无法使用字体样式“ Luciest Guy ”垂直居中跨度。
我试图申请display: flex;align-items: center;
但span
没有工作。
应用程序.vue
<template>
<div id="app">
<span>Luckiest Guy Font</span>
</div>
</template>
<script>
export default {
name: "App",
};
</script>
<style lang="scss">
@import url("https://fonts.googleapis.com/css2?family=Luckiest+Guy&display=swap");
#app {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
background-color: grey;
margin-top: 60px;
span {
font-family: "Luckiest Guy", Helvetica, Arial, sans-serif;
font-size: 19px;
line-height: 19px;
display: flex;
align-items: center;
}
}
</style>
CodeSandbox:
https ://codesandbox.io/s/cool-browser-lh9f8?file=/src/App.vue:441-453
解决方案
您的代码没有问题,并且工作正常。也许您还有其他一些影响此标签的类。
你也可以设置vertical-align:baseline; 在跨度标签样式中。
.span-style{
display:flex;
align-items:center;
justify-content:center;
border:1px solid black;
height:40px;
vertical-align:baseline;
}
<div>
<span class="span-style">
Hello world
</span>
</div>
推荐阅读
- apache-poi - 从 zip 文件中读取多个 xls 文件
- c++ - 从 XML 中读取未指定结构的每个数据成员
- amazon-dynamodb - 在 DynamoDB 中插入地图
- python - 使用字典列表更新数据框单元格值时出错
- javascript - 使用 Ajax 和 php 更新 Span 元素
- java - 如何在android studio中创建卡通效果
- angular - 我正在尝试在 component.ts 文件中包含 js 代码。这样做时我遇到了错误
- api - 如何限制对 API 的请求量?
- sql-server - SQL 条件提交 - 即使没有错误也检查结果
- angularjs - .net核心中的AngularJS路由问题