2 回答
TA贡献1799条经验 获得超6个赞
您可以使用单个 h1 作为您的名字,并最终使用 vw 来设置您的字体大小:
示例清理 html 和一点你的 css
.MainText {
font-size: calc(5vw);
left: 18%;
top: 25%;
font-family: "Arial Black";
position: fixed;
}
.hoverr {
display:inline-block;
transition: transform ease 1s;
}
.hoverr:hover {
transform: scale(1.15) translatey(-3vw);
text-shadow: rgb(121, 121, 121);
}
<div class="MainText">
<h1>
<!--first name-->
<span class="hoverr ">A</span>
<span class="hoverr">B</span>
<span class="hoverr">H</span>
<span class="hoverr">I</span>
<span class="hoverr">N</span>
<span class="hoverr">N</span>
<!--blank space for seprating first name and last name-->
<br>
<!--last name-->
<span class="hoverr">K</span>
<span class="hoverr">R</span>
<span class="hoverr">I</span>
<span class="hoverr">S</span>
<span class="hoverr">H</span>
<span class="hoverr">N</span>
</h1>
</div>
如果该页面上没有其他内容,并且您希望将您的名字放在中间,那么 flex 可以轻松帮助您:
/* centers body in the window if smaller than window */
html {
min-height: 100vh;
display: flex;
}
body {
margin: auto;
}
/* end page centering */
.MainText {
font-size: calc(5vw);
font-family: "Arial Black";
}
.hoverr {
display: inline-block;
transition: transform ease 1s;
}
.hoverr:hover {
transform: scale(1.15) translatey(-3vw);
text-shadow: rgb(121, 121, 121);
}
<div class="MainText">
<h1>
<!--first name-->
<span class="hoverr ">A</span>
<span class="hoverr">B</span>
<span class="hoverr">H</span>
<span class="hoverr">I</span>
<span class="hoverr">N</span>
<span class="hoverr">N</span>
<!--blank space for seprating first name and last name-->
<br>
<!--last name-->
<span class="hoverr">K</span>
<span class="hoverr">R</span>
<span class="hoverr">I</span>
<span class="hoverr">S</span>
<span class="hoverr">H</span>
<span class="hoverr">N</span>
</h1>
</div>
添加回答
举报