2017-04-18 93 views
0

我想讓我的文字和圖標彼此變小。他們分成2行,每個3個單元格。另外,我如何使高度和寬度響應並且不會從正方形變成矩形?如何讓兩個表格行之間的空間變小css

@import url(https://fonts.googleapis.com/css?family=Fjalla+One); 
 

 
html{ 
 
    height: 100%; 
 
} 
 

 
body{ 
 
    font-family: 'Fjalla One', sans-serif; 
 
    background: #2C3E50; /* fallback for old browsers */ 
 
    background: -webkit-linear-gradient(to top, #4CA1AF, #2C3E50); /* Chrome 10-25, Safari 5.1-6 */ 
 
    background: linear-gradient(to top, #4CA1AF, #2C3E50); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ 
 
} 
 

 
.icon{ 
 
    display: inline-block; 
 
    vertical-align: middle; 
 
    -webkit-transform: perspective(1px) translateZ(0); 
 
    transform: perspective(1px) translateZ(0); 
 
    box-shadow: 0 0 1px transparent; 
 
    -webkit-transition-duration: 0.3s; 
 
    transition-duration: 0.3s; 
 
    -webkit-transition-property: box-shadow, transform; 
 
    transition-property: box-shadow, transform; 
 
    display: table-cell; 
 
    vertical-align: middle; 
 
    color: white; 
 
    border: 2px solid black; 
 
    border-radius: 35px; 
 
    width: 180px; 
 
    height: 180px; 
 
    text-align: center; 
 
    background: #007991; /* fallback for old browsers */ 
 
    background: -webkit-linear-gradient(to bottom, #78ffd6, #007991); /* Chrome 10-25, Safari 5.1-6 */ 
 
    background: linear-gradient(to bottom, #78ffd6, #007991); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ 
 
} 
 

 
.icon:hover, .icon:focus, .icon:active { 
 
    box-shadow: 0 50px 50px -50px rgba(0, 0, 0, 50); 
 
    -webkit-transform: scale(1.1); 
 
    transform: scale(1.1); 
 
} 
 

 

 

 
.icontext{ 
 
    text-align: center; 
 
    color: white; 
 
    font-size: 30px; 
 
} 
 

 

 

 
table { 
 
    border-spacing: 60px; 
 
    border-collapse: separate; 
 
}
<table align="center"> 
 
    <tr> 
 
    <h1> 
 
    <td class="icon" id="afspraken">Icoon1</td> 
 
    <td class="icon">Icoon2</td> 
 
    <td class="icon">Icoon3</td> 
 

 
    </tr> 
 
    <tr> 
 
     <td class="icontext">Afspraken</td> 
 
     <td class="icontext">Grenzen</td> 
 
     <td class="icontext">Situaties</td> 
 
    </tr> 
 
</table>

回答

1

我不知道在你執行這項所以不會批評你一個<table>的選擇奠定了這些圖標的上下文。

儘管使用表格單元格作爲圖標,但這不是個好主意。更好的選擇是在其中設置一個元素。我用<span>來做那here

html{ 
 
     height: 100%; 
 
    } 
 

 
    body{ 
 
     font-family: 'Fjalla One', sans-serif; 
 
     background: #2C3E50; /* fallback for old browsers */ 
 
     background: -webkit-linear-gradient(to top, #4CA1AF, #2C3E50); /* Chrome 10-25, Safari 5.1-6 */ 
 
     background: linear-gradient(to top, #4CA1AF, #2C3E50); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ 
 
    } 
 

 
    .icon{ 
 
     text-decoration: none; 
 
     cursor: pointer; 
 
     display: block; 
 
     -webkit-transform: perspective(1px) translateZ(0); 
 
     transform: perspective(1px) translateZ(0); 
 
     box-shadow: 0 0 1px transparent; 
 
     -webkit-transition-duration: 0.3s; 
 
     transition-duration: 0.3s; 
 
     -webkit-transition-property: box-shadow, transform; 
 
     transition-property: box-shadow, transform; 
 
     vertical-align: middle; 
 
     color: white; 
 
     border: 2px solid black; 
 
     border-radius: 35px; 
 
     width: 160px; 
 
     height: 180px; 
 
     margin: 10px; 
 
     line-height: 180px; 
 
     text-align: center; 
 
     background: #007991; /* fallback for old browsers */ 
 
     background: -webkit-linear-gradient(to bottom, #78ffd6, #007991); /* Chrome 10-25, Safari 5.1-6 */ 
 
     background: linear-gradient(to bottom, #78ffd6, #007991); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ 
 
    } 
 

 
    .icon:hover, .icon:focus, .icon:active { 
 
     box-shadow: 0 50px 50px -50px rgba(0, 0, 0, 50); 
 
     -webkit-transform: scale(1.1); 
 
     transform: scale(1.1); 
 
    } 
 

 

 

 
    .icontext{ 
 
     text-align: center; 
 
     color: white; 
 
     font-size: 30px; 
 
     text-decoration: none; 
 
    } 
 

 

 

 
    table { 
 
     border-spacing: 60px; 
 
     border-collapse: collapse; 
 
     text-align: center; 
 
    }
<table align="center"> 
 
    <tr> 
 
     <td><a href="#" class="icon" id="afspraken">Icon1</a></td> 
 
     <td><a href="#" class="icon">Icon2</a></td> 
 
     <td><a href="#" class="icon">Icon3</a></td> 
 
    </tr> 
 
    <tr> 
 
     <td><a href="#" class="icontext">Afspraken</a></td> 
 
     <td><a href="#" class="icontext">Grenzen</a></td> 
 
     <td><a href="#" class="icontext">Situaties</a></td> 
 
    </tr> 
 
</table>

注意了我要從頭開始,我會做不同的更多的東西。要回答你的問題,我只是對你的標記和CSS做了小的修改。

+0

你好,首先感謝您的幫助的。我是一個初學者,這可能是爲什麼有這麼多的錯誤。我會更新它並讓你知道它是如何工作的。 –

+0

我已經更新了答案中的代碼。如果您希望擁有完整的代碼,以便查看上下文,請詢問。再次感謝您的幫助 –

0

如果我這樣做會更好嗎?

html{ 
 
    height: 100%; 
 
} 
 

 
body{ 
 
    font-family: 'Fjalla One', sans-serif; 
 
    background: #2C3E50; /* fallback for old browsers */ 
 
    background: -webkit-linear-gradient(to top, #4CA1AF, #2C3E50); /* Chrome 10-25, Safari 5.1-6 */ 
 
    background: linear-gradient(to top, #4CA1AF, #2C3E50); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ 
 
} 
 

 
.icon{ 
 
    cursor: pointer; 
 
    display: block; 
 
    -webkit-transform: perspective(1px) translateZ(0); 
 
    transform: perspective(1px) translateZ(0); 
 
    box-shadow: 0 0 1px transparent; 
 
    -webkit-transition-duration: 0.3s; 
 
    transition-duration: 0.3s; 
 
    -webkit-transition-property: box-shadow, transform; 
 
    transition-property: box-shadow, transform; 
 
    vertical-align: middle; 
 
    color: white; 
 
    border: 2px solid black; 
 
    border-radius: 35px; 
 
    width: 160px; 
 
    height: 180px; 
 
    margin: 10px; 
 
    line-height: 180px; 
 
    text-align: center; 
 
    background: #007991; /* fallback for old browsers */ 
 
    background: -webkit-linear-gradient(to bottom, #78ffd6, #007991); /* Chrome 10-25, Safari 5.1-6 */ 
 
    background: linear-gradient(to bottom, #78ffd6, #007991); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ 
 
} 
 

 
.icon:hover, .icon:focus, .icon:active { 
 
    box-shadow: 0 50px 50px -50px rgba(0, 0, 0, 50); 
 
    -webkit-transform: scale(1.1); 
 
    transform: scale(1.1); 
 
} 
 

 

 

 
.icontext{ 
 
    text-align: center; 
 
    color: white; 
 
    font-size: 30px; 
 
} 
 

 

 

 
table { 
 
    border-spacing: 60px; 
 
    border-collapse: collapse; 
 
    text-align: center; 
 
}
<table align="center"> 
 
    <tr> 
 
    <h1> 
 
    <td><input type="button" class="icon" value="Icoon1") /></td> 
 
    <td><input type="button" class="icon" value="Icoon2") /></td> 
 
    <td><input type="button" class="icon" value="Icoon3") /></td> 
 
    </tr> 
 
    <tr> 
 
     <td class="icontext">Afspraken</td> 
 
     <td class="icontext">Grenzen</td> 
 
     <td class="icontext">Situaties</td> 
 
    </tr> 
 
</table>

相關問題