一

{"type":"编程笔记"}


  • Home

  • Archives
  • Search

difference sed on macosx and linux

Posted on 2014-08-01   |   In linux

sed正则替换内容时,碰到在Linux上正常执行的命令在MacOSX执行失败的问题,如:

 sed -i 's/text/replaced/g' filename

sed: 1: "filename": invalid command code -

google之后发现有别人碰到类似的问题,在MacOSX上需要加个空字符串在-i参数后面:

 sed -i "" 's/text/relpaced/g' filename

What I hadn’t realised is that on the Mac version of sed the -i flag has a mandatory suffix, as described in this post.

The appropriate section of the man page for sed on the Mac looks like this:

-i extension    Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved.

It is not recommended togive a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is exhausted, etc.

Read more »

jquery-1.4.2 utilities部分源码分析

Posted on 2014-08-01   |   In jquery

jQuery.extend方法是扩展jQuery本身的静态对象,各方法解释直接写在jQuery源码注释前:

Read more »

jquery-1.4.2 support部分源码分析

Posted on 2014-08-01   |   In jquery

Event detection without browser sniffing

Two more events are left to be handled: submit and change. Before jQuery applies fix for these two events, jQuery needs a way to detect if a browser allows submit and change events to bubble or not. jQuery team does not favor browser sniffing. So how to go about detecting event support without browser sniffing.

Juriy Zaytsev posted an excellent blog titled Detecting event support without browser sniffing . Here is the a short and concise way he proposes to find out if an event is supported by a browser.

Read more »

jquery-1.4.2 sizzle部分源码分析

Posted on 2014-08-01   |   In jquery

Sizzle部分源码分析

Read more »

jquery-1.4.2 offset部分源码分析

Posted on 2014-08-01   |   In jquery

9.3 Positioning schemes[CSS2.1中的定位方式]

In CSS 2.1, a box may be laid out according to three positioning schemes:

  1. Normal flow [p. 130] . In CSS 2.1, normal flow includes block formatting [p. 130]
    of block [p. 121] boxes, inline formatting [p. 130] of inline [p. 123] boxes, relative
    positioning [p. 133] of block or inline boxes, and positioning of run-in [p. 124]
    boxes.

  2. Floats [p. 134] . In the float model, a box is first laid out according to the normal
    flow, then taken out of the flow and shifted to the left or right as far as possible.
    Content may flow along the side of a float.

  3. Absolute positioning [p. 141] . In the absolute positioning model, a box is
    removed from the normal flow entirely (it has no impact on later siblings) and
    assigned a position with respect to a containing block.

Note. CSS 2.1’s positioning schemes help authors make their documents more accessible by allowing them to avoid mark-up tricks (e.g., invisible images) used for layout effects.

在CSS中关于position的说明:

position:relative | absolute | static | fixed

static 没有特别的设定,遵循基本的定位规定,不能通过z-index进行层次分级。

relative 不脱离文档流,参考自身静态位置,并可通过 top, bottom, left, right 相对于其原来的静态位置进行定位,并且可以通过z-index进行层次分级。

absolute 脱离文档流,通过 top, bottom, left, right 定位。选取其最近的non-static父级定位元素,当全部祖先元素的 position 为 static 时,absolute元素将以body坐标原点进行定位,可以通过z-index进行层次分级。

fixed 固定定位,这里他所固定的对像是可视窗口而并非是body或是父级元素。可通过z-index进行层次分级。

一、DOM元素对于offset提供了offsetParent、offsetTop、offsetLeft、offsetWidth、offsetHeight五个属性来定位于元素的相对位置。

offsetParent是指当前元素的相对定位时的参考元素,当前元素可以根据offsetParent和top/left进行定位。

offsetParent、parentNode(IE: parentElement)都是指元素的父节点。它们的针对的目标是不一样,功能也不一样。

parentNode就是取文档层次中包含该节点的最近父节点(直接的父节点)。在FF中对于Attr, Document, DocumentFragment, Entity和Notation这些父节点,其parentNode返回null。还有如果没有附加到文档树的元素也是返回null。

offsetParent是指可视的父节点。如:

Read more »
1…293031…99
yuweijun

yuweijun

492 posts
12 categories
RSS
GitHub Twitter
© 2021 yuweijun
Powered by Hexo
Theme - NexT.Mist.KISS