简体   繁体   English

使用线性渐变CSS将html Div除以12列

[英]Divide html Div in to 12 Column using linear-gradient CSS

I want to divide Div in to 12 equal column using CSS linear-grediant. 我想使用CSS linear-grediant将Div分成12个相等的列。 IT needs to work on IE, Chrome and FF IT需要在IE,Chrome和FF上运行

I am facing issue on IE browser and Chrome browser. 我在IE浏览器和Chrome浏览器上面临问题。

  1. Chrome browser showing some extra space after 12 Column on window resize. Chrome浏览器在窗口调整大小的12列后显示一些额外空间。
  2. IE not showing Grid Lines on Window Resize if use background-repeat: round and window size is less than 900 px IE如果使用background-repeat,则不显示窗口上的网格线大小:圆形和窗口大小小于900像素
  3. IE showing only 11 Column if user background-repeat: space 如果用户background-repeat:space,IE仅显示11列

HTML Code HTML代码

 .grid-lines { background-size: 8.3469%;/*8.39*/ background-image: linear-gradient(to left, #EECBCB 1px, transparent 1px); background-image: -webkit-linear-gradient(left, #EECBCB 1px, transparent 1px); background-image: -moz-linear-gradient(to left, #EECBCB 1px, transparent 1px); background-image: -o-linear-gradient(to left, #EECBCB 1px, transparent 1px); background-color: white; background-repeat: round; //background-repeat: space; } 
 <div style="width:100%;height:100px" class="grid-lines"> </div> 

here is my Code https://jsfiddle.net/07eaht8L/3/ 这是我的代码https://jsfiddle.net/07eaht8L/3/

Thanks In Advance... 提前致谢...

If you change 1px to 0.07em (the lowest IE seems to accept), it will stop the disappearing/flickering on Window Resize. 如果您将1px更改为0.07em(最低IE似乎接受),它将停止Window Resize上消失/闪烁。

https://jsfiddle.net/0n55p0p2/ https://jsfiddle.net/0n55p0p2/

background-image: linear-gradient(to left, #EECBCB 0.07em, transparent 0.07em);

This is not a perfect solution, as 0.0625em = 1px, but I cannot see the difference in a side by side comparison. 这不是一个完美的解决方案,因为0.0625em = 1px,但我看不出并排比较的差异。 However, it might be a subpixel rendering issue with IE and this bit of extra width stops it from disappearing. 但是,它可能是IE的子像素渲染问题,这个额外的宽度阻止它消失。

I have tried transform, scaling, anti-aliasing but it does not work for gradient. 我尝试过变换,缩放,抗锯齿,但它不适用于渐变。

To Remove Extra Space in Chrome 删除Chrome中的额外空间

I think it's a percentage bug in WebKit calculating subpixels. 我认为这是WebKit计算子像素的百分比错误。

You could create a media query that changes the width % in Chrome WebKit only. 您可以创建仅在Chrome WebKit中更改宽度%的媒体查询。 The space changes when browser is scaled. 缩放浏览器时空间会发生变化。 I have picked % and resolution values that counter the extra space. 我选择了%和分辨率值来抵消额外的空间。 Change the values to what you think works best. 将值更改为您认为最佳的值。

And do not use background-repeat: round or space. 并且不要使用background-repeat:round或space。

https://jsfiddle.net/frpfgp16/ https://jsfiddle.net/frpfgp16/

@media (max-width: 720px) {
  .grid-lines {
      -webkit-background-size: 8.5% !important;
  }
}
@media (min-width: 721px) {
  .grid-lines {
      -webkit-background-size: 8.39% !important;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM