Firefox中的CSS列数(CSS column-count in Firefox)
我想为一个块内的div使用CSS
column-count
。 但是,由于一些浏览器(例如IE 9)不支持column-count
,我想为该块内的div设置float:left
。但是,如果我这样做,
column-count
将在Firefox中以一种奇怪的方式表现。 如果我不使用float:left
,它可以在Firefox中正常工作,而在Chrome中使用float:left
不使用float:left
时可以正常工作。 请参阅附件图片。那么,我该如何将
column-count
和float:left
一起使用。这里是
JSFiddle
链接: http : //jsfiddle.net/V8KV6/1/代码如下:
HTML:
<div class="block"> <div class="column"></div> <div class="column"></div> <div class="column"></div> <div class="column"></div> <div class="column"></div> </div>
CSS:
.block{ width: 300px; -webkit-column-count:3; -moz-column-count:3; } .column{ background: orange; width: 100px; height: 100px; margin-bottom: 20px; float: left; }
I want to use CSS
column-count
for the divs inside a block. However, since some browsers (eg. IE 9) do not supportcolumn-count
, I want to setfloat:left
for the divs inside the block.But if I do that,
column-count
will behave in a strange way in Firefox. It works fine in Firefox if I do not usefloat:left
, while it works fine in Chrome with and withoutfloat
. Please see the attached image.So, how can I use the
column-count
andfloat:left
together.Here's the
JSFiddle
Link: http://jsfiddle.net/V8KV6/1/And here's the code:
HTML:
<div class="block"> <div class="column"></div> <div class="column"></div> <div class="column"></div> <div class="column"></div> <div class="column"></div> </div>
CSS:
.block{ width: 300px; -webkit-column-count:3; -moz-column-count:3; } .column{ background: orange; width: 100px; height: 100px; margin-bottom: 20px; float: left; }
原文:https://stackoverflow.com/questions/12350713
最满意答案
与Java的
Object
类不同,PHP 没有对象的基类 。 对象不会继承stdClass
:它是默认的对象实现,而不是基类。 所以,不幸的是,你不能在PHP中输入所有对象的提示。 您必须执行以下操作:class MyClass { public function myFunc($object) { if (!is_object($object)) throw new InvalidArgumentException(__CLASS__.'::'.__METHOD__.' expects parameter 1 to be object"); } }
幸运的是,PHP已经为此目的定义了
InvalidArgumentException
类。Unlike Java's
Object
class, PHP does not have a base class for objects. Objects do not inheritstdClass
: it's a default object implementation, not a base class. So, unfortunately, you can't type hint for all objects in PHP. You have to do something like:class MyClass { public function myFunc($object) { if (!is_object($object)) throw new InvalidArgumentException(__CLASS__.'::'.__METHOD__.' expects parameter 1 to be object"); } }
Luckily, PHP already defines the
InvalidArgumentException
class for that purpose.
相关问答
更多-
当您为单元测试创建模拟对象时,它会很有用。 您可以更改__new__方法,以便在某些情况下返回具有与原始相同接口的其他对象(例如模拟原始类实例的行为),而不修改其余代码。 It can be useful when you create mock objects for unit testing. You can change the __new__ method to return, in the certain cases, the the other object with the same inte ...
-
允许方法接受数组(Allow method to accept an array)[2019-12-03]
是! 它叫做“splat”运算符。 它将把剩下的东西带到数组中。 def foo(*args) args.each { |arg| puts arg } end > foo 'baz','boo','bing' baz boo bing Yes! It's call the "splat" operator. It will take whatever is left over in stuff it in an array. def foo(*args) args.each { |arg| ... -
其他答案处理逗号,我将解决方法之间的差异。 当您事先不知道方法名时(在“代码写入”时,由于缺少编译时),您可以使用send调用方法。 或者您知道,但执行“静态”调用会大大增加代码的复杂性(您的情况,使用重复的代码)。 在这种情况下,需要调用动态调用( send )。 Other answers deal with the comma, I'll address the difference between approaches. You invoke methods with send when you d ...
-
typehinting:方法应该接受任何作为对象的$ arg(typehinting: method should accept any $arg that is an object)[2022-10-17]
与Java的Object类不同,PHP 没有对象的基类 。 对象不会继承stdClass :它是默认的对象实现,而不是基类。 所以,不幸的是,你不能在PHP中输入所有对象的提示。 您必须执行以下操作: class MyClass { public function myFunc($object) { if (!is_object($object)) throw new InvalidArgumentException(__CLASS__.'::'.__MET ... -
您可以更改您的功能的签名以包含person def PreSerializer(request, person, *args): if person = "david": ... 或者,如果你可以从args获得人物。 def PreSerializer(request, *args): person = args[0] if person == "david": ... You can either change the signature of ...
-
在这个问题中你没有提到Object doSomething(Class> clazz)方法是abstract T doSomething(Class extends T> clazz)方法的抽象泛型类的实现。 所以实际上你有以下Java类(为了简洁,我重命名为doSomething进行test ): public abstract class AbstractJava
{ protected abstract T test(Class extends T> c); } publi ... -
它不工作,因为. 是一种特殊的形式,并有特殊的评估规则。 正常的函数调用评估它们的参数,但是. 不会评估方法名称参数。 要使其工作,请使用eval或将您的功能更改为宏。 user=> (defmacro foo [o m] `(. ~o ~m)) #'user/foo user=> (foo 123 toString) "123" user=> (defn bar [o m] (eval `(. ~o ~m))) #'user/bar user=> (bar 123 'toString) "123" 通常 ...
-
像这样定义Param : sealed abstract class Param object Param { implicit final class IntParam(val x: Int) extends Param implicit final class StringParam(val x: String) extends Param ... implicit final class SeqParam(val seq: Seq[Param]) extends Param } D ...
-
在jq中增加arg(Increment arg in jq)[2021-10-14]
您可以使用to_entries ,当给定数组时,它将为每个项目提供索引: jq --arg START 10 '($START | tonumber) as $s | [.z[] | select(has("name"))] | to_entries | map({name:.value.name, id: ($s + .key) })' 这样, id从10 + 0到10 + n You can use to_entries, which, when given an array, will ... -
这很简单。 当您向访问者调用accept方法时,您可以提供此附加参数,然后将其传递回访问者的visit方法。 这基本上是一种将一些上下文对象传递给访问者的方式,允许访问者自己保持无状态。 例如,考虑一个您希望收集访问时看到的所有方法名称的情况。 您可以提供Set
作为参数,并将方法名称添加到该集合。 我想这就是它背后的基本原理。 (我个人更喜欢有状态的访客)。 顺便说一句,你通常应该打电话 cu.accept(new MethodVisitor(), null); 而不是相反。 It is ...