[英]css - not able to vertical center span with font-style "Luckiest Guy"
我發現我無法使用字體樣式“ Luckiest Guy ”進行垂直居中。
我試圖應用display: flex;align-items: center;
在span
但不工作。
應用程序
<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>
代碼沙盒:
https://codesandbox.io/s/cool-browser-lh9f8?file=/src/App.vue:441-453
您的代碼沒有問題,並且運行良好。 也許您還有一些其他類會影響此標簽。
您也可以設置 vertical-align:baseline; 在 span 標簽樣式中。
.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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.