首页 建站教程 WEB前端 正文

元素垂直居中

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> &nb...
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .wrap{
            width: 400px;
            height: 400px;
            margin: 0 auto;
            background: rgba(0,0,0,0.5);
            color: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .main{
            width: 400px;
            height: 400px;
            margin: 20px auto;
            position: relative;
            background: rgba(0,0,0,0.5);
            color: #fff;
        }
        .main p{
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
        }
    </style>
</head>
<body>
    <div>
        <p>对对对对对对对对对对对对对对对<br>猜猜猜猜猜错错错错错错错错错错错<br>试试事实上是是是<br>猜猜猜猜猜错错错错错错错错错错错<br>试试事实上是是是<br>猜猜猜猜猜错错错错错错错错错错错<br>试试事实上是是是</p>
    </div>
    <div>
        <p>对对对对对对对对对对对对对对对<br>猜猜猜猜猜错错错错错错错错错错错<br>试试事实上是是是<br>猜猜猜猜猜错错错错错错错错错错错<br>试试事实上是是是<br>猜猜猜猜猜错错错错错错错错错错错<br>试试事实上是是是</p>
    </div>
</body>
</html>


打赏
海报

本文由优美主题原创或收集发布

转载请注明本文地址:http://www.umtheme.com/web/31.html

相关推荐

如何在html页面中通过css隐藏元素

在平常的页面布局中,我们经常会遇到将某个模块隐藏,而实现不同的页面布局或js交互效果,尤其是在响应式布局中比较常见,下面我们整理了一些关于实现隐藏页面元素的多种方法以及各种方法不同的特点(如:是否占据...

WEB前端 2020.09.18 0 25

web前端写html页面div+css命名规范

web前端写html页面div+css命名规范

使用良好的CSS书写规范来写CSS代码,既能最大化优化前端代码,提升代码阅读体验,更重要的是为以后维护带来方便。常用的CSS命名一般由小...

WEB前端 2020.09.08 0 70

给网页增加WOW插件滚动触发css动效

随着浏览器的兼容性增强,css3动画特效运用也越来越广,通过css3动画库加js可以实现很多炫酷的效果。比如在滚动页面时会触发展示各式各样的动画效果,通过设置调整可以改变动画的风格、延迟、偏移量等。优...

WEB前端 2018.07.04 0 3666

发布评论

ainiaobaibaibaibaobaobeishangbishibizuichiguachijingchongjingdahaqiandaliandangaodw_dogedw_erhadw_miaodw_tuzidw_xiongmaodw_zhutouganbeigeiliguiguolaiguzhanghahahahashoushihaixiuhanheixianhenghorse2huaixiaohuatonghuaxinhufenjiayoujiyankeaikeliankouzhaokukuloukunkuxiaolandelinileimuliwulxhainiolxhlikelxhqiuguanzhulxhtouxiaolxhwahahalxhzanningwennonuokpinganqianqiaoqinqinquantouruoshayanshengbingshiwangshuaishuijiaosikaostar0star2star3taikaixintanshoutianpingtouxiaotuwabiweifengweiquweiwuweixiaowenhaowoshouwuxiangjixianhuaxiaoerbuyuxiaokuxiaoxinxinxinxinsuixixixuyeyinxianyinyueyouhenghengyuebingyueliangyunzanzhajizhongguozanzhoumazhuakuangzuohenghengzuoyi

感谢您的支持