首页前端开发CSS使用css实现自适应标题浮动效果(代码实例)

使用css实现自适应标题浮动效果(代码实例)

时间2024-01-28 01:33:02发布访客分类CSS浏览739
导读:收集整理的这篇文章主要介绍了使用css实现自适应标题浮动效果(代码实例),觉得挺不错的,现在分享给大家,也给大家做个参考。本篇文章通过代码实例给大家介绍一下css实现自适应标题浮动效果的方法。有一定的参考价值,有需要的朋友可以参考一下,希望...
收集整理的这篇文章主要介绍了使用css实现自适应标题浮动效果(代码实例),觉得挺不错的,现在分享给大家,也给大家做个参考。本篇文章通过代码实例给大家介绍一下css实现自适应标题浮动效果的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

(学习视频分享:css视频教程)

效果展示:

源码展示:

!doctyPE htML>
    html>
    head>
    meta charset="utf-8">
    tITle>
    纯css实现自适应标题浮动效果/title>
         style>
        body {
                background-color:#FAFAFA;
        }
         input[type="text"] {
        -webkit-box-sizing:border-box;
        -moz-box-sizing:border-box;
        box-sizing:border-box;
        width:100%;
        height:-webkit-calc(3em + 2px);
        height:calc(3em + 2px);
        margin:0 0 1em;
        padding:1em;
        border:1px solid #cccccc;
        border-radius:1.5em;
        background:#fff;
        reSize:none;
        outline:none;
}
input[type="text"][required]:focus {
        border-color:#00bafa;
}
input[type="text"][required]:focus + label[placeholder]:before {
        color:#00bafa;
}
input[type="text"][required]:focus + label[placeholder]:before,input[type="text"][required]:valid + label[placeholder]:before {
        -webkit-transition-duration:.2s;
        transition-duration:.2s;
        -webkit-transform:translate(0,-1.5em) scale(0.9,0.9);
        -ms-transform:translate(0,-1.5em) scale(0.9,0.9);
        transform:translate(0,-1.5em) scale(0.9,0.9);
}
input[type="text"][required]:invalid + label[placeholder][alt]:before {
        content:attr(alt);
}
input[type="text"][required] + label[placeholder] {
        display:block;
        pointer-events:none;
        line-height:2.3em;
        margin-top:-webkit-calc(-3em - 2px);
        margin-top:calc(-3em - 2px);
        margin-bottom:-webkit-calc((3em - 1em) + 2px);
        margin-bottom:calc((3em - 1em) + 2px);
}
input[type="text"][required] + label[placeholder]:before {
        content:attr(placeholder);
        display:inline-block;
        margin:0 -webkit-calc(1em + 2px);
        margin:0 calc(1em + 2px);
        padding:0 2px;
        color:#898989;
        white-space:nowrap;
        -webkit-transition:0.3s ease-in-out;
        transition:0.3s ease-in-out;
        background-image:-webkit-gradient(linear,left top,left bottom,From(#ffffff),to(#ffffff));
        background-image:-webkit-linear-gradient(top,#ffffff,#ffffff);
        background-image:linear-gradient(to bottom,#ffffff,#ffffff);
        -webkit-background-size:100% 5px;
        background-size:100% 5px;
        background-repeat:no-repeat;
        background-position:center;
}
    /style>
    /head>
    body>
    div style="width:400px;
    height:100px;
    margin:50px auto">
    form>
    input required="" type="text">
    label alt="请输入用户名" placeholder="名称">
    /label>
    /form>
    /div>
    /body>
    /html>
    

更多编程相关知识,请访问:编程视频!!

以上就是使用css实现自适应标题浮动效果(代码实例)的详细内容,更多请关注其它相关文章!

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!

上一篇: css如何实现渐渐消失下一篇:css按钮如何去掉边框猜你在找的CSS相关文章 css怎么控制按钮不可用2022-05-17css3中transform属性实现的4种功能2022-04-13纯CSS3实现div按照顺序出入效果2022-04-13CSS实现隐藏搜索框功能(动画正反向序列)2022-04-13使用CSS3实现按钮悬停闪烁动态特效代码2022-04-13CSS3 Tab动画实例之背景切换动态效果2022-04-13CSS实现两列布局的N种方法2022-04-13CSS 实现Chrome标签栏的技巧2022-04-13css实现两栏布局左侧固定宽右侧自适应的多种方法2022-04-13从QQtabBar看css命名规范BEM的详细介绍2022-04-13 其他相关热搜词更多phpjavapython程序员

若转载请注明出处: 使用css实现自适应标题浮动效果(代码实例)
本文地址: https://pptw.com/jishu/588985.html
css怎么设置居中 css如何实现渐渐消失

游客 回复需填写必要信息