Web-birthday

catalogue

图片全屏显示

javascript 复制代码
<!DOCTYPE html>
<html>
    <head>
        <title>Happy Birthday to You🩷</title>
        <style>
            *{
                margin:0;
                box-sizing:border-box;
            }
            body,html{
                height:100%;
            }
            .fullsreen{
                height:100vh;
                width:100%;
                background-image: url("background.jpg");
                background-size: cover;
                background-position: center;
            }
        </style>
    </head>
    <body>
        <div class="fullsreen"></div>
    </body>
</html>

*与.

*所有元素,.指定类名的元素

div等于视口高度

div是块级元素,默认宽度是100%,但高度为0

javascript 复制代码
.fullscreen-bg{
                /* 等于视口高度 */
                height:100vh;
            }

插入图片

javascript 复制代码
.fullscreen-bg{
                /* 等于视口高度 */
                height:100vh;
                width:100%;
                background-image: url("background.jpg");
            }

margin

margin为0

javascript 复制代码
 *{
                margin:0;
                padding:0;
                box-sizing: border-box;
            }

margin不为0

javascript 复制代码
        <style>
            *{
                /* margin:0; */
                padding:0;
                box-sizing: border-box;
            }

background-size的auto,cover,contain

div阴影

javascript 复制代码
            .shadow{
                box-shadow: 0 5px 15px blue;
            }

div悬浮

javascript 复制代码
           .shadow{
                /* 悬浮 */
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
            }

不要position: absolute

position: absolute使其脱离文档流,即悬浮

javascript 复制代码
          .shadow{
                /* 悬浮 */
                /* position: absolute; */
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
            }

不要top和left

topleft定位悬浮元素的位置

javascript 复制代码
           .shadow{
                /* 悬浮 */
                position: absolute;
                /* top: 50%;
                left: 50%; */
                transform: translate(-50%,-50%);
            }

不要transform

transform定位悬浮元素的位置

javascript 复制代码
            .shadow{
                /* 悬浮 */
                position: absolute;
                top: 50%;
                left: 50%;
                /* transform: translate(-50%,-50%); */
            }

烟雾感边框

javascript 复制代码
            .shadow{
                /* 烟雾感 */
                filter: blur(10px);
            }

延时出现

animation:fadeIn 2s forwards;animation-delay: 1s;@keyframes fadeIn必须一起出现才能实现"延时淡入"效果

opacity 默认是 1,即不透明,要先设置为0,才能看到延时淡入的效果

javascript 复制代码
            .shadow{
                /* 延时 */
                opacity: 0;
                animation:fadeIn 2s forwards;
                animation-delay: 1s;
            }
            @keyframes fadeIn {
                from {opacity:0;}
                to {opacity:1;}
            }

效果演示视频

文字

z-index的数值越大,层级越高
font-size是字体大小
font-family是字体类型

javascript 复制代码
           .word{
                font-family: 'YouYuan';
                color: violet;
                font-size: 3rem;
                /* 延时 */
                opacity: 0;
                animation:fadeIn 2s forwards;
                animation-delay: 2s;
                /* 悬浮 */
                position: absolute;
                z-index: 1;
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
            }

效果演示视频

全部代码

javascript 复制代码
<!DOCTYPE html>
<html>
    <head>
        <title>Happy Birthday🩷</title>
        <style>
            *{
                margin:0;
                box-sizing:border-box;
            }
            body,html{
                height:100%;
            }
            .fullsreen{
                height:100vh;
                width:100%;
                background-image: url("background.jpg");
                background-size: cover;
                background-position: center;
            }
            .shadow{
                height: 50vh;
                width: 50%;
                background-image: url("shadow.jpg");
                background-size: cover;
                background-position: center;
                box-shadow: 0 5px 15px blue;
                /* 悬浮 */
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
                /* 烟雾感 */
                filter: blur(10px);
                /* 延时 */
                opacity: 0;
                animation:fadeIn 2s forwards;
                animation-delay: 1s;
            }
            @keyframes fadeIn {
                from {opacity:0;}
                to {opacity:1;}
            }
            /* 文字 */
            .word{
                font-family: 'YouYuan';
                color: violet;
                font-size: 3rem;
                /* 延时 */
                opacity: 0;
                animation:fadeIn 2s forwards;
                animation-delay: 2s;
                /* 悬浮 */
                position: absolute;
                z-index: 1;
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
            }
        </style>
    </head>
    <body>
        <div class="fullsreen"></div>
        <div class="shadow"></div>
        <div class="word">
            <p>生日快乐呀!🩷</p>
        </div>
    </body>
</html>
相关推荐
架构师老Y15 分钟前
003、Python Web框架深度对比:Django vs Flask vs FastAPI
前端·python·django
小陈工3 小时前
Python Web开发入门(十七):Vue.js与Python后端集成——让前后端真正“握手言和“
开发语言·前端·javascript·数据库·vue.js·人工智能·python
xiaotao1317 小时前
第九章:Vite API 参考手册
前端·vite·前端打包
午安~婉7 小时前
Electron桌面应用聊天(续)
前端·javascript·electron
彧翎Pro8 小时前
基于 RO1 noetic 配置 robosense Helios 32(速腾) & xsense mti 300
前端·jvm
小码哥_常8 小时前
解锁系统设置新姿势:Activity嵌入全解析
前端
之歆8 小时前
前端存储方案对比:Cookie-Session-LocalStorage-IndexedDB
前端
哟哟耶耶9 小时前
vue3-单文件组件css功能(:deep,:slotted,:global,useCssModule,v-bind)
前端·javascript·css
是罐装可乐9 小时前
深入理解“句柄(Handle)“:从浏览器安全到文件系统访问
前端·javascript·安全
华科易迅9 小时前
Vue如何集成封装Axios
前端·javascript·vue.js