如何在bootstrap中计算推/拉顺序单元?(How I can calculate push/pull order cell in bootstrap?)
我尝试命令单元格像图像,这个引导代码是这样做的,但我仍然尝试和测试得到这个顺序,有没有办法计算网格中每个col的推或拉。
我的问题用另一种方式,我需要订购单元格,我可以打印像图像的单元格,即时尝试和测试许多值拉/推得到这个代码..有没有办法计算价值?
<div class="row row-4"> <div class="col-xs-3 col-md-push-9">5</div> <div class="col-xs-4 col-md-push-2">4</div> <div class="col-xs-1 col-md-pull-3">3</div> <div class="col-xs-3 col-md-pull-7">2</div> <div class="col-xs-1 col-md-pull-11">1</div> </div>
Im try to order cell like image, and this bootstrap code are do that, but Im still try & test to get this order, is there any way to calculate push or pull for each col in grid .
my question with another way, I need to order cell, to i can print a cell like image, im try & test many of value for pull/push to get this code ..is there way to calculate value?
<div class="row row-4"> <div class="col-xs-3 col-md-push-9">5</div> <div class="col-xs-4 col-md-push-2">4</div> <div class="col-xs-1 col-md-pull-3">3</div> <div class="col-xs-3 col-md-pull-7">2</div> <div class="col-xs-1 col-md-pull-11">1</div> </div>
原文:https://stackoverflow.com/questions/26337132
最满意答案
这只是一个猜测,但这是我认为发生的事情:
- 当您宣布
Superhero
,您声明name
和power
应该具有相同的生命周期。r
的类型被推断为&String
(或者可能是&str
,点是r
是引用)。 在词汇生命周期中,r
必须存活到声明它的块的末尾,所以直到第14行。- 因为你影响了
hero.name
到r
,hero.name
应该至少与r
一样长,因此hero.name
应该存在直到第14行。- 由于
hero.name
和hero.power
应该具有相同的结构声明生命周期,因此hero.power
也应该存在直到第14行。- 由于
hero.power
借用了p
,p
应该一直存在到第14行,但它只能存在到声明它的块的末尾(第13行)。它适用于非词汇生命周期的原因是因为编译器注意到你没有在第12行之后使用
r
,因此能够相应地缩短生命周期。 请注意, 如果在第13行的右括号后使用r
, 它甚至不能用于nll 。This is only a guess, but here is what I think happens:
- When you declared
Superhero
, you stated thatname
andpower
should have the same lifetime.- The type for
r
is inferred as&String
(or maybe&str
, the point is thatr
is a reference). With lexical lifetimes,r
must live until the end of the block in which it is declared, so until line 14.- Since you affect
hero.name
tor
,hero.name
should live at least as long asr
, thereforehero.name
should live until line 14.- Since
hero.name
andhero.power
should have the same lifetime per the struct declaration,hero.power
should also live until line 14.- Since
hero.power
borrowsp
,p
should live until line 14, but it only lives until the end of the block in which it is declared (line 13).The reason it works with non-lexical lifetimes is because the compiler notices that you don't use
r
after line 12 and is therefore able to shorten the lifetimes accordingly. Note that it doesn't work even with nll if you user
after the closing brace of line 13.
相关问答
更多-
Long Live Paper求翻译[2024-04-08]
《书香永留存》 这是美国作家Justin. B的一篇文章,针对当时邓肯部长提出的淘汰纸质教科书观点进行评判。 文章内容是“身处E时代,莫忘纸张香”。 下面是详细参考,我没有360文库账号不嗯能够复制,你自己看吧。 http://www.360doc.com/content/12/1016/17/5707568_241854668.shtml 原文及译文如下: long live paper by justin b. hollander october 16, 2012 medford, mass. last ... -
你是正确的,你不能返回一个比MutexGuard东西的MutexGuard ,因为这会导致一个可能悬空的指针。 但是,将内容包装在Box无济于事! Box是一个拥有的指针,除了参考生命周期之外,重定向的行为类似于包含的值。 毕竟,如果您返回对它的引用,其他人可能会从HashMap删除它并取消分配它。 根据您对参考的要求,我可以考虑几个选项: 而不是Box值,将它们包装在Arc 。 从HashMap获取时,您将克隆Arc ,并且多个引用可以同时存在。 您也可以将MutexGuard与参考一起返回; 看到这个问 ...
-
借用的值不够长 - 字符串切片到HashMap(Borrowed value does not live long enough - string slice into HashMap)[2022-09-04]
字符串需要所有者: fn lyrics_more_bottles(song_template:&mut String, number:i32){ let mut start_bottles = format!("{} bottles", number); // own them as `String` let mut remaining_num = format!("{} bottles", number); let mut template_partials:HashMap<&st ... -
盒装价值不够长(Boxed value does not live long enough)[2022-06-30]
我想你错过了Rust的一些关键细节; 有三件事我认为需要处理: 模式如何工作; 不可变( & )和可变( &mut )引用之间的区别; Rust的所有权模式如何工作(因为您的&*box尝试)。 我将首先处理模式部分; 在fn add(mut list: &List, x: uint) ,有两种模式正在使用, mut list和x 。 模式的其他例子是let lhs = rhs;的左侧let lhs = rhs; 以及match表达式的每个分支上的=>之前的位。 这些模式如何有效地应用于通话? 这真的像你这样 ... -
我认为虽然盒子内部的价值确实存在的时间与'a'一样长,因为它是Foo的成员,具有完全相同的生命周期。 可以为derp成员分配一个新框,此时旧框将被删除,并且其中的值的生命周期结束。 我认为你想要做的事情在安全的Rust中是不可能的:不支持struct成员之间的交叉引用。 这经常作为一个问题出现,但它只是在语言中没有。 如何初始化相互引用的struct字段 为什么我不能在同一个结构中存储值和对该值的引用? 您可以使用Rc解决此问题,可能与RefCell结合使用。 I think though that the ...
-
您正在复制输入&str : let get_string = String::from(get_string); 该副本由函数拥有,并在函数完成时被删除,但您也返回一个包含对它的引用的HashMap 。 应该清楚为什么这不起作用。 删除那一行实际上将修复错误,因为您将引用该函数的参数。 You are copying the input &str here: let get_string = String::from(get_string); This copy is owned by the func ...
-
这只是一个猜测,但这是我认为发生的事情: 当您宣布Superhero ,您声明name和power应该具有相同的生命周期。 r的类型被推断为&String (或者可能是&str ,点是r是引用)。 在词汇生命周期中, r必须存活到声明它的块的末尾,所以直到第14行。 因为你影响了hero.name到r , hero.name应该至少与r一样长,因此hero.name应该存在直到第14行。 由于hero.name和hero.power应该具有相同的结构声明生命周期,因此hero.power也应该存在直到第14 ...
-
因为Path::new(&x)返回一个&Path ,它从x借用它的内容。 Some(s) => Some(Path::new(&s.clone())), // Type is Option<&Path> // reborrow --------------^ 你真正想要做的是使用PathBuf (相当于Path )。 PathBuf将取得s所有权而不是借用它。 let cfgFilePath = match matches.opt_str("c") { Some(s) => Some(PathBu ...
-
如何返回一个“拥有不够长寿”的拥有值的指针?(How to return a pointer to owned value that “does not live long enough”?)[2022-07-21]
这就是为什么你不能返回&node : fn create_node(&mut self) -> &Node { let index = self.nodes.len(); let node = Node { id: index }; println!("{}", &node as *const Node); self.nodes.push(node); println!("{}", &self.nodes[index] as *const Node); ret ... -
这看起来就像生活中的缺陷使事情变得不那么明显的情况之一。 这是Builder::new的原型 : pub fn new(context: &Context) -> CSemiBox
这可能会让您认为CSemiBox与context的生命周期没有任何关系。 但是CSemiBox的定义有一个生命周期参数: pub struct CSemiBox<'a, D> 据我了解,当函数的输出类型(在本例中为Builder::new )具有生命周期参数时,如果只有一个输入生命周期,则可以省略它。 (生 ...