如何使CSS3列显示在IE9中工作

时间:2017-01-24 17:34:41

标签: css css3 internet-explorer-9 css-multicolumn-layout

这适用于FF / Chrome / Opera和IE 10+,但不适用于IE9;我正在寻找IE9解决方案

以下CSS将使一组div,span或p标签自组织成可以水平滚动的整齐列(仅适用于支持WebKit的浏览器)。

-webkit-column-fill: auto;
-webkit-column-width: 300px;
-webkit-column-gap: 40px;
-moz-column-fill: auto;
-moz-column-width: 300px;
-moz-column-gap: 40px;

以下是示例:



$(document).ready(function() {


  $(".RightArrow ").click(function() {
    $(".columns").animate({
      scrollLeft: '+=500'
    }, 100);
  });

  $(".LeftArrow ").click(function() {
    $(".columns").animate({
      scrollLeft: '-=500'
    }, 100);
  });



}); //end script

body {
  font-family: arial;
}
.columns {
  overflow: hidden;
  width: 500px;
  border: 1px solid #000;
  -webkit-column-fill: auto;
  -webkit-column-width: 300px;
  -webkit-column-gap: 40px;
  -moz-column-fill: auto;
  -moz-column-width: 300px;
  -moz-column-gap: 40px;
  padding: 0 20px;
  text-align: left;
  height: 500px;
  overflow: hidden;
  position: relative;
}
.notsectable {
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: -moz-none;
  -o-user-select: none;
  user-select: none;
}
.arrows {
  width: 500px;
}
.RightArrow {
  float: right;
  cursor: pointer;
}
.LeftArrow {
  float: left;
  cursor: pointer;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="columns">



  <p>
    <a class="">

      <h2>
<span class="">1</span>
NUM 1
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>


  <p>
    <a class="">

      <h2>
<span class="">2</span>
NUM 2
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>

  <p>
    <a class="">

      <h2>
<span class="">3</span>
NUM 3
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>



  <p>
    <a class="">

      <h2>
<span class="">4</span>
NUM 4
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>


  <p>
    <a class="">

      <h2>
<span class="">5</span>
NUM 5
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>

  <p>
    <a class="">

      <h2>
<span class="">6</span>
NUM 6
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>

</div>
<!--columns-->


<div class="arrows">


  <span class="LeftArrow"> Previose </span>  <span class="RightArrow">  Next </span>
</div>
&#13;
&#13;
&#13;

https://jsfiddle.net/n5qh89vw/

我希望它以这种方式工作的原因是我从DB直接输出到<div>的列表中我希望避免使其变得更复杂并且必须使输出计数为然后,数据项的数量将标记形成为内联div或表格(如x数字单元格中的y列将包含4行),因为我希望尽可能简单。

有没有办法让这个与IE一起工作?

2 个答案:

答案 0 :(得分:6)

根据Can I Use,IE 10+支持多列布局。如果您需要支持旧版本的IE,则有一个CSS multicolumn polyfill(可以在我可以使用的资源选项卡中找到)。

现在您已经更新了问题以指定IE9需要这个,这是使用Adam Wulf's Columnizer jQuery Plugin的完整示例:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script type="text/javascript" src="/path-to-local-file/jquery.columnizer.min.js"></script>
        <script>
            $(function(){
                $('.wide').columnize({width:400});
                $('.thin').columnize({width:200});
            });
        </script>

    <style>
        .column p, .column h1{ padding: 5px; }
        body { font-size: 9pt; }
        #wrapper { margin: 0px 100px; }
        .wide, .thin { clear:both; }
    </style>

</head>
<body>
    <div id="wrapper">
        <div class="wide">
            <h1>Lorem ipsum ne justo</h1>
            <p>Bonorum has. His ut cibo quas tantas, vis ut probo adhuc definiebas, has at meis debet vulputate. No sed velit essent suavitate, in pro decore ceteros temporibus, usu in odio offendit theophrastus. Mel labore indoctum cu, ad soleat admodum delicatissimi sed, mei viris tritani ullamcorper eu. Ut vim simul aperiam.</p>
            <p>Eu eleifend repudiandae has. Mea eu ridens aliquam. Nisl aeque sit ut, posse dolor utinam cum in. Ad timeam sapientem eos, et eripuit inermis nam. Eos integre voluptaria ne, iriure concludaturque ut eum.</p>
            <p>Vis erant intellegat in. Soleat legere no ius, usu ex laoreet molestie. Sit eu sint inermis. Ea zzril scribentur pro.</p>
            <h1>Tempor essent appetere</h1>
            <p>Ius mutat commune expetendis in. Nam et quas sensibus reprimique, vix no erat soluta suavitate. At mel eius dictas latine. Corrumpit inciderint reformidans sed no, no usu omnis utinam noluisse.</p>
            <p>Sit et, an ius nihil apeirian. Eu posse tempor iuvaret cum. No diam dolor sea, postea mnesarchum ne ius, vel no utinam ignota dolores. Malis suscipit accusamus his ne, utinam assentior prodesset ea eam, facer partem antiopam et cum.</p>
            <p>Probo debet quaestio an eos, no mel assum iracundia delicatissimi, rebum facete utroque sed ex. Eu melius invidunt repudiandae vix, eu paulo reformidans deterruisset duo, solum voluptaria efficiantur ea mel. Qui summo zzril alienum et. Eu est ferri iuvaret, mazim epicurei sententiae ut cum, modo reque intellegat ex vix. Vim eu tibique accusamus, quot electram at qui.</p>
            <p>Ex iisque eleifend periculis has. Sit aeterno virtute partiendo ei, eam nonumy bonorum adolescens ad. Ut nec suas vocent ornatus, cetero legendos constituam mea ea, pri cu delenit iracundia. Mundi decore nec te.</p>
            <h1>Soleat civibus in pri</h1>
            <p>In petentium erroribus percipitur per. Takimata accommodare ius ut, eam no postulant urbanitas. Qui ei tantas consectetuer, quis dictas euripidis duo ei. Quaeque democritum concludaturque has ne.</p>
            <p>Blandit insolens constituto vix an. Has diam wisi in, eum unum repudiare no. Sit at virtute rationibus, qui vitae explicari cu. Vim ne singulis voluptatum, sed puto accusata salutandi ei. Ad mel civibus adversarium.</p>
            <p>Per ne solum vivendo, fabulas dolorem vivendo in pro. Nec duis ignota cotidieque no, an per possit nostrum. Pro detraxit definitionem eu. Vivendo officiis no nam, eu has reque maiestatis percipitur, dolore reprimique accommodare cum ad. No utinam voluptua oportere pri, augue sonet dicant ei sea.</p>
            <p>Sit et, an ius nihil apeirian. Eu posse tempor iuvaret cum. No diam dolor sea, postea mnesarchum ne ius, vel no utinam ignota dolores. Malis suscipit accusamus his ne, utinam assentior prodesset ea eam, facer partem antiopam et cum.</p>
        </div>
        <div class="thin">
            <h1>Lorem ipsum ne justo</h1>
            <p>Bonorum has. His ut cibo quas tantas, vis ut probo adhuc definiebas, has at meis debet vulputate. No sed velit essent suavitate, in pro decore ceteros temporibus, usu in odio offendit theophrastus. Mel labore indoctum cu, ad soleat admodum delicatissimi sed, mei viris tritani ullamcorper eu. Ut vim simul aperiam.</p>
            <p>Blandit insolens constituto vix an. Has diam wisi in, eum unum repudiare no. Sit at virtute rationibus, qui vitae explicari cu. Vim ne singulis voluptatum, sed puto accusata salutandi ei. Ad mel civibus adversarium.</p>
            <p>Ius mutat commune expetendis in. Nam et quas sensibus reprimique, vix no erat soluta suavitate. At mel eius dictas latine. Corrumpit inciderint reformidans sed no, no usu omnis utinam noluisse.</p>
            <p>Probo debet quaestio an eos, no mel assum iracundia delicatissimi, rebum facete utroque sed ex. Eu melius invidunt repudiandae vix, eu paulo reformidans deterruisset duo, solum voluptaria efficiantur ea mel. Qui summo zzril alienum et. Eu est ferri iuvaret, mazim epicurei sententiae ut cum, modo reque intellegat ex vix. Vim eu tibique accusamus, quot electram at qui.</p>
            <p>Eu eleifend repudiandae has. Mea eu ridens aliquam. Nisl aeque sit ut, posse dolor utinam cum in. Ad timeam sapientem eos, et eripuit inermis nam. Eos integre voluptaria ne, iriure concludaturque ut eum.</p>
            <p>Sit et, an ius nihil apeirian. Eu posse tempor iuvaret cum. No diam dolor sea, postea mnesarchum ne ius, vel no utinam ignota dolores. Malis suscipit accusamus his ne, utinam assentior prodesset ea eam, facer partem antiopam et cum.</p>
            <p>Vis erant intellegat in. Soleat legere no ius, usu ex laoreet molestie. Sit eu sint inermis. Ea zzril scribentur pro.</p>
            <h1>Tempor essent appetere</h1>
            <p>Ius mutat commune expetendis in. Nam et quas sensibus reprimique, vix no erat soluta suavitate. At mel eius dictas latine. Corrumpit inciderint reformidans sed no, no usu omnis utinam noluisse.</p>
            <p>Sit et, an ius nihil apeirian. Eu posse tempor iuvaret cum. No diam dolor sea, postea mnesarchum ne ius, vel no utinam ignota dolores. Malis suscipit accusamus his ne, utinam assentior prodesset ea eam, facer partem antiopam et cum.</p>
            <p>Blandit insolens constituto vix an. Has diam wisi in, eum unum repudiare no. Sit at virtute rationibus, qui vitae explicari cu. Vim ne singulis voluptatum, sed puto accusata salutandi ei. Ad mel civibus adversarium.</p>
            <p>Per ne solum vivendo, fabulas dolorem vivendo in pro. Nec duis ignota cotidieque no, an per possit nostrum. Pro detraxit definitionem eu. Vivendo officiis no nam, eu has reque maiestatis percipitur, dolore reprimique accommodare cum ad. No utinam voluptua oportere pri, augue sonet dicant ei sea.</p>
            <p>Probo debet quaestio an eos, no mel assum iracundia delicatissimi, rebum facete utroque sed ex. Eu melius invidunt repudiandae vix, eu paulo reformidans deterruisset duo, solum voluptaria efficiantur ea mel. Qui summo zzril alienum et. Eu est ferri iuvaret, mazim epicurei sententiae ut cum, modo reque intellegat ex vix. Vim eu tibique accusamus, quot electram at qui.</p>
            <p>Ex iisque eleifend periculis has. Sit aeterno virtute partiendo ei, eam nonumy bonorum adolescens ad. Ut nec suas vocent ornatus, cetero legendos constituam mea ea, pri cu delenit iracundia. Mundi decore nec te.</p>
            <h1>Soleat civibus in pri</h1>
            <p>In petentium erroribus percipitur per. Takimata accommodare ius ut, eam no postulant urbanitas. Qui ei tantas consectetuer, quis dictas euripidis duo ei. Quaeque democritum concludaturque has ne.</p>
            <p>Blandit insolens constituto vix an. Has diam wisi in, eum unum repudiare no. Sit at virtute rationibus, qui vitae explicari cu. Vim ne singulis voluptatum, sed puto accusata salutandi ei. Ad mel civibus adversarium.</p>
            <p>Ius mutat commune expetendis in. Nam et quas sensibus reprimique, vix no erat soluta suavitate. At mel eius dictas latine. Corrumpit inciderint reformidans sed no, no usu omnis utinam noluisse.</p>
            <p>Sit et, an ius nihil apeirian. Eu posse tempor iuvaret cum. No diam dolor sea, postea mnesarchum ne ius, vel no utinam ignota dolores. Malis suscipit accusamus his ne, utinam assentior prodesset ea eam, facer partem antiopam et cum.</p>
            <p>Per ne solum vivendo, fabulas dolorem vivendo in pro. Nec duis ignota cotidieque no, an per possit nostrum. Pro detraxit definitionem eu. Vivendo officiis no nam, eu has reque maiestatis percipitur, dolore reprimique accommodare cum ad. No utinam voluptua oportere pri, augue sonet dicant ei sea.</p>
            <p>Sit et, an ius nihil apeirian. Eu posse tempor iuvaret cum. No diam dolor sea, postea mnesarchum ne ius, vel no utinam ignota dolores. Malis suscipit accusamus his ne, utinam assentior prodesset ea eam, facer partem antiopam et cum.</p>
        </div>

    </div>
</body>

您需要下载该文件,因为它没有CDN,所以不要忘记将path-to-local-file更改为文件的实际位置。

对于只需要支持10+的其他人来说,问题在于您只使用CSS的供应商前缀版本。您还需要包含正常版本:

-webkit-column-fill: auto;
-webkit-column-width: 300px;
-webkit-column-gap: 40px;
-moz-column-fill: auto;
-moz-column-width: 300px;
-moz-column-gap: 40px;
column-fill: auto;
column-width: 300px;
column-gap: 40px;

这在IE11中对我有用:

&#13;
&#13;
$(document).ready(function() {


  $(".RightArrow ").click(function() {
    $(".columns").animate({
      scrollLeft: '+=500'
    }, 100);
  });

  $(".LeftArrow ").click(function() {
    $(".columns").animate({
      scrollLeft: '-=500'
    }, 100);
  });



}); //end script
&#13;
body {
  font-family: arial;
}
.columns {
  overflow: hidden;
  width: 500px;
  border: 1px solid #000;
  -webkit-column-fill: auto;
  -webkit-column-width: 300px;
  -webkit-column-gap: 40px;
  -moz-column-fill: auto;
  -moz-column-width: 300px;
  -moz-column-gap: 40px;
  column-fill: auto;
  column-width: 300px;
  column-gap: 40px;
  padding: 0 20px;
  text-align: left;
  height: 500px;
  overflow: hidden;
  position: relative;
}
.notsectable {
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: -moz-none;
  -o-user-select: none;
  user-select: none;
}
.arrows {
  width: 500px;
}
.RightArrow {
  float: right;
  cursor: pointer;
}
.LeftArrow {
  float: left;
  cursor: pointer;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="columns">



  <p>
    <a class="">

      <h2>
<span class="">1</span>
NUM 1
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>


  <p>
    <a class="">

      <h2>
<span class="">2</span>
NUM 2
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>

  <p>
    <a class="">

      <h2>
<span class="">3</span>
NUM 3
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>



  <p>
    <a class="">

      <h2>
<span class="">4</span>
NUM 4
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>


  <p>
    <a class="">

      <h2>
<span class="">5</span>
NUM 5
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>

  <p>
    <a class="">

      <h2>
<span class="">6</span>
NUM 6
</h2>
      <h3>200 Broadway</h3>
      <p>This transit hub is a contemporary architectural marvel in Lower Manhattan and features a Sky Reflector Net centerpiece…</p>
    </a>


  </p>

</div>
<!--columns-->


<div class="arrows">


  <span class="LeftArrow"> Previose </span>  <span class="RightArrow">  Next </span>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

答案很简单,没有。如果您不想在其中加入一些逻辑并将结果划分为特定的DIV,那么您将无法获得所需的结果。抱歉:(