【问题标题】:Multi column CSS make the first column wider多列 CSS 使第一列更宽
【发布时间】:2017-05-16 12:53:19
【问题描述】:

我正在使用多列 div。请参阅下面的 CSS:

<div id="content">
    Super duper long text....
</div>

#content {
    -webkit-column-width: 300px!IMPORTANT; 
    -moz-column-width: 300px!IMPORTANT;
    column-width: 300px!IMPORTANT;
}

它工作得很好。我所有的列都是 300 像素。有没有办法使用 css 使第一列 500px?

【问题讨论】:

标签: html css


【解决方案1】:

要使第一列宽使用此代码:

=> CSS

    .div_style:first-child
{
    border:1px solid black;
    width: 500px;
}
.div_style
{
    border:1px solid black;
    width: 300px;
}

=> HTML

 <div id="content_first" class="div_style">
    Super duper long text....
</div>
<div id="content" class="div_style" >
    Super duper long text....
</div>
<div id="content" class="div_style" >
    Super duper long text....
</div>

【讨论】:

    【解决方案2】:

    你可以使用flex

    以下是示例: 您可以使用以下属性

    .header,
    .footer  { flex: 1 100%; }
    .sidebar { flex: 1; } /* You can change property*/
    .main    { flex: 2; }
    

    .flex-container {
      padding: 0;
      margin: 0;
      list-style: none;
      height: 200px;
      
      -ms-box-orient: horizontal;
      display: -webkit-box;
      display: -moz-box;
      display: -ms-flexbox;
      display: -moz-flex;
      display: -webkit-flex;
      display: flex;
      
      -webkit-justify-content: space-around;
      justify-content: space-around;
      -webkit-flex-flow: row wrap;
      flex-flow: row wrap;
      -webkit-align-items: stretch;
      align-items: stretch;
    }
    
    .header,
    .footer  { flex: 1 100%; }
    .sidebar { flex: 1; }
    .main    { flex: 2; }
    
    .flex-item {
      
      background: tomato;
      padding: 10px;
      width: 100px;
      border: 3px solid rgba(0,0,0,.2);
      
      color: white;
      font-weight: bold;
      font-size: 2em;
      text-align: center;
    }
    <ul class="flex-container">
      <li class="flex-item header">Header</li>
      <li class="flex-item sidebar">Sidebar</li>
      <li class="flex-item main">Main</li>
      <li class="flex-item sidebar">Sidebar</li>
      <li class="flex-item footer">Footer</li>
    </ul>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-14
      • 2011-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-05
      • 2018-07-29
      相关资源
      最近更新 更多