- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
有谁知道偏移前两个 div
是在侧行中具有类 col-3-12
的偏移量 offset -6-12
和 offset-9-12
位于我的网格系统的右侧 jsFiddle
CSS:
body {
font:20px/1.2 Verdana, Arial; padding:0px; margin:0px;
}
*, *:after, *:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing:border-box;
}
.container {
padding: 20px 20px 0 20px; background-color: red
}
.row {
padding: 0;
*zoom: 1;
}
.row:after, .row:before {
content: ' ';
display: table;
}
.row:after {
clear: both;
}
.row > [class*='col-']:first-child {
margin-left: 0;
}
.row > [class*='col-']:last-child {
margin-right: 0;
}
.row > [class*='col-'] {
/* edit here*/
margin:0px 10px 20px 10px
}
[class*="col-"] {
float:left;
height:300px;
background-color: #dedede;
border: 1px solid #000;
}
[class*=col-]:last-of-type {
}
.col-1-12 {
width: calc((100% - (12/1 - 1) * 20px) / 12 * 1);
}
.col-2-12 {
width: calc((100% - (12/2 - 1) * 20px) / 12 * 2);
}
.col-3-12 {
width: calc((100% - (12/3 - 1) * 20px) / 12 * 3);
}
.col-4-12 {
width: calc((100% - (12/4 - 1) * 20px) / 12 * 4);
}
HTML:
<div class="container">
<div class="row">
<div class="col-3-12 offset-6-12">
Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="col-3-12 offse-9-12">
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>
<div class="row">
<div class="col-3-12">
Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="col-3-12">
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
<div class="col-4-12">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="col-2-12">
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>
</div>
最佳答案
好吧,对于偏移量,您需要对 float 列应用左边距以将它们推到右侧。
margin-left
的值等于:
对于本身没有左边距的第一列:width
的 previous columns + the gutter width
.
对于第二列(其他列):
如果列有左/右 margin
(创建排水沟):width
的 previous columns
+ the gutter width
+ 1/2 gutter width
. (因为列的左/右 margin
是装订线宽度的 1/2)
如果列没有margin-left
(即装订线仅由 margin-right
创建):width
的 previous columns
+ the gutter width
.
例如:
.offest-6
的左边距如下:.row [class*="col-"]:first-child.offest-6-12 {
margin-left: calc(((100% - (12/6 - 1) * 20px) / 12 * 6 ) + 20px);
/* | width of col-6-12 | + gutter width */
}
注意:我在这里使用了多个选择器以获得更高的 specificity value .
另请注意,由于列彼此相邻 float ,因此您只需要使用 .offset-*
第一列的类将它们都推到右侧。
因为列有左(和右)边距(等于 1/2 的装订线 = 10px
)
.row [class*="col-"].offest-6-12 {
margin-left: calc(((100% - (12/6 - 1) * 20px) / 12 * 6 ) + 20px + 10px);
/* | width of col-6-12 | + (1 + 1/2) gutter width */
}
UPDATED DEMO 。 (时髦的方式: Sass version )
对于第二列,您应该使用 offset-6
因为还有一个col-3
当前列之前的列。
即您应该计算列数,包括偏移量。
例如:col-3
+ col-3 including offset-6
= 12 columns
.如果您添加更多列,则会中断流程,因为它超过了连续 12 列的限制。
How can we change the code in my CSS to compensate for that
30px
on the end of thecalc()
function, can there be something in the CSS that's in there to make it work without the30px
. so it can calculate by the20px
gutter instead of that30px
现在列的左右边距为 10px
这创建了 20px
排水沟。这就是添加额外 10px
的原因到排水沟宽度以进行偏移。
我们可以使用 margin-right: 20px
对于列而不是左侧和右侧的两个边距(最后一列没有边距)。在这种情况下,我们不需要添加额外的 10px
.
关于html - 如何在 CSS 网格系统中偏移 div 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22246270/
我正在尝试从第 4 到 9 页以及第 12 和 13 页上的单元格中清除所有内容(包括图像)。我有以下代码,但它正在清除第 3-9 和 12-15 页中的内容,我不知道为什么。 有什么想法吗? Sub
有没有办法增加极坐标图刻度标签(θ)的填充/偏移? import matplotlib import numpy as np from matplotlib.pyplot import figure,
我正在调用本地 API 并尝试以分页 样式进行操作。我有 n 张图片,我想将它们分成 n/4 行(每行 4 张图片)。因此,我正在调用我的 API,images/count,offset。但不知何故,
我的问题解释起来有点棘手,但无论如何我都会尝试。我有两个水平选项卡,当您单击它们时,会打开一个文本框内容。当他们被点击时,我试图“关注”他们。我在网上找到了很多资料,但除了我在下面显示的这段代码外,没
所以我有一个 float 的 div,我需要它始终向右 200 像素,并填充窗口的其余部分。有没有某种跨浏览器兼容的方法,我可以在不借助 javascript 的情况下使宽度填满页面的其余部分? 最佳
我有以下片段 $('html,body').animate({scrollTop: $('#menu').offset().top}, 'slow'); 单击链接时,我希望浏览器从#menu div
我目前正在为我的应用程序使用 JASidePanel,并且我有一个 UITableViewcontroller 和一个 UIRefreshControl 作为它的 ViewController 之一。
给出以下代码: imshow(np.arange(16*16).reshape(16,16)) cb = colorbar() cb.set_label("Foo") cb.set_ticks([0,
我是编程新手,我认为 VBA 是一个很好的起点,因为我在 Excel 中做了很多工作。 我创建了一个宏,它从输入框中获取一个整数(我一直使用 2、3 和 4 来测试),并创建该数字的一组 4 层层次结
我在 PHP 中有一个 unix 时间戳: $timestamp = 1346300336; 然后我有一个我想要应用的时区的偏移量。基本上,我想应用偏移量并返回一个新的 unix 时间戳。偏移量遵循这
演示:http://jsfiddle.net/H45uY/6/ 我在这里想做的是将 的左上角设为跟随鼠标。代码在没有段落的情况下工作正常(请参阅上面的演示),但是当您添加段落时,被向上推,鼠标位于盒
假设我们有两个由无符号长(64 位)数组表示的位图。我想使用特定的移位(偏移)合并这两个位图。例如,将位图 1(较大)合并到位图 2(较小)中,起始偏移量为 3。偏移量 3 表示位图 1 的第 3 位
通过在 pageViewController 中实现 tableView,tableView 与其显示的内容不一致。对此最好的解决办法是什么? 最佳答案 如果您的 TableView 是 View C
我设置了一个在 nib 中显示地点信息的地点配置文件。当我在标准屏幕流程中推送此 View 时,它工作正常。但是,当我从另一个选项卡推送此 View 时,UINavigationBar 似乎抵消了它,
如果我想选择 5 条记录,我会这样做: SELECT * FROM mytable LIMIT 5 如果我想添加偏移量,我会这样做: SELECT * FROM mytable OFFSET 5 LI
我有一个应用程序,其中某些 View 需要全屏,而其他 View 不需要全屏。在某些情况下,我希望背景显示在状态栏下方,所以我在 View 加载时使用它来使 Activity 全屏显示: window
在下图中,我进行绘制,结果位于 A 点,就在我手指接触的地方。 如何使图像显示在实际触摸上方约 40pt。 (二) 我正在使用经典的 coreGraphic UITouch 代码,如下所示: - (v
只要键盘处于事件状态,我就会尝试偏移 UITextField,效果很好,直到我尝试了表情符号布局。有没有办法检测键盘输入的类型,以便找出高度差?谢谢 最佳答案 不是使用 UIKeyboardDidSh
这是我的 Swift 代码 (AppDelegate.swift): var window: UIWindow? var rootViewController :UIViewController? f
我有一个 div 作为绝对定位的 body 的直接子节点,其 css 属性定义如下: div[id^="Container"] { display: block; position: a
我是一名优秀的程序员,十分优秀!