margin的auto的理解 top,left[,bottom,right] position
auto
auto 总是试图充满父元素
margin有四个值:
All the margin properties can have the following values:
auto - the browser calculates the margin
length - specifies a margin in px, pt, cm, etc.
% - specifies a margin in % of
inherit - specifies that the margin should be inherited from the parent element
absolute: 会脱离标准文档流,但若不指定top,right,bottom,left 则还在原位置上

margin-left,margin-top是影响自身
margin-right,margin-bottom是影响它后面的元素
top left
top
The top CSS property specifies part of the position of positioned elements. It has no effect(只对于定位了的元素有效,包括相对定位,绝对定位) on non-positioned elements.
For absolutely positioned elements (those with position: absolute or position: fixed), it specifies the distance between the top margin edge of the element and the top edge of its containing block.
For relatively positioned elements(相对定位的元素:top是相对于自身) (those with position: relative), it specifies the amount the element is moved below its normal position.
When both top and bottom are specified, as long as height is unspecified, auto or 100%(高度值未声明,auto或是100%), both top and bottom distances will be respected. Otherwise, if height is constrained(如果top和bottom同时声明,并且height被限制,则bottom就会无效) in any way, the top property takes precedence and the bottom property is ignored.
/* <length> values */
top: 3px;
top: 2.4em;
/* <percentages> of the height of the containing block(containing block的高度的百分) */
top: 10%;
/* Keyword value */
top: auto;
/* Global values */
top: inherit;
top: initial;
top: unset;
left
The left CSS property specifies part of the position of positioned elements(适用于被定位了的元素). For absolutely positioned elements (those with position: absolute or position: fixed), it specifies the distance between the left margin edge of the element and the left edge of its containing block.
/* <length> values */
left: 3px;
left: 2.4em;
/* <percentage>s of the width of the containing block(containing block的百分比) */
left: 10%;
/* Keyword values */
left: auto;
/* Global values */
left: inherit;
left: initial;
left: unset;
right:
The right property has no effect on non-positioned elements.
When both the right CSS property and the left CSS property are defined, the position of the element is overspecified(同时对元素采用left和right属性时,对于从左向右的dom,left优先级更高). In that case, the left value has precedence when the container is left-to-right (that is that the right computed value is set to -left), and the right value has precedence when the container is right-to-left (that is that the left computed value is set to -right).
position
The position CSS property chooses alternative rules for positioning elements, designed to be useful for scripted animation effects.
A positioned element is an element whose computed position property is either relative, absolute, fixed or sticky.
- A relatively positioned element is an element whose computed position property is relative.
- An absolutely positioned element is an element whose computed position property is absolute or fixed.
- A stickily positioned element is an element whose computed position property is sticky.
margin的auto的理解 top,left[,bottom,right] position的更多相关文章
- margin的auto的理解
auto 总是试图充满父元素 margin有四个值: All the margin properties can have the following values: auto - the brows ...
- 定位(left 、right 、top 、 bottom)、padding、margin 值设为百分比值时
定位(left .right .top . bottom): top 为例 right 为例 padding.margin : 当padding.margin 值设为百分比值时,其百分比会相对于父元素 ...
- 详解margin: auto
auto是margin的可选值之一.相信大家平时使用auto值时,最多的用法大概是 margin: 0 auto; 和 margin: auto; 不过你可能也发现了不论是 margin: auto; ...
- margin:0 auto是什么意思
一.margin设置对象外边距 二.margin后面如果只有两个参数的话,第一个表示top和bottom,第二个表示left和right 因为0 auto
- 正确的使用margin:0 auto与body{text-align:center;}实现元素居中(转)
body{text-align:center}与margin:0 auto的异同? text-align是用于设置或对象中文本的对齐方式.一般情况下我们设置文本对齐方式的时候需要用此属性进行设置 我们 ...
- position:absolute和margin:auto 连用实现元素水平垂直居中
有时候,要实现一些元素水平垂直都居中,这部分元素呢 可能大小未知,例如一些图片或者是一些未知大小的块元素. 利用绝对定位可以将要居中的元素脱离文档流. position: absolute; left ...
- margin:0 auto为何会居中?
margin: 0 auto;为何会居中呢??? 一开始的学习html的时候,就是只知道块级元素margin:0 auto就能居中 但是后来就很好奇 margin: auto 0;为何不能垂直居中? ...
- CSS中margin:auto什么意思?margin:auto属性的用法详解
我们都知道使用margin:auto可以让元素水平居中的.但你有没有想过使用margin:auto可以让元素水平居中的原因,要回答这个问题,我们首先需要看一下margin:auto的工作原理.auto ...
- 绝对定位上下左右都为0 margin为auto为什么能居中
老规矩,先来一段废话,我大学刚入门的时候觉得CSS很简单,记一记就会了,不就是盒模型嘛,现在想来觉得自己那时候真的很自以为是哈哈.但是随着工作沉淀,我明白了任何技术都有着它的深度和广度,正是因为不少人 ...
随机推荐
- Python解释器的配置
1.准备工作 安装好Pycharm2017版本 电脑上安装好Python解释器 2.本地解释器配置 配置本地解释器的步骤相对简洁直观: (1)单击工具栏中的设置按钮. (2)在Settings/Pre ...
- Java Web基础——Controller+Service +Dao三层的功能划分
转自:https://www.cnblogs.com/cielosun/articles/5752272.html 1. Controller/Service/DAO简介: Controller是管理 ...
- SpringCloud---客户端负载均衡---Spring Cloud Ribbon
1.概述 1.1 Spring Cloud Ribbon是一个基于HTTP和TCP的客户端负载均衡工具: 基于Netflix Ribbon实现: 通过Spring Cloud的封装,可以轻松将面向服务 ...
- 带双反斜杠的Json数据至单反斜杠的Json数据处理
假如你光看标题,你只能哦呵呵了!我也看不懂.还是先描述下问题吧.这里是使用微信接口返回了一些数据.因为该串数据包含html标签所以TX是对该串数据进行了编码的.所有的数据是通过Unicode编码的,然 ...
- 利用rem解决移动端响应适配问题
最近看了<从网易与淘宝的font-size思考前端设计稿与工作流>和github上的<使用Flexible实现手淘H5页面的终端适配> 以前一直用百分比的我,对移动前端的H5页 ...
- pointer-events属性值详解
其实早知道这个属性,但是一直没有去研究过.今天正好在twitter看到这个词,就去研究了下,正好解决了目前遇到的一个小难题,所以分享下.嗯,其实这是个比较简单的CSS3属性. 在某个项目中,很多元素需 ...
- H5页面JS调试
页面调试 常用的调试方法 开发时候的调试基本是在chrome的控制台Emulation完成 现有的一些手机端调试方案: Remote debugging with Opera Dragonfly 需要 ...
- LVS+keepalived DR模式配置高可用负载均衡集群
实验环境 LVS-Master 10.0.100.201 VIP:10.0.100.203 LVS-Slave 10.0.100.204 WEB1-Tomcat 10.0.2.29 gat ...
- win7(64)+vs2010+opencv2.3.1配置问题:应用程序无法正常启动0xc000007b
根据:毛星云(浅墨)的[OpenCV入门教程之一] 安装OpenCV:OpenCV 3.0.OpenCV 2.4.8.OpenCV 2.4.9 +VS 开发环境配置 文章链接:http://blog. ...
- 从零开始制作H5人脸融合小游戏
去年的建军节,一个展示军装照的H5人脸融合游戏火遍朋友圈,带来很好的传播效果.最近欧冠决赛要来了,公司决定做一个寻找和你最像的欧冠球星的H5游戏,那么该怎么做呢?认真分析了一下,这个游戏其实用到的技术 ...