css - 怎么做一个悬浮导航条,下边框有一个进度条过渡的效果

查看:169
本文介绍了css - 怎么做一个悬浮导航条,下边框有一个进度条过渡的效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        div{
            margin: 100px auto;
            width: 100px;
            height: auto;
            border-left: 2px solid aqua;
            border-left-width: 1px;
            transition: all 6s;
            -webkit-transition:all 6s;
        }

        div:hover{
            border-bottom-width: 100px;
            border-bottom-color: aqua;
        }
    </style>
</head>
<body>
    <div>hello world!</div>
</body>
</html>

我做了一个,可是不行。悬浮div下边框,从左至右开始延伸的效果。并且不超出div的宽度。求大神帮助

解决方案

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        div {
            margin: 100px auto;
            width: 100px;
            height: auto;
            border-left: 2px solid aqua;
            border-left-width: 1px;
            position: relative;
        }

        .ani {
            position: absolute;
            border-bottom: 1px solid aqua;
            left: 0;
            bottom: 0;
            width: 0px;
            transition: all 3s;
            -webkit-transition: all 3s;
        }

        div:hover .ani{
            width: 100px;
        }
    </style>
</head>

<body>
    <div>
        hello world!
        <em class="ani"></em>
    </div>
</body>

</html>


也可以根据@Baran所说的,用伪类做

这篇关于css - 怎么做一个悬浮导航条,下边框有一个进度条过渡的效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆