margin

Android: RelativeLayout margin works but gets overridden

前提是你 提交于 2019-12-25 01:46:49
问题 Problem Using RelativeLayout.LayoutParams and marginTop before setLayoutParams( params ) . Works on all devices for half a second but some cases it bumps back to top. The view stays centered in the holding view on my Moto X 2014 running Lollipop but not on my Nexus 4 running Lollipop . Opening activity Opens activity The margin is fine and the SurfaceView is centered ~200ms delay The margin resets and its back to top (top of SurfaceView at the top of holder) Closing activity Back pressed

CSS & Regex, switching values of padding or margin property

僤鯓⒐⒋嵵緔 提交于 2019-12-25 00:37:27
问题 I have CSS code where I want to find Padding -or- Margin Properties (where it has 4 values) and to switch the left value with right value: e.g. padding: 1px 2px 3px 4px; - to be like this - padding: 1px 4px 3px 2px; How can I achieve this with regex & PHP? :-) 回答1: Try this: preg_replace( '/padding:\s*?(\d*px)\s*(\d*px)\s*(\d*px)\s*(\d*px)\s*?;/i', 'padding: $1 $4 $3 $2;', $css ); Explanation \s matches a space \d matches a digit \d*px will match any digits followed by a 'px' 来源: https:/

css实现多种常见布局

流过昼夜 提交于 2019-12-24 20:55:16
水平居中 定宽的块级元素 .out { } .in { margin: 0 auto; } 不定宽的块级元素(一个div里面多个div要居中) 里面元素设置为内联元素,父元素使用text-align:center; .out { text-align: center; } .in { display: inline-block; } 使用flex布局 .out { display: flex; justify-content:center; } .in { } 给多个div加一个container .out { position: relative; } .container { position: absolute; left:50%; transform: translate(-50%,0) } .in { float: left; } 内联元素居中 .out { text-align:center; } 垂直居中 块级元素垂直居中,知道高度 .out { } .in { margin-top: 75px; } .out { box-sizing: border-box; padding-top: 75px; } .in { } 块级元素垂直居中,不知道高度 .out { position: relative; } .in { position: absolute; top:

css常见布局方式

北城余情 提交于 2019-12-24 20:12:10
  布局是CSS中一个重要部分,下面总结了CSS布局中的常用技巧,包括常用的水平居中、垂直居中方法,以及单列布局、多列布局的多种实现方式(包括传统的盒模型布局和比较新的flex布局实现)。   一、居中方式    水平居中 水平居中对于子元素为行内元素还是块状元素,宽度一定还是宽度未定,采取的布局方案是不同。 行内元素:对父元素设置text-align:center; 定宽块状元素: 设置左右margin值为auto; 不定宽块状元素: 设置子元素为display:inline,然后在父元素上设置text-align:center; 通用方案: flex布局,对父元素设置display:flex;justify-content:center; 垂直居中 垂直居中对于子元素是单行内联文本、多行内联文本以及块状元素采用的方案也是不同的。 父元素一定,子元素为单行内联文本:设置父元素的height等于行高line-height 父元素一定,子元素为多行内联文本:设置父元素的display:table-cell或inline-block,再设置vertical-align:middle; 块状元素:设置子元素position:absolute并设置top、bottom为0,父元素要设置定位为static以外的值,margin:auto; 通用方案: flex布局,给父元素设置

Center an `<img>` in a `<div>`

柔情痞子 提交于 2019-12-24 19:20:05
问题 How do I center an <img> in a containing <div> ? The usual margin-left: auto; margin-right: auto; isn't working. The image can be larger than the container, and is scaled either horizontally or vertically by the max-width and max-height . A jsfiddle with the below code: http://jsfiddle.net/9ShGj/1/ HTML: <div class="container"> <img src="http://www.yensa.com/fat/fat-dude10.jpg" /> </div> <div class="container"> <img src="http://oi43.tinypic.com/bje2wn.jpg" /> </div> CSS: .container { width:

python | HTML 笔记2

狂风中的少年 提交于 2019-12-24 19:16:19
HTML --css笔记: 一.css引入方式 1.行内式(不推荐使用): 直接在标签里面加style-css样式,这样是可以添加,但是会出现很同样标签,所以一般不推荐 和使用这样的方式去添加css样式. 使用方法: <p style="color:green">这里放设置文本</p> 直接在标签属性添加style-css样式 2.内接样式(页面较小的时候使用哟 ***): 内接样式是针对页面比较小的情况,才会使用. 使用方法:就可以直接在head 标签里面添加:<style> 直接在这里写cass样式</style> 3.外接样式: (1) 链接式 *** 这个是常用的方式,链接式一般都是会另外写一个文件,然后通过link 样式文件进来. 使用方法:<link rel="stylesheet" href="这里放cass文件"> (2) 导入式 同样也是另外写css文件然后导入,不建议使用,因为页面css加载不出来时候,会显示 html 的页面,有加载延迟 导入式是使用方法: @import url("这里放css文件") 二.选择器 *** 注意点: css优先级,指的是浏览器加载 cass 样式的先后顺序 *** 1.基本选择器 (1) 标签选择器 直接使用标签名来做选择器,而不是在另外设置属性,调用属性的( 值 ) 使用方法:直接标签来写在里面,任何标签都是可以找到的.

control margin properties depending on another control margin properties in wpf

你。 提交于 2019-12-24 19:02:42
问题 I'm trying to show two canvas control in a grid in my wpf applike this way. the second_canvas.margin.left will be the same as first_canvas.margin.right . but it can't be done since margin property can't be used as a variable. So I tried " Thickness ". but I can't convert first_canvas.margin.right to a thickness variable since it's a double type. So is there any work around for this? 回答1: You could write a dedicated value converter: using System; using System.Collections.Generic; using System

vim left and right column highlight

久未见 提交于 2019-12-24 15:29:45
问题 I need to highlight anything beyond column 72 with a different background color. What's the best method? Something similar to a visible line margin that some editors do is also good. Is it possible? Some background: The syntax is a Pascal like, and works correctly. Only the Background needs to change. The foreground is already highlighted as it should be. There are cases where a String will be more than 80 characters and will pass the 72 column limit, and should be highlighted as a string.

How to remove this space(margin) from a QWidget form

爷,独闯天下 提交于 2019-12-24 14:52:50
问题 I have a QWidget form , then I have added QTextEdit on the form, but there is a space(margin) in the top. I tried to use the following: QWidget *widget = new QWidget(this); widget->layout()->setContentsMargins(0,0,0,0); But unfortunately, it did not do what I want. How to remove that space(margin) to be like the left , right and down side ? Full code QWidget *widget = new QWidget(this); QTextEdit *TextEdit = new QTextEdit(widget); QMdiSubWindow *mdiWindows = ui->mdiArea->addSubWindow(widget);

Margin of inner Div affects outer div

青春壹個敷衍的年華 提交于 2019-12-24 14:18:42
问题 I have three nested DIV elements like this: <div id="outer"> <div id="innerA"> <div id="innerB"> This<br/>is<br/>a<br/>multiline<br/>testcase.<br/> This<br/>is<br/>a<br/>multiline<br/>testcase.<br/> </div> </div> </div> #innerA has a height of 100% which makes it as big as #outer . #innerB 's height is left to be auto so it gets as high as its contents. Now when i set #innerB to have margin-top: 10px for example i would expect that #innerB will get a margin in relation to #innerA . What