自行车CSS3属性替代? [英] bikeshedding CSS3 property alternative?

查看:145
本文介绍了自行车CSS3属性替代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bikeshedding CSS3属性有任何替代方法吗?

解决方案

white-space属性



在CSS3中, white-space 属性是 white-space-collapsing (我猜 bikeshedding 意味着他们不知道该调用什么)和 text-wrap 属性。 white-space 属性是大多数浏览器支持的CSS 2.1属性,有两个值可以折叠新行:


  1. 正常(初始值)。

  2. nowrap

但是折叠换行符是什么意思? b
$ b

根据CSS 2.1:


如果'white-space'设置为'normal'
'nowrap',换行字符
转换为渲染目的为
以下字符之一:a
空格字符,零宽度空格
字符(U + 200B),或没有字符
(即,不呈现),根据
基于
内容脚本的UA特定算法。


根据CSS 3:



白色之前或之后的零宽度空间包含
换行符的空格序列导致
空白整个序列折叠成零
宽度空间。


现实:



大多数浏览器将换行符转换为空格。所以你真正想要的是将 white-space-collapsing 属性设置为 discard 不是崩溃折叠,然后在换行符之前添加零宽度空格字符。



在浏览器支持之前该怎么做



从HTML文档中删除空白:

 < span> A< / span> 
< span> B< / span>

To:

 code>< span> A< / span>< span> B< / span> 

或:

 code>< span> A< / span>< span> 
B< / span>


Is there any alternative for bikeshedding CSS3 property? It doesn't seem to be supported yet.

解决方案

The white-space property

In CSS3, The white-space property is a shorthand for the white-space-collapsing (I guess bikeshedding means they don't know what to call it yet) and text-wrap properties. The white-space property is a CSS 2.1 property supported by most browsers and there are two values for it that collapse new lines:

  1. normal (The initial value).
  2. nowrap

But what does collapsing line feed characters mean?

According to CSS 2.1:

If 'white-space' is set to 'normal' or 'nowrap', linefeed characters are transformed for rendering purpose into one of the following characters: a space character, a zero width space character (U+200B), or no character (i.e., not rendered), according to UA-specific algorithms based on the content script.

According to CSS 3:

A zero width space before or after a white space sequence containing a newline causes the entire sequence of white space to collapse into a zero width space.

Reality:

Most browsers transform line feed characters into a space. So what you really want is to set the white-space-collapsing property to discard not collapse or to collapse and then add a zero width space character before the line break.

What to do till browser support

Remove white-space from your HTML document:

<span>A</span>
<span>B</span>

To:

<span>A</span><span>B</span>

Or:

<span>A</span><span>
    B</span>

这篇关于自行车CSS3属性替代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆