簡體   English   中英

在CSS Foundation Framework中將按鈕垂直居中放置在表格中?

[英]Center a Button Vertically in a Table in the CSS Foundation Framework?

我有一個基金會按鈕:

<a href="#" class="button tiny alert radius FormSubmit">Delete</a>  

在表格行單元格內:``button''

在此處輸入圖片說明

如您所見,按鈕未垂直居中對齊。

這是我創建的一個JSFiddle來顯示問題。

<table class="centered columns">
    <thead>
        <tr>
            <td>Granted</td>
            <td>Action</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>true</td>
            <td><a href="#" class="button tiny alert radius FormSubmit">Delete</a>  </td>
        </tr>

    </tbody>
</table>

如何在CSS Foundation Framework中的表中垂直放置按鈕?

您只需要刪除按鈕margin-bottom屬性。

jsfiddle

這會將所有內容居中放在表格中間。 但是作為CSS3,您只需擔心現代瀏覽器。

td{
  position:relative; 
}
.button{
  position: absolute;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}

JSFIDDLE

只需將保證金自動添加到按鈕類

.button{
    margin: auto;
}

並刪除以前的樣式,因為它會過篩並且不起作用;與絕對位置相比,自動也會響應

在按鈕中添加id =“ top-padding”並添加CSS

<style>
#top-padding {
padding-top: 10px;

}

</style>

可能並不完美,但您可以弄亂像素數,直到居中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM