html - 我如何控制(悬停)出现边框的长度?
问题描述
嗨,我正在为我的作品集制作一个网站,需要一些帮助来解决我遇到的样式问题。我将向您展示我的外观,然后跟进我正在尝试复制的模板。
在底部的边框看起来好像不同的文本有一个它们所在的框。如果你明白我的意思。
我的代码如下;
萨斯:
.header{
nav {
padding: 2rem 30rem;
background: $blackish;
}
&__links {
a {
font-size: $font-med;
margin-right: 6.25rem;
border-bottom: 3px solid transparent;
}
a:hover {
color: $boltyellow;
padding: 1.9rem 0rem;
border-bottom-color: $boltyellow;
}
}
}
html:
<header class = "header">
<div class="top"></div>
<nav class = "flex">
<div class="header__links">
<a href="#">Home</a>
<a href="#">Order</a>
<a href="#">About</a>
<a href="#">Contact</a>
</div>
</nav>
</header>
解决方案
你可以在伪类之前或之后做
a:after{
content:'';
width:0;
height:3px;
background: yellow;
position: absolute;
bottom:0;
left:0;
display: block;
transition: ease-in-out .5s;
}
a:hover:after{
width:100%;
}
推荐阅读
- android - Kotlin:如何生成依赖于两个文本框的 If 语句
- php - 使用 Apache 在 raspberry (Debian) 上运行的 PHP
- c++98 - 如何在头文件中定义嵌套映射以在 .cpp 中使用
- go - Go 频道——这里发生了什么
- c - C:为数组中的所有字符串添加文字,同时保留对原始字符串的访问权限
- javascript - 从映射对象中删除空数组
- xamarin - 如何修复xamarin中的空白列表视图页面
- encryption - 文件校验和中是否存在冲突?
- dart - 用颤振绘制虚线弧
- swift - 我有一个“UIImage”,我想将其转换为 NSData 以上传到 firebase 存储