2014-07-06 122 views
0

enter image description here如何在表格中的單元格之間添加空白空間?

我想要做的HTML和CSS ..我想在第二排的每個按鈕上每個箭頭的第一行上的底部..我的意思,我想他們之間添加空間。我怎樣才能做到這一點??

這裏是第二行我的HTML代碼:

<table style="width:1160px; margin-top:10px" cellspacing="10" cellpadding="0" bordercolor="#666666" > 
<tr> 
<td width="193px" class="button" ><img src="b2.png" /></td> 

<td width="193px" class="button" ><img src="b2.png" /></td> 
<td width="193px" class="button" ><img src="b2.png" /></td> 
<td width="193px" class="button" ><img src="b2.png" /></td> 
<td width="193px" class="button" ><img src="b1.png" /></td> 
<td width="193px" class="button" ></td> 
</tr> 
</table> 

,這裏是類按鈕的CSS:

.button { 
    width:152px; 
    text-align:center; 
    background:rgb(51,153,51); 
    position:relative; 
    overflow:hidden; 
    margin:1px; 
    float: left; /* add this */ 
} 
.button a{ 
    display:block; 
    height:37px; 
    color:white; 
    line-height:100px; 
    text-decoration:none; 
    position:relative; 
    z-index:10; 
} 
.button:before { 
    content:" "; 
    display:block; 
    width:152px; 
    height:37px; 
    background:rgba(0,0,0,0.5); 
    position:absolute; 
    left:0; 
    top:100%; 
    transition:all 0.5s; 
} 
.button:hover:before { 
    top:0; 
} 

任何幫助?

+1

你能提供一個小提琴嗎? – hjpotter92

+0

你是什麼意思的小提琴? – user3675605

+0

[jsfiddle](http://fsfiddle.net) –

回答

0

爲什麼不使用相同寬度的按鈕?

.button{ 
    width:193px; 

    //More Styles here ... 
} 

或者做一些數學,如果你想空白

.button{ 
    width:188px; 
    margin-right:5px 

    //More Styles here ... 
} 
0
.button { 
    width: 152px; 
    text-align:center; 
    background:rgb(51,153,51); 
    position:relative; 
    overflow:hidden; 
    margin:1px 10px 1px 1px; /* add this */ 
    float: left; 
} 
.button a{ 
    display:block; 
    height:37px; 
    color:white; 
    line-height:100px; 
    text-decoration:none; 
    position:relative; 
    z-index:10; 
} 
.button:before { 
    content:" "; 
    display:block; 
    width:152px; 
    height:37px; 
    background:rgba(0,0,0,0.5); 
    position:absolute; 
    left:0; 
    top:100%; 
    transition:all 0.5s; 
} 
.button:hover:before { 
    top:0; 
} 
1

最好的辦法才達到你想要的是將有DIV的一個容器,將同時擁有您的組件的箭頭,按鈕 現在漂浮這個div並根據需要

在小提琴看看添加儘可能多的div

[http://jsfiddle.net/EHgr5/3/][1] 
相關問題