我有一个 header ,希望在悬停时从右向左滑动边框,如果可能的话,请使用纯CSS。
目前,我可以使用以下CSS从左向右滑动边框:
#header a:after {
content: '';
display: block;
border-bottom: 3px solid $(header.hover.color);
width: 0;
-webkit-transition: 1s ease;
transition: 1s ease;
}
#header a:hover:after { width: 100%; }
有没有人很好的解决方案来完成此任务?
最佳答案
您可以将:after
元素放置在右侧
#header {
position: relative;
}
#header a:after {
content: '';
display: block;
border-bottom: 3px solid red;
width: 0;
position: absolute;
right: 0;
-webkit-transition: 1s ease;
transition: 1s ease;
}
#header a:hover:after {
width: 100%;
}
关于html - 使用CSS从右向左滑动边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31180810/