2017-08-29 91 views
2

正常工作,我做了一個共同的表,可以使用下面的CSS代碼溢出 - X和溢出-Y是不是在鉻

.table td{ 
    display: table-cell; 
    white-space: nowrap; 
    text-overflow: ellipsis; 
    max-width: 250px; 
    width: inherit; 
    overflow-y: hidden; 
    overflow-x: visible; 
} 

HTML代碼

<table class="table table-striped table-bordered table-hover"> 
            <thead> 
             <tr> 
              <th> # </th> 
              <th>Name</th> 
              <th class="hidden-xs">Code</th> 
              <th>Category</th> 
              <th class="hidden-xs">Location</th> 
              <th>More</th> 
             </tr> 
            </thead> 
            <tbody> 
             <tr role="row" class="odd"> 
              <td>21</td> 
              <td class="sorting_1">XXXXXXXX</td> 
              <td>00000000</td> 
              <td>xxxxxxxxxx</td> 
              <td>No: xx/x</td> 
              <td> 
               <div align="center"> 
                <div class="btn-group"> 
                 <a class="btn btn-xs btn-blue dropdown-toggle btn-sm" data-toggle="dropdown" href="#"> 
                  <i class="fa fa-cog"></i> 
                  <span class="caret"></span> 
                 </a> 
                 <ul role="menu" class="dropdown-menu pull-right"> 
                  <li role="presentation"> 
                   <a role="menuitem" tabindex="-1" href="../asset/edit?id=57"> 
                    <i class="fa fa-edit"></i> Edit 
                   </a> 
                  </li> 
                  <li role="presentation"> 
                   <a data-toggle="modal" role="menuitem" tabindex="-1" href="#model57"> 
                    <i class="fa fa-times"></i> Remove 
                   </a> 
                  </li> 
                 </ul> 
                </div> 
               </div> 
              </td> 
             </tr> 
            </tbody> 
           </table> 

還有就是隱藏在細胞多餘的文字每個桌子上的單元格中有一個按鈕,當點擊像波紋管那樣的按鈕時,它會顯示下拉菜單。 enter image description here

對於上面的代碼下拉菜單在firefox中正常工作,但在Chrome中它隱藏了下面的下拉菜單。 enter image description here

我需要爲每個表格中的工作制作一個通用的css代碼。我如何解決這個問題在鉻?

這裏是小提琴的例子。檢查它與Firefox和鉻 https://jsfiddle.net/udarazz/qhane23o/1/

+0

請提供你的代碼進行檢查。 –

+0

刪除overflow-y:hidden; – veera

+0

@ankitapatel你需要哪些代碼? Html代碼? – Udara

回答

1

請試試這個

$(".btn-group").parent().parent("td").addClass("drp_menu");
.table td{ 
 
    display: table-cell; 
 
    white-space: nowrap; 
 
    text-overflow: ellipsis; 
 
    max-width: 250px; 
 
    width: inherit; 
 
    overflow-y: hidden; 
 
    overflow-x: visible; 
 
} 
 
td.drp_menu { 
 
    overflow: visible; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script> 
 
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 

 
<table class="table table-striped table-bordered table-hover"> 
 
    <thead> 
 
     <tr> 
 
     <th> # </th> 
 
      <th>Name</th> 
 
      <th >Code</th> 
 
      <th>Category</th> 
 
      <th >Location</th> 
 
      <th>More</th> 
 
     </tr> 
 
    </thead> 
 
    <tbody> 
 
     <tr role="row" class="odd"> 
 
      <td>21</td> 
 
      <td class="sorting_1">XXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</td> 
 
      <td>00000000</td> 
 
      <td>xxxxxxxxxx</td> 
 
      <td>No: xx/x</td> 
 
      <td> 
 
       <div align="center"> 
 
        <div class="btn-group"> 
 
         <a class="btn btn-xs btn-blue dropdown-toggle btn-sm" data-toggle="dropdown" href="#"> 
 
          <i class="fa fa-cog"></i> 
 
          <span class="caret"></span> 
 
         </a> 
 
         <ul role="menu" class="dropdown-menu pull-right"> 
 
          <li role="presentation"> 
 
           <a role="menuitem" tabindex="-1" href="../asset/edit?id=57"> 
 
            <i class="fa fa-edit"></i> Edit 
 
           </a> 
 
          </li> 
 
          <li role="presentation"> 
 
           <a data-toggle="modal" role="menuitem" tabindex="-1" href="#model57"> 
 
            <i class="fa fa-times"></i> Remove 
 
           </a> 
 
          </li> 
 
         </ul> 
 
        </div> 
 
       </div> 
 
      </td> 
 
     </tr> 
 
    </tbody> 
 
</table>

+0

非常感謝。這有助於我解決我的問題 – Udara

+0

最受歡迎... –

0

如果試圖設置z-indexblock與菜單?

UPD:我所看到的問題不是TD,但與ul.dropdown-menu.pull-right

UPD2:

.table td ul.dropdown-menu.pull-right{ 
    display:block; 

} 

UPD3: https://codepen.io/Leo240/pen/Jymqrz

+0

我試過了,但沒有工作。 – Udara

+0

然後我認爲你還必須給出HTML代碼示例。 – Leo240

+0

@Udara我最近的更新在Chrome的codepen上工作 – Leo240

0

使用這種風格爲表格的最後一列。

table tr td:last-child { 
    text-overflow: initial; 
    overflow-y: visible; 
    overflow-x: visible; 
} 
+0

這僅適用於此表格。但我需要做一個共同的表CSS代碼。因爲有時按鈕不在最後一列 – Udara

+0

你可以使用像這樣的表tr td:hasChild(<按鈕)的hasChild方法,我用過這一次。它會搜索td中的按鈕 –

+0

這是一個JavaScript代碼? – Udara