H5 div 居中显示

文章目录

  • H5 div 居中显示
    • 推荐:[浏览器同步测试工具](http://www.browsersync.cn/#install)
    • H5 引入外部CSS文件
    • div居中显示
      • 块水平垂直居中
      • 子块水平垂直居中

推荐:浏览器同步测试工具

Browsersync能让浏览器实时、快速响应您的文件更改(html、js、css、sass、less等)并自动刷新页面

H5 引入外部CSS文件

<link type="text/css" rel="stylesheet" href="login.css" >

div居中显示

块水平垂直居中

第一种:

.div{color:red; background-color: red;width: 700px;height: 300px;position:absolute;top: 0;left: 0;bottom: 0;right: 0;margin: auto;
}

第二种:

.div{color:red; background-color: red;width: 700px;height: 300px;position:absolute;top: 50%;left: 50%;margin-top: -150px;margin-left: -350px;
}
子块水平垂直居中

子块login在dv_login居中

.dv_login{color:red; background-color: red;width: 700px;height: 300px;display: flex;align-items: center;justify-content: center;}.login{width: 100;height: 100;background-color: wheat;border: black 1px solid;
}

或者

/* 这个是外部水平垂直居中 */
.div{color:red; background-color: red;text-align: center;width: 700px;height: 300px;position:absolute;top: 50%;left: 50%;margin-top: -150px;margin-left: -350px;
}.login{background-color: wheat;border: black 1px solid;position:absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);}
/* 如果子块有确定宽高,也可以用下面的 */
.login{width:100px;height:100px;background-color: wheat;border: black 1px solid;position:absolute;top: 50%;left: 50%;margin-top: -50px;margin-left: -50px;
}
  <div class="dv_login">  <form class="login"><span>注册:</span><input type="text"><br><span>密码:</span><input type="password"></form>
</div>

H5 div 居中显示相关推荐

  1. 设置div中的div居中显示

    设置div中的div居中显示 方法一. <div class='big'><div class='small'>box1</div></div>styl ...

  2. 如何使 一个 div 居中显示

    在 chrome 或 FireFox里,使用 body{ margin:0px; padding:0px; } div{ magin:0 auto; } 即可让一个 div 居中显示,但在 IE 里不 ...

  3. 使一个div居中显示的三种方法

    使一个div居中显示的三种方法 1. <!DOCTYPE html> <html lang="en"> <head><meta chars ...

  4. 关于div居中显示的问题

    关于div居中显示的问题 要想设置div居中显示,只需要设置margin-right:auto 和 margin-left:auto 切记,这种方法 不能设置浮动,也就是float属性.否则,达不到预 ...

  5. 前端笔记之Div居中显示

    前端笔记之Div居中显示 1.水平居中:给div设置一个宽度,然后添加margin:0 auto属性 <!DOCTYPE html> <html> <head>&l ...

  6. 使用css代码实现div居中显示 div水平居中显示

    使用css代码实现div居中显示 div水平居中显示 属性 居中显示 属性 需要的主要css代码有两个,一个为text-align:center(内容居中),另外一个为**margin:0 auto: ...

  7. 利用transform:translate使div居中显示

    利用transform:translate使div居中显示 之前一直在用这个属性让某个div居中显示,但是一直有一个困惑,我想同时让水平和垂直都居中,可是水平方向总会有一点偏差,看一下以前怎么写的. ...

  8. 使用css使div居中显示

    本例以vue为例,使用text-align: center 和margin:0 auto;实现div居中显示 1.html代码 <template>   <div class=&qu ...

  9. 两个div并排显示 div居中显示

    div并排显示的两种方法 float:left display: inline-block; div居中显示.文字居中显示 text-align: center;margin: 0 auto

最新文章

  1. mysql大于等于怎么写_数据库中大于等于0小于等于100怎样表达
  2. 虚拟机下Linux安装图解之三:Linux发行版本之Red Hat 9 安装
  3. 《Elasticsearch 权威指南》阅读笔记
  4. python【蓝桥杯vip练习题库】PREV-52小数第n位(模拟)
  5. 微信小程序云开发 | 云函数安装依赖
  6. Numpy.tile() (Python)
  7. Tomcat SSL/HTTPS 单向认证
  8. 使用swipecard实现卡片视图左右滑动监听以及点击监听
  9. nssl1447-小智的糖果【dp】
  10. 洛谷P2347 砝码称重 某一年noip提高组原题
  11. retrofit content-length为0_Retrofit 源码剖析
  12. 【SQL Server】入门教程-基础篇(完结)
  13. 四种JSON解析工具--(json-libJacksonGsonFastJson)
  14. matlab损耗函数曲线,MATLAB 损失函数画图
  15. 基于SVP的格密码计算复杂性问题
  16. ORA-00937:不是单组分组函数
  17. php用代码写的三行情书,三行情书经典语录_最美的三行情书(两行泪,一段情)
  18. gensim 主题模型 seed
  19. 分数混合运算简便方法_分数混合运算和简便计算
  20. react 前端 实现打印机打印功能

热门文章

  1. 计算机毕设(附源码)JAVA-SSM基于Java的新冠疫苗预约系统
  2. 简单几步骤查看天猫国际同行大量商品的发布、下架时间
  3. 网站被CC攻击了如何应对?
  4. oracle管理 | 表空间权限管控
  5. 用户注册发送激活邮件(上)
  6. Unity 发送邮件(附 QQ邮箱开启Smtp授权方法)
  7. 即使不学编程,你也要了解计算机思维
  8. 上架打包错误信息:Found an unexpected Mach-0 header code: 0x72613c21
  9. freeRTOS中文实用教程1
  10. dofilter在java中_java – doFilter没有被调用