2015-12-15 66 views
1

我想为MVC添加此表格@foreach(模型中的var项目)(我可以这样做),我为Dreamweaver创建此表格,但表格单元格高度可以不会改变,我该怎么办?或者请给我一些表结构/教程。 三江源MVC的表格单元格高度不能更改

jsfiddle

HTML

<table class="table"> 
    <tr> 
     <th> 
      First Name 
     </th> 
     <th> 
      Last Name 
     </th> 
     <th> 

     </th> 
     <th>Edit</th> 
    </tr> 



     <tr> 
      <td> 
       jgfjfgj jjjjjjjjjjjjjjjjjjjjjjjjjj jgfjfgj jjjjjjjjjjjjjjjjjjjjjjjjjj jgfjfgj jjjjjjjjjjjjjjjjjjjjjjjjjj 
      </td> 
      <td> 
       jgfjjjjjjjjjjjjjjjjjjj 
      </td> 
      <td> 
      fgjfjjjjjjjjjjjjjjjjj 
      </td> 
      <td> 
       gjj jjjjjjjjjjjjjjjjjjjjjjjjjj 
      </td> 
     </tr> 


</table> 

CSS

@media 
    only screen and (max-width: 560px), 
    (min-device-width: 768px) and (max-device-width: 1024px) { 

     /* Force table to not be like tables anymore */ 
     table, thead, tbody, th, td, tr { 
      display: block; width:250px; 
     } 

     /* Hide table headers (but not display: none;, for accessibility) */ 
     thead tr { 
      position: absolute; 
      top: -9999px; 
      left:-9999px; 
     } 

     tr { margin-left:4px; } 



     /* 
     Label the data 
     */ 
     td:nth-of-type(1):before { content: ""; } 
     td:nth-of-type(2):before { content: ""; } 
     td:nth-of-type(3):before { content: ""; } 
     td:nth-of-type(4):before { content: ""; } 
     td:nth-of-type(5):before { content: ""; } 

     } 

    /* Smartphones (portrait and landscape) ----------- */ 
    @media only screen 
    and (min-device-width : 320px) 
    and (max-device-width : 480px) { 
     body { 
      padding: 0; 
      margin: 0; 
      width: 320px; } 
     } 

    /* iPads (portrait and landscape) ----------- */ 
    @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) { 
     body { 
      width: 495px; 
     } 
    }tr:nth-of-type(odd) { 
     background:#eee; 
    } 
    th { 
     background: #333; 
     color: white; 
     font-weight: bold; 
    } 
    th { 
     padding: 5px; height:10px; 
     border: 1px solid #ccc; 
     text-align: left; 
    } 
td { 
height:5px; 
     border: 1px solid #ccc; 
     text-align: left; 



} 

    Edit { color:black;} 
+0

它不能改变 – Codeone

+0

IM尝试,但对于小不会改变,我想小众的细胞 – Codeone

+0

可能的复制的[如何设置表格单元的最大高度是多少?(HTTP:/ /stackoverflow.com/questions/13667941/how-to-set-maximum-height-for-table-cell) –

回答

1

你应该试试这个样子,

@media 
 
    only screen and (max-width: 560px), 
 
    (min-device-width: 768px) and (max-device-width: 1024px) { 
 
    
 
    /* Force table to not be like tables anymore */ 
 
    table, thead, tbody, th, td, tr { 
 
     display: block; width:250px;box-sizing: border-box; 
 
    } 
 
    
 
    /* Hide table headers (but not display: none;, for accessibility) */ 
 
    thead tr { 
 
     position: absolute; 
 
     top: -9999px; 
 
     left:-9999px; 
 
    } 
 
    
 
    tr { margin-left:4px; } 
 
     
 
    
 
    
 
    /* 
 
    Label the data 
 
    */ 
 
    td:nth-of-type(1):before { content: ""; } 
 
    td:nth-of-type(2):before { content: ""; } 
 
    td:nth-of-type(3):before { content: ""; } 
 
    td:nth-of-type(4):before { content: ""; } 
 
    td:nth-of-type(5):before { content: ""; } 
 
    
 
    } 
 

 
    /* Smartphones (portrait and landscape) ----------- */ 
 
    @media only screen 
 
    and (min-device-width : 320px) 
 
    and (max-device-width : 480px) { 
 
    body { 
 
     padding: 0; 
 
     margin: 0; 
 
     width: 320px; } 
 
    } 
 
    
 
    /* iPads (portrait and landscape) ----------- */ 
 
    @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) { 
 
    body { 
 
     width: 495px; 
 
    } 
 
    }tr:nth-of-type(odd) { 
 
    background:#eee; 
 
    } 
 
    th { 
 
    background: #333; 
 
    color: white; 
 
    font-weight: bold; 
 
    } 
 
    th { 
 
    padding: 5px; 
 
    min-height:10px; 
 
    border: 1px solid #ccc; 
 
    text-align: left; 
 
    } 
 
td { 
 
    min-height:5px; 
 
    border: 1px solid #ccc; 
 
    text-align: left; 
 
     
 

 

 
} 
 

 
    Edit { color:black;} 
 

 
    
 
</style>
<table class="table"> 
 
    <tr> 
 
     <th> 
 
      First Name 
 
     </th> 
 
     <th> 
 
      Last Name 
 
     </th> 
 
     <th> 
 
      
 
     </th> 
 
     <th>Edit</th> 
 
    </tr> 
 
    
 
    <tr> 
 
     <td> 
 
      jgfjfgj jjjjjjjjjjjjjjjjjjjjjjjjjj jgfjfgj jjjjjjjjjjjjjjjjjjjjjjjjjj jgfjfgj jjjjjjjjjjjjjjjjjjjjjjjjjj 
 
     </td> 
 
     <td> 
 
      jgfjjjjjjjjjjjjjjjjjjj 
 
     </td> 
 
     <td> 
 
     fgjfjjjjjjjjjjjjjjjjj 
 
     </td> 
 
     <td> 
 
      gjj jjjjjjjjjjjjjjjjjjjjjjjjjj 
 
     </td> 
 
    </tr> 
 
    </table>

+0

但OP *希望*限制细胞高度。 –

+0

我这样做,但不满意 – Codeone

+0

@GregPettit,我认为你是对的 – Codeone