首页 \ 问答 \ bootstrap网格 - 3列和2行分成2列和3行(bootstrap grid - 3 columns and 2 rows into 2 columns and 3 rows)

bootstrap网格 - 3列和2行分成2列和3行(bootstrap grid - 3 columns and 2 rows into 2 columns and 3 rows)

嗨,我有典型的引导网格

<div class="row">
<div class="col-sm-4" align="center" style="font-size:150px">A</div>
<div class="col-sm-4" align="center" style="font-size:150px">B</div>
<div class="col-sm-4" align="center" style="font-size:150px">C</div>
</div>
<div class="row">
<div class="col-sm-4" align="center" style="font-size:150px">D</div>
<div class="col-sm-4" align="center" style="font-size:150px">E</div>
<div class="col-sm-4" align="center" style="font-size:150px">F</div>
</div>

在更大或中等的屏幕上显示

A B C
D E F

在一个非常小的屏幕上显示

A
B
C
D
E
F

好了,现在我的问题。 这是否可以在非常小的屏幕上显示最后一列作为最后一列

A B
D E
C F

比你的帮助。


Hi I have typical bootstrap grid

<div class="row">
<div class="col-sm-4" align="center" style="font-size:150px">A</div>
<div class="col-sm-4" align="center" style="font-size:150px">B</div>
<div class="col-sm-4" align="center" style="font-size:150px">C</div>
</div>
<div class="row">
<div class="col-sm-4" align="center" style="font-size:150px">D</div>
<div class="col-sm-4" align="center" style="font-size:150px">E</div>
<div class="col-sm-4" align="center" style="font-size:150px">F</div>
</div>

On a larger or medium screen it shows

A B C
D E F

On a very small screen it shows

A
B
C
D
E
F

Ok now my question. Is this possible to make on very small screen to show last colum as last row

A B
D E
C F

Than you for help.


原文:https://stackoverflow.com/questions/48012731
更新时间:2022-09-18 14:09

最满意答案

我可以想出两种避免警告的方法。 第一种也是最简单的方法是为toResult添加另一个方程式,它捕获所有其他大小的列表并提供信息性错误:

toResult :: [SqlValue] -> IO Course
toResult [ ... ] = do ... --Your existing code goes here
toResult xs      = error $ "toResult: List must contain exactly six values (recieved " ++ length xs ++ ")."

但是如果你的函数只设计为长度为6的列表,我怀疑列表是否真的是这里使用的最佳数据结构。

理想情况下,您的函数类型签名应该让读者很清楚地知道如何使用该函数。 如果您的函数只能接受长度为6的列表,那么它的类型签名将无法与之通信。 我建议选择不具有可变长度的不同数据结构,例如6元组(可能与typenewtype结合使用)或自定义data类型。 这完全消除了基于长度的模式匹配问题,并使您的功能更容易从“外部世界”中理解。

在不了解更多上下文的情况下,我无法确切地知道在您的情况下哪种常量大小的数据结构最合适,但这里有一个简单的示例,希望能够说明我所描述的方法的好处:

--Explicitly hexadic type signature (might benefit from some aliasing)
toResult :: (SQLValue, SQLValue, SQLValue, SQLValue, SQLValue, SQLValue) -> IO Course
toResult ( fromSql -> courseid, fromSql -> title,
           fromSql -> name,     fromSql -> version,
           fromSql -> cdate,    fromSql -> fid ) = do ...
--No need for separate equations due to constant-size container

不幸的是,如果你无法从这种情况中完全删除List类型,那么所有这一切都会将问题转移到其他地方,因为你最终需要第二个函数来从List转换为元组。 这些类型的功能总是难看并且难以使用。

在编译时,GHC无法保证满足要​​求(即,正好传递六个值)这一事实是不可能的。 即使你100%表示quickQuery会返回一个包含六个元素的列表(你真的,完全地,在数学上确定这一点吗?),你仍然必须考虑到这种情况的逻辑可能性。 这意味着您必须在运行时提供一种处理此案例的方法。

那么,当传递多于或少于六个值时,您想要做什么? 如何在您的程序中实现错误处理? 这是一个使用error的潜在天真的例子:

sixValues :: [SQLValue] -> 
             (SQLValue, SQLValue, SQLValue, SQLValue, SQLValue, SQLValue)
sixValues [a,b,c,d,e,f] = (a,b,c,d,e,f)
sixValues xs            = error "Wrong number of values"

虽然没有比我的第一个建议好多少,但这至少具有将长度处理逻辑与结果生成逻辑分开的优点。


I appreciate the input and learning that I have received from this experience. However, I have progressed from a working function that issued a compile-time warning that I was comfortable ignoring to a compile error that prevents building the output executable.

I have incorporated a couple of the suggestions from this thread, but have basically gone back to my original warning about a non-exhaustive pattern match. It seems, in the end, that there is an irreconcilable incongruity between executing a database query that always returns a list of the same number of elements and then using that list as, or converting that list to, a fixed-size collection.

Every language has its quirks. Maybe this is one for Haskell.

Thanks for all the input and guidance.

Dave Smith

相关问答

更多
  • 你的第二行有lastButone ,但你的意思是lastButOne 。 哎呦! :) You have lastButone on your second line but you mean lastButOne. Whoops! :)
  • 我可以想出两种避免警告的方法。 第一种也是最简单的方法是为toResult添加另一个方程式,它捕获所有其他大小的列表并提供信息性错误: toResult :: [SqlValue] -> IO Course toResult [ ... ] = do ... --Your existing code goes here toResult xs = error $ "toResult: List must contain exactly six values (recieved " ++ lengt ...
  • 问题是你定义了两个子句: 一个空列表 cwords "" = 0 还有一个列表至少包含两个元素: cwords (a:b:c) = ... 所以Haskell说,如果字符串只包含一个字符,它就不知道该做什么,因为没有子句指定在这种情况下要做什么。 既然你数了单词,如果我们获得最后一个字符,我们应该把它算作一个单词(因为它是一个字母字符)。 所以代码应该是这样的: cwords :: String -> Int cwords "" = 0 cwords (a:b:c) |isAlpha a && ...
  • 问题正是因为type Nodo = String的定义。 由于String本身是Char的列表,这意味着当你拥有模式时 buscaNodo _ [] = False 这相当于 buscaNodo _ "" = False 你实际上匹配空字符串。 您可能想要的是切换这些参数: buscaNodo [] _ = False 查找空列表中的任何元素( _ )将始终返回False 。 您还可以使用Haskell附带的内置函数大大简化此定义: buscaNodo :: [(Nodo, Peso)] -> Nod ...
  • 模式匹配失败例外是PatternMatchFail类型。 基本异常都在Control.Exception中定义。 下面是使用Control.Exception.catch来捕捉你所谈论的类型的模式匹配失败。 在这里,我的操作和处理函数都是IO ()类型,但是你可以做任何你想要的 - 如果操作是IO Int那么异常处理程序可以返回一个默认的IO Int 。 {-# LANGUAGE ScopedTypeVariables #-} import Control.Exception as X func = X. ...
  • GHC根本不知道a > b , a < b或a == b必须评估为True 。 (事实上,编写一个违反这个假设的Ord实例是可能的 - 尽管大多数程序员不会考虑这样做,当然Int实例在这方面会表现得很好。) 你可以很明显地看到,GHC已经通过使用完整的模式匹配来覆盖所有的情况,例如 respond correct guess = case compare guess correct of GT -> ... LT -> ... EQ -> ... GHC在其严格性检查器中也有特殊情 ...
  • 你的第二个let定义一个新的double 。 您可以像这样在GHCi中定义多行功能。 λ :{ | let | double :: Num a => [a] -> [a] | double [] = [] | double (x:xs) = 2 * x : double xs | :} λ double [1,2,3] [2,4,6] 请注意,这相当于map (2*) 。 Your second let is defining a new double. You can define multi-line ...
  • 正如人们在评论中指出的那样,GHCi 8的单行定义取代了之前的定义。 如果您想输入多模式定义,则需要使用特殊的:{和:}代码来启动和结束多行命令。 所以,以下工作正常: Prelude> :{ Prelude| fact 0 = 1 Prelude| fact n = n * fact (n-1) Prelude| :} Prelude> fact 10 3628800 Prelude> (请注意,这仅适用于GHCi 8,不适用于7.) 另外,请介意您的定义中的顺序。 在Haskell中,模式的顺序很重 ...
  • 问题是您的模式只匹配一个元素的列表。 例如,如果您尝试在ghci定义函数: a [x] = x 然后尝试使用具有不同数量元素的列表来调用它: a [1]结果为1 a []结果为Exception: :5:1-13: Non-exhaustive patterns in function a a [1,2]结果为Exception: :1:1-9: Non-exhaustive patterns in function a 以下修改使您的功能工作: sum ...
  • 你没有包含一个定义,当你插入的树是Nil时会发生什么,大概看起来像 genTree x Nil = singleton x 你试图用这条线做到这一点 genTree x (Node e l r) = if (Node e l r == Nil) then singleton x else ... 但如果你考虑一下,你会发现它无法奏效。 模式匹配确保您正在查看的树的形式为Node _ _ _ ,因此它永远不会为Nil 。 也就是说, if表达式中的测试总是计算为False 。 You ha ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。