CSS - 样式表

时间:2014-04-14 10:21:16

标签: html css

我需要做这样的事情: enter image description here

我不是百分百肯定如何制作这样的,所以我决定桌子哪个有用,但它只是可怕的分散我做的,我的尝试看起来像:

    <table>
      <tr>
          <td rowspan="2" class="img-position"><a href="#"><img src="images/foto.png"></a></td>
          <td class="topic-name"><a href="#">Název topicu nebo článku </a></td>
          <td class="date">28.8.2014 / 19:30</td>
      </tr>
    </table>  

我的CSS:

#sub-content .left{
    width: 326px;
    height: 145px;
    display: inline-block;
    float:left;        
}

#sub-content img{
    width: 122px;
    height: 121px;
    display: inline-block;
    margin-top: 0px;
    margin-left: 5px;        
}

#sub-content .topic-name{
    width: 150px;
    height: 14px;
    line-height 14px;
    margin-bottom: 130px;
    margin-left: 10px;
    display: inline-block;
    vertical-align: top;
    text-decoration: underline;
    font-weight: 14px;         
}

#sub-content table{
    width:326px;
    height:145px;         
}

#sub-content tr{
    margin: 10px 0px 0px 0px;
    padding: 0px;
    height: 36px;         
}

#sub-content .date{            
}

#sub-content .img-position{
    margin: 0px;
    padding: 0px;
    width: 122px;
    height: 121px;
    display: inline-block;         
} 

我不能从我的位置移动至至少一个部分,然后只复制它3次。我希望我能找到一个可以帮助我解决问题的人。

可以在http://funedit.com/andurit/try1/

上找到实时预览

感谢您阅读我的帖子

3 个答案:

答案 0 :(得分:1)

首先,我建议您阅读:Why not use tables for layout in HTML?关于如何创建布局的内容。

我用你给定的东西为你准备了基本的jsfiddle例子,让你更快地了解事情。看一下这个。 Example layout

我将您给定的布局更改为div和span,它看起来或多或少会像这样:

<div class='article-container'>
  <div class='article'>  
  <div class="img-position">
    <a href="#"><img src="http://funedit.com/andurit/try1/images/foto.png"/></a> 
  </div>
  <span class="topic-name"><a href="#">Název topicu nebo článku </a></span>
  <span class="date">28.8.2014 / 19:30</span>
  </div>
  .
  . 
  .
</div>

答案 1 :(得分:0)

在表NON Semantic中执行此操作,我不推荐它。 我认为你需要使用这个结构

Html

<div class="block1">block1</div>
        <div class="block2">block2</div>
        <div class="block3">block3</div>
    </div>
* {
    margin: 0;
    padding: 0;
}
html, body {
    height: 100%;
    width: 100%;
}
.wrapper{
    width: 100%;
    background: #ddd;
}
.block1{
    float: left;
    width: 33.3%;
    background: #c01;
    height: 200px;
    margin-right: 1px;
}
.block2{
    float: left;
    width: 33.3%;
    background: #c01;
    height: 200px;
    margin-right: 1px;
}
.block3{
    float: left;
    width: 33.3%;
    background: #c01;
    height: 200px;
}

答案 2 :(得分:0)

使用bootstrap网格来实现表格样式。它响应迅速,易于实施。 包含此CSS file

<div class='row'>
       <div class='col-xs-4 tab'> <!-- 1/3rd size of the parent container -->
        <div class='row'>
          <!-- Image box -->
          <div class='col-xs-4'> 
            <a href="#"><img src="images/foto.png"></a> 
          </div>
          <!-- Description box -->
          <div class='col-xs-8'> <!-- 2/3rd size of parent container -->
           <div><a href="#">Název topicu nebo článku </a></div>
           <div>28.8.2014 / 19:30</div>
           <div>Lorem Ipsum</div>
         </div>
       </div>
     </div>

   <div class='col-xs-4 tab'> <!-- 1/3rd size of the parent container -->
    <div class='row'>
      <!-- Image box -->
      <!-- ...  Follow same structure as above-->
   </div>
  </div>

   <div class='col-xs-4 tab'> <!-- 1/3rd size of the parent container -->
    <div class='row'>
      <!-- ... Follow same structure as above -->
   </div>
  </div>
</div>

这将为您提供3列,宽度相等。 对于每个标签的固定高度,只需提供

<style>
.tab{
  height: 200px;
}
</style>

有关实施细节,请参阅here

相关问题