多列CSS使第一列更宽

时间:2017-05-16 04:00:25

标签: html css

我正在使用多列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;
}

它运作得很好。我的所有专栏都是300px。有没有办法用css制作第一列500px?

2 个答案:

答案 0 :(得分:0)

您可以使用flex

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

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

&#13;
&#13;
.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;
}
&#13;
<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>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

要使第一列广泛使用此代码:

=&GT; CSS

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

=&GT; 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>