Search

3/06/2008

Equidistant Objects with CSS - CSS-Tricks

Equidistant Objects with CSS - CSS-Tricks - this is useful!
Example
equidistant.png
FAIL: Give each object a percentage left position


<img src="images/shape-red.png" class="first-r">
<img src="images/shape-green.png" class="second-r">
<img src="images/shape-yellow.png" class="third-r">
<img src="images/shape-blue.png" class="fourth-r">

img.first-r { left: 0%; position: relative; }
img.second-r { left: 25%; position: relative; }
img.third-r { left: 50%; position: relative; }
img.third-r { left: 75%; position: relative; }

FAIL: Give the objects a common left percentage margin

<span class="do-not-wrap">
<img src="images/shape-red.png">
<img src="images/shape-green.png" class="mover">
<img src="images/shape-yellow.png" class="mover">
<img src="images/shape-blue.png" class="mover">
</span>
img.mover {
margin-left: 15%;
}

FAIL: Just use a table!

<table>
<tr>
<td class="leftalign">
<img src="images/shape-red.png">
</td>
<td>
<img src="images/shape-green.png">
</td>
<td>
<img src="images/shape-yellow.png">
</td>
<td class="rightalign">
<img src="images/shape-blue.png">
</td>
</tr>
</table>

PASS: First on the left, float the rest right in equal size boxes

<img src="images/shape-red.png">
<div id="movers-row">
<div><img src="images/shape-green.png"></div>
<div><img src="images/shape-yellow.png"></div>
<div><img src="images/shape-blue.png"></div>
</div>
#movers-row {
margin: -120px 0 0 120px;
}
#movers-row div {
width: 33.3%;
float: left;
}
#movers-row div img {
float: right;
}

Float-less CSS layout

Float-less CSS layout - 用 display:table, display:table-row, display:table-cell 弄出來的。

No div, no float, no clear, no hack*, no joke! A CSS layout that does not use DIV, FLOAT, CLEAR nor structural HACK!
No FLOAT means fewer IE bugs:

* Doubled Float-Margin bug,
* Three Pixel Text-Jog bug,
* Etc.

and here's the comment from Chris Coyier
For another thing, I don’t see what’s so wrong with floats. I know about the IE double margin thing. Big deal. Clearing floats can be a little unsemantic but it works and it’s valid and it’s nothing to re-create your entire layout over. For another thing, it says it’s hack free but clearly uses a hack right in it’s own header. You might argue that conditional comments aren’t hacks but I feel they are at least in the same genre. Still, despite all these things, I gotta admit it does a damn good job of what it says it does. The layouts are very solid.

Grauw’s web spot - The www-style CSS FAQ

Grauw’s web spot - The www-style CSS FAQ

Q: What is incremental rendering
Incremental rendering is the ability to display the contents of a document which is still being loaded. This is a valueable asset, because users do not have to wait for the entire document to load, which can take a fair amount of time depending on the size of the document, the bandwidth of the client, the bandwidth of the server, the locations of the client and the server, etc.

An important part of incremental rendering is to avoid reflows. A reflow of the entire document means it has to be drawn all over again, which is a very slow process, and thus has to be avoided whenever possible.

Thus, incremental rendering and avoiding reflows is important to CSS because it keeps things fast and simple. Especially on lower-end systems such as mobile phones, webtv, and browsers on old computers such as the MSX reflows are extremely costly operations. But also on modern systems such as desktop PCs they have a considerable performance impact, resulting in very slow responsiveness while loading, and often also ugly visible ‘snaps’ when the location of things change as more content is loaded (you can often see this in table-based layouts).

3/05/2008

Acid3 is out

Acid3 is out

he third Acid test, again compiled by Ian Hickson. This one viciously tests DOM Scripting standards compliance and currently exposes flaws in every browser.

Acid3: Putting Browser Makers on Notice, Again. - The Web Standards Project
Acid3 Browser Test - The Web Standards Project
* DOM2 Core
* DOM2 Events
* DOM2 HTML
* DOM2 Range
* DOM2 Style (getComputedStyle, …)
* DOM2 Traversal (NodeIterator, TreeWalker)
* DOM2 Views (defaultView)
* ECMAScript
* HTML4 (<object>, <iframe>, …)
* HTTP (Content-Type, 404, …)
* Media Queries
* Selectors (:lang, :nth-child(), combinators, dynamic changes, …)
* XHTML 1.0
* CSS2 (@font-face)
* CSS2.1 (’inline-block’, ‘pre-wrap’, parsing…)
* CSS3 Color (rgba(), hsla(), …)
* CSS3 UI (’cursor’)
* data: URIs
* SVG (SVG Animation, SVG Fonts, …)

Take the Acid3 test.

Google Maps Without the Scripting

Google Maps Without the Scripting

3/04/2008

web.Frontend :: 翻译:On having layout :: April :: 2006

web.Frontend :: 翻译:On having layout :: April :: 2006

对已渲染元素的重排(re-flow)

当所有元素都已渲染完成时,如果有一个因鼠标经过而引起的变化产生(比如某个链接的 background 有变化),IE会对其 layout 包含区块进行重排。有时一些元素就会因此被排到了新的位置,因为当这个鼠标经过发生时,IE已经知道了所有相关元素的宽度、偏移量等数据了。这在文档首次载入时则不会发生,那时由于自动扩张的特性,宽度还无法确定。这种情况会导致在鼠标经过时页面出现跳变。

* Jump on :hover
* quirky percentages: the reflow

这些和重排问题相关的 bug 会给百分比边距和补白使用较多的流动布局带来不少麻烦。

pseudo-class, pseudo-element, pseudo-CSS: IE/Win bugs with :first-letter, :hover & Co.
Jump on :hover as a consequence of the re-flow

IE6: It's a basic concept of CSS that a page is incrementally rendered, so the user doesn't have to wait until all elements are loaded. The very special situation in IE by allowing containers to expand in width and height ("expand-to-fit"), even when a dimension is given, forces IE to make assumptions on the real boundary of an element. Now, roughly, assumptions can be wrong. On :hover, IE re-renders the elements of a "layout" block, the elements re-flow, but at this moment, all the dimensions are known to IE (they were determined in the first round). This results in a jump on hover, especially on percentage margins and paddings (e.g. in the Holy Grail layout jump), but can be seen in other bug-related situations too. The jump usually corrects the initial misplacement, the jump often indicates that we have to search for a wrong placement of the element before the hover event is performed.

IE7: Like in IE6, it's a rule of thumb that a relatively positioned container needs haslayout, otherwise strange things like disappearance or jumping of the descendants might occur. A :hover event might be the trigger. Check for the haslayout-state of parent elements in these cases.

Unrelated to this, sometimes the 'trivial' cause of a jump on hover is the declaration of a border at the hover-state only, and a fix is to apply a invisible background-colored similar border on the link.

3/03/2008

Web Bug Track: bug 165 - dynamic pre population fails in IE

Web Bug Track: bug 165 - dynamic pre population fails in IE

<script type="text/javascript">
myPreObj.innerHTML = 'This\nWill\nFail... no linebreaks or spaces';
</script>

Example Workaround Code:
<script type="text/javascript">
myPreObj.innerHTML = 'This\nWill\nFail... no linebreaks or spaces';
myPreObj.innerHTML = myPreObj.innerHTML;
</script>

keyword: preserve pre whitespace

Every keystroke is a prisoner - a neat commenting trick

Ajaxian » Every keystroke is a prisoner - a neat commenting trick
If you however use the following syntax then you only need to delete one slash to comment and uncomment a section:

foo();
/*
bar();
baz.foo = 200;
return{
dolly:clone()
}
// */

foo();
//*
bar();
baz.foo = 200;
return{
dolly:clone()
}
// */

in CSS you can just delete and add and remove an asterisk:
.test{
border:1px solid red;
/*/
background-color:blue;
/**/
margin:1em;
}

.test{
border:1px solid red;
/**/
background-color:blue;
/**/
margin:1em;
}

xssinterface - Google Code

xssinterface - Google Code
The xssinterface javascript library enables communication of multiple pages (or pages and iframes) via javascript functions across domain boundaries. This may be useful for websites that want to expose a limited javascript interface to embedded widgets.

xssinterface works in all browsers that support the postMessage() interface and implements a fallback mechanism that works in most current browsers.

How it works?

For Browsers that support it, we use the postMessage() interface.

If the Browser has Google Gears installed, we use Gears cross origin workers.

For all other browsers, we use the following mechanism:

All sites that participate in the cross domain calls must provide an html file (cookie_setter.html) that is provided by this library that enables other domains to place certain cookie under the domain of the site.

The library uses this mechanism to place cookies on the target domain that are then read and evaluated by the target page.

Pages must explicitly grant access to their domain by setting a security token cookie under a domain that is allowed to access the callbacks.

function sayHello() {
var caller = new XSSInterface.Caller("www.two.com","/cookie_setter.html","channel1");
caller.call("hello", "Hello World")
}

window.onload = function () {
window.xssListener = new XSSInterface.Listener("1234567890","channel1");
window.xssListener.allowDomain("www.one.com", "/cookie_setter.html");
window.xssListener.registerCallback("hello", function (msg) {alert(msg)} )
window.xssListener.startEventLoop()
}

Theo Jansen的神奇機械動物

Theo Jansen的神奇機械動物 | vgod’s blog - 第一次看到覺得很像是 wild wild west 裡面的八腳機械怪獸,整個做起來還蠻有感覺的。