I'm creating a custom carousel for my current project. Here's a simplified version (only tested in Chrome/Mac):

我正在为我当前的项目创建一个自定义轮播。这是一个简化版本(仅在Chrome / Mac中测试过):

http://codepen.io/troywarr/pen/LpQzbv

Note that when the carousel scrolls, you can see that each page (1-5) butts up flush against its neighbor on the left and right sides (looking like a single double-thick border). I'd like to add a 5px-wide gutter between the left and right borders of each page so that the borders don't touch.

请注意,当轮播滚动时,您可以看到每个页面(1-5)与左侧和右侧的邻居齐平(看起来像一个双厚边框)。我想在每个页面的左右边框之间添加一个5px宽的装订线,这样边框就不会碰到。

However, since this is a fluid-width carousel, this has proven to be more difficult than expected.

然而,由于这是一个流体宽度的转盘,事实证明这比预期的要困难得多。

I need to support IE9+, so I can't rely on calc() values or CSS animations; I'd probably need to do this via jQuery .animate(), but when the horizontal position to which I'm animating is basically 100% + 5px, I can't figure out how to express that in code.

我需要支持IE9 +,所以我不能依赖calc()值或CSS动画;我可能需要通过jQuery .animate()来做这件事,但是当我动画的水平位置基本上是100%+ 5px时,我无法弄清楚如何在代码中表达它。

How would I go about that? Is there, perhaps, another clever way to set up the carousel that allows me to use margins, padding, table cell padding, etc. to my benefit? Or, any other ideas? I've played around with different approaches for a couple of hours and I'm running out of ideas.

我该怎么办呢?是否有另一种聪明的方法来设置旋转木马,允许我使用边距,填充,表格细胞填充等,以造福我?或者,还有其他想法吗?我已经玩了几个小时不同的方法,我的想法已经不多了。


UPDATE:

Just to clarify what I mean by "gutter" - I'd like there to be a 5px empty gap between the left and right sides of each page in the carousel. Each page should retain its own borders, but there should be empty whitespace between them (only noticeable on scroll). Here's an example that uses calc() and CSS transitions to do exactly what I want (only tested in Chrome):

只是为了澄清“阴沟”的意思 - 我希望旋转木马中每页的左右两侧之间有5px的空隙。每个页面都应保留自己的边框,但它们之间应该有空白空格(仅在滚动时才会显着)。这是一个使用calc()和CSS转换来完成我想要的(仅在Chrome中测试)的示例:

http://codepen.io/troywarr/pen/GpQYPj

I just need to find a comparable solution that is compatible with IE9+ (which calc() and CSS animations are not).

我只需要找到一个与IE9 +兼容的类似解决方案(其中calc()和CSS动画不兼容)。

1 个解决方案

#1


0

Applying border-box to everything will allow you to add paddings without breaking the layout.

将边框应用于所有内容将允许您添加填充而不会破坏布局。

// See an explanation here:
// http://www.paulirish.com/2012/box-sizing-border-box-ftw/
html {
   box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

EDIT:

Sorry, you were already doing this. Here is my take on it:

对不起,你已经这样做了。这是我的看法:

.window {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    // Add these two rules
    // The idea is to make a static frame, except for the right column
    // which is the one being repainted.
    border: 5px solid #666;
    border-right: 0;
}

...

.slider li {
    float: left;
    width: 20%;
    height: 100%;
    background-color: #ccc;
    display: table;
    border-right: 5px solid #666; // <- Paint the right column only
 }

更多相关文章

  1. 在页面问题内的Phonegap垂直滚动
  2. Ajax php登录表单不指向另一个页面
  3. jquery编写web页面头部分类的选中事件$.cookie("currentIndex",
  4. 页面加载后的JQuery(窗口).load?
  5. 禁用焦点上的锚点()元素上的灰色边框
  6. JQuery滚动条插件jScrollPane的详细使用(除去点击边框)
  7. 静态h5页面没有后台直接访问本地json文件
  8. jquery刷新iframe页面的方法
  9. Jquery---定时器(实现页面内定时弹出广告,定时退出)

随机推荐

  1. Selenium自动化|爬取公众号全部文章,就是这
  2. Python办公自动化|自动更新表格,告别繁琐
  3. 收藏| Scrapy框架各组件详细设置
  4. 迭代学习 重视复盘——我的PMP备考之路(下
  5. 备战520|Python花式表白的几种姿势
  6. 动画:“栈”的那点破事
  7. 刚接触Python,这么多IDE我该怎么选
  8. NumPy进阶修炼|基础操作与运算
  9. 面试必知必会|堆和优先队列
  10. 童年的游戏,Python一行代码就能玩