首页 \ 问答 \ Float divs到两边(Float divs to both sides)

Float divs到两边(Float divs to both sides)

假设我有一堆div,它们有“左”类或“右”类。 是否有可能使这些div在容器的两侧浮动,就像有一列“left”div和一列“right”divs一个在另一个下方对齐。 div的顺序是随机的。

我不是在寻找双栏布局。 ;)


Let's say I have a bunch of divs which have either "left" class or "right" class. Is it possible to make these divs to float on both sides of container like there was a column of "left" divs and a column of "right" divs aligned one under another. Order of divs is random.

I'm not looking for two-column-layout. ;)


原文:https://stackoverflow.com/questions/7751476
更新时间:2022-01-07 15:01

最满意答案

你需要将你的StructField集合作为Seq传递。

像以下任何一项工作:

val customSchema = StructType(Seq(StructField("user_id", IntegerType, true), StructField("item_id", IntegerType, true), StructField("artist_id", IntegerType, true), StructField("scrobble_time", StringType, true)))

val customSchema = (new StructType)
  .add("user_id", IntegerType, true)
  .add("item_id", IntegerType, true)
  .add("artist_id", IntegerType, true)
  .add("scrobble_time", StringType, true)

val customSchema = StructType(StructField("user_id", IntegerType, true) :: StructField("item_id", IntegerType, true) :: StructField("artist_id", IntegerType, true) :: StructField("scrobble_time", StringType, true) :: Nil)

我不确定为什么它不会在README上显示,但是如果你检查StructType文档,那么它就清楚了。


You need to pass your set of StructField's as a Seq.

Something like any of the following works:

val customSchema = StructType(Seq(StructField("user_id", IntegerType, true), StructField("item_id", IntegerType, true), StructField("artist_id", IntegerType, true), StructField("scrobble_time", StringType, true)))

val customSchema = (new StructType)
  .add("user_id", IntegerType, true)
  .add("item_id", IntegerType, true)
  .add("artist_id", IntegerType, true)
  .add("scrobble_time", StringType, true)

val customSchema = StructType(StructField("user_id", IntegerType, true) :: StructField("item_id", IntegerType, true) :: StructField("artist_id", IntegerType, true) :: StructField("scrobble_time", StringType, true) :: Nil)

I'm not sure why it's not presented as this on the README, but if you check the StructType documentation, it's clear about this.

相关问答

更多