【问题标题】:dynamic vertical multi column list does not work in IE动态垂直多列列表在 IE 中不起作用
【发布时间】:2013-12-11 18:50:43
【问题描述】:

Blow 代码完美适用于 Mozilla、Safari 和 Chrome,但不适用于 IE 7、8、9。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css"> 
ul {margin: 0; padding: 0; list-style: none;float:left;}

.column {
    background-color: #fff;
    border: 1px solid #999;
    padding: 8px;
    width:40%;
}
label{
   float:left;
}
ul li a{
    display:block;
    float:left;
    width: 120px;
    margin: 0 5px 0 5px;
}
ul li {
    clear:both;
    margin: 0 0 5px 0;  
    overflow:hidden;
}
.column {
/* the proper rules ready for future */
column-count: 3;
column-gap: 20px;

/* Moz/Firefox rules */
-moz-column-count: 3;
-moz-column-gap: 20px;

/* Safari & Chrome rules */
-webkit-column-count: 3;
-webkit-column-gap: 20px;
}
</style>
</head>
<body>
<ul class="column">
    <li><label><input type="checkbox"></label>Francoise Barre-Sinoussi</li>
    <li><label><input type="checkbox"></label>Rachel Carson</li>
    <li><label><input type="checkbox"></label>Shirley M. Tilghman</li>
    <li><label><input type="checkbox"></label>Jane Goodall</li>
    <li><label><input type="checkbox" ></label>Marie Curie</li>
    <li><label><input type="checkbox" ></label>Rosalind Franklin</li>
    <li><label><input type="checkbox" ></label>Svetlana Savitskaya</li>
    <li><label><input type="checkbox" ></label>Mae Jemison</li>
    <li><label><input type="checkbox" ></label>Mayim Bialik</li>
    <li><label><input type="checkbox" ></label>Sally Ride</li>
</ul>
</body> 
</html>

我必须应用哪些 hack 才能使其在 IE7、8 和 9 中运行。

【问题讨论】:

  • 这和php有什么关系?请重新标记为 HTML。
  • 澄清一下,问题出在column-count: 3;
  • @falsarella:能否请您提出解决方案。

标签: html css list internet-explorer cross-browser


【解决方案1】:

IE 不支持 CSS column-count。

我看到的唯一解决方案是更改 html 结构和 css:

See the jsfiddle demo

HTML:

<div class="border">
<ul class="column">
    <li><label><input type="checkbox"></label>Francoise Barre-Sinoussi</li>
    <li><label><input type="checkbox"></label>Rachel Carson</li>
    <li><label><input type="checkbox"></label>Shirley M. Tilghman</li>
</ul>
<ul class="column">
    <li><label><input type="checkbox"></label>Jane Goodall</li>
    <li><label><input type="checkbox" ></label>Marie Curie</li>
    <li><label><input type="checkbox" ></label>Rosalind Franklin</li>
</ul>
<ul class="column">
    <li><label><input type="checkbox" ></label>Svetlana Savitskaya</li>
    <li><label><input type="checkbox" ></label>Mae Jemison</li>
    <li><label><input type="checkbox" ></label>Mayim Bialik</li>

</ul>
<ul class="column">
    <li><label><input type="checkbox" ></label>Sally Ride</li>
</ul>
</div>​

CSS:

ul {margin: 0; padding: 0; list-style: none;float:left;}

.column {
    background-color: #fff;
    padding: 8px;
}
.border {
    border: 1px solid #999;
    float: left;
}
label{
   float:left;
}
ul li a{
    display:block;
    float:left;
    margin: 0 5px 0 5px;
}
ul li {
    clear:both;
    margin: 0 0 5px 0;  
}

【讨论】:

    【解决方案2】:

    试试这个css代码,

    ul {margin: 0; padding: 0; list-style: none;float:left;}
    
    .column {
    background-color: #fff;
    border: 1px solid #999;
    padding: 8px;
    width:500px;
    }
    ul li {
    float:left;
    margin: 0 0 5px 0;  
    overflow:hidden;
    width: 200px;
    background-color: orange;
    margin-right: 10px;
    }
    .column {
    /* the proper rules ready for future */
    column-count: 3;
    column-gap: 20px;
    
    /* Moz/Firefox rules */
    -moz-column-count: 3;
    -moz-column-gap: 20px;
    
    /* Safari & Chrome rules */
    -webkit-column-count: 3;
    -webkit-column-gap: 20px;
    }
    

    【讨论】:

    • jsfiddle.net/Zcecm 在这里试试,让我知道它是否有效。
    • 现在可以使用了。在您的帖子中是width:40%;,而不是width:500px;。
    • 只是为了说清楚。它之所以有效,是因为 ul li 宽度为 200 像素,.column 宽度为 500 像素,适合 2 次。要将 3 列作为列数:3,.column 的宽度应该是ul li 宽度的 3 倍(例如 600px)。
    猜你喜欢
    • 2021-09-24
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 2018-06-26
    • 2017-09-01
    • 1970-01-01
    相关资源
    最近更新 更多