温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用纯CSS实现打开内容弹窗的交互动画是什么

发布时间:2020-08-31 14:29:10 来源:亿速云 阅读:178 作者:小新 栏目:web开发

这篇文章给大家分享的是有关使用纯CSS实现打开内容弹窗的交互动画是什么的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。

效果预览

使用纯CSS实现打开内容弹窗的交互动画是什么

代码解读

定义 dom,一个名为 .main 的容器中包含 1 个链接:

<div class="main">
    <a href="#" class="open-popup">open popup</a>
</div>

设置页面的基本属性:无边距、全高、忽略溢出:

body {
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

设置主界面的背景和其中按钮的布局方式:

.main {
    height: inherit;
    background: linear-gradient(dodgerblue, darkblue);
    display: flex;
    align-items: center;
    justify-content: center;
}

设置按钮样式:

.open-popup {
    box-sizing: border-box;
    color: white;
    font-size: 16px;
    font-family: sans-serif;
    width: 10em;
    height: 4em;
    border: 1px solid;
    text-align: center;
    line-height: 4em;
    text-decoration: none;
    text-transform: capitalize;
}

设置按钮悬停效果:

.open-popup:hover {
    border-width: 2px;
}

至此,主界面完成,接下来制作弹窗。
在 dom 中增加的 .popup 小节表示弹窗内容,其中的 <a> 是返回按钮,<p> 是具体内容,这里我们把内容简化为一些陆生动物的 unicode 字符,为了能够触发这个弹窗,设置 .popupidterrestrial,并在 .main<a> 链接中指向它:

<div class="main">
    <a href="#terrestrial" class="open-popup">terrestrial animals</a>
</div>
<section id="terrestrial" class="popup">
    <a href="#" class="back">&lt; back</a>
    <p>

感谢各位的阅读!关于使用纯CSS实现打开内容弹窗的交互动画是什么就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI