如何让两个表格行之间的空间变小css

问题描述:

我想让我的文字和图标彼此变小。他们分成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>

我不知道在你执行这项所以不会批评你一个<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

我已经更新了答案中的代码。如果您希望拥有完整的代码,以便查看上下文,请询问。再次感谢您的帮助 –

如果我这样做会更好吗?

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>