高宽不定的div相对父div上下、左右居中
<div class="parent">
<div class="child">123</div>
</div>
css样式使div以表格的特性表现:
.parent {
width: 400px;
height: 360px;
display: table;
text-align: center;
}
.child {
display: table-cell;
vertical-align: middle;
}
居中效果是这样:

高宽不定的div相对父div上下、左右居中的更多相关文章
- 【html】【8】div布局[子div在父div居底]
从今天起 开始细话div布局 思路及要点: 父div的位置设置成相对的,即“position: relative;”. 而子div的位置设置成绝对的,并且下边缘设为0,即“position: ab ...
- 转载 html div三列布局占满全屏(左右两列定宽或者百分比、中间自动适应,div在父div中居底)
原文地址:http://blog.csdn.net/duyelang/article/details/20558899 <p><!DOCTYPE html> <html ...
- CSS+DIV:父DIV相对定位+子DIV绝对定位
如何在一个div内将一个div进行绝对定位呢?很简单,把父div的position属性设为relative,子div的position属性设为absolute就可以了... 示例: <html& ...
- 解决div和父div不上对齐
加一个vertical-align: top;就好了.原因就是inline-block会使元素向下对齐.这和padding-top,margin-top没有关系的.使用浮动就不会有这种情况了,当然会带 ...
- css 子div自适应父div高度
<div class="out"> <div class="a"></div> <div class="b& ...
- html中子div用了浮动怎样让父div的大小自动撑开(清除浮动)
浮动子div撑开父div的几种方法: (1)在父div中在添加一个清除浮动的子div<div style=" clear:both;"></div>,该di ...
- css 设置div基于父元素宽度的宽高相等的样式
1. 前言 在移动开发中,有时候需要设置一个宽高相等的div,并且为了使它能够适配更多的屏幕,于是需要让它的宽高和屏幕宽高成一定的比例.这里将提供一个css的解决方案,让一些后端开发不用再写繁琐的js ...
- 未知高宽的div在其父级div中垂直居中显示
(一)如果已知子div的高宽 .father { position: relative; } .child { width: 100px; height: 80px; position: absolu ...
- 不固定高宽的 div 水平垂直居中
<div class="father"> <div id="main"></div> </div> .fathe ...
随机推荐
- JavaDate类
在JDK1.0中,Date类是唯一的一个代表时间的类,但是由于Date类不便于实现国际化,所以从JDK1.1版本开始,推荐使用Calendar类进行时间和日期处理.这里简单介绍一下Date类的使用. ...
- 给RecyclerView实现的GridView加上HeaderView和FooterView
给RecyclerView设置布局管理器 GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3); 写适配器,添加子项 ...
- centos安装php-memcached扩展及cas用法
一.安装libmemcachedwget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar ...
- Given a compiled machine-language program, which statements in the source language cause the execution of the most machine-language instructions and what is the execution time of these instr
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION A variety of studi ...
- 为什么微信android图片质量会比iphone的差?
为什么微信android图片质量会比iphone的差? 我们团队最初也纠结过这个问题,费了半天劲.绕了好大圈,直到最后才发现,原来这是谷歌犯得一个“小”错误,而且一直错到了今天. 谷歌的错就在于:li ...
- 前台 JSON对象转换成字符串 相互转换 的几种方式
在最近的工作中,使用到JSON进行数据的传递,特别是从前端传递到后台,前台可以直接采用ajax的data函数,按json格式传递,后台Request即可,但有的时候,需要传递多个参数,后台使用requ ...
- Oracle 参数之_small_table_threshold
SQL> select * from v$version; BANNER ------------------------------------------------------------ ...
- iptables nt
占位... 扩展 1.其实匹配扩展中,还有需要加-m引用模块的显示扩展,默认是隐含扩展,不要使用 -m 状态检测的包过滤-m state --state {NEW,ESTATBLISHED ...
- 自动化环境robot framework安装中问题解决
在搭建自动化环境的时候需要安装以下程序:
- -XX:+TraceClassLoading 监控类的加载
-XX:+TraceClassLoading –监控类的加载 •[Loaded java.lang.Object from shared objects file] •[Loaded java.io. ...