如何将它们压实
这是我的html代码
<body>
<form action="/cgi-bin/form.py" id="myform">
<table class="table-fill">
...
</table>
<table class="table-fill">
...
</table>
...
</table>
<input type="submit" name="add" value="Submit" form="myform"/>
</form>
</body>
这是我的餐桌样式
.table-fill {
background: white;
border-radius:3px;
border-collapse: collapse;
height: 120px;
margin: auto;
max-width: 100px;
padding:5px;
}
我的提交样式
input[type=submit] {
padding:10px 15px;
background:#ccc;
border:0 none;
cursor:pointer;
-webkit-border-radius: 5px;
border-radius: 5px;
margin: auto;
display: block;
}
答案 0 :(得分:1)
一种方法可以是简单地在表格样式上使用display: inline-block
并调整边距
.table-fill {
display: inline-block;
background: white;
border-radius:3px;
border-collapse: collapse;
border-color: 1px solid #000;
height: 120px;
max-width: 100px;
padding:5px;
margin: 5px;
width: 100%;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
animation: float 5s infinite;
}
input[type=submit] {
padding:10px 15px;
background:#ccc;
border:0 none;
cursor:pointer;
-webkit-border-radius: 5px;
border-radius: 5px;
margin: auto;
display: block;
font-size: 14px;
font-weight: 300;
margin-top: 10px
}
<div class="table-fill">block 1</div>
<div class="table-fill">block 2</div>
<div class="table-fill">block 3</div>
<div class="table-fill">block 4</div>
<div class="table-fill">block 5</div>
<input type="submit"/>
或者制作一个容器并使用flex
,这将使表格的自动居中更加容易:
.container {
display: flex;
align-items: center;
justify-content: center;
}
.table-fill {
background: white;
border-radius:3px;
border-collapse: collapse;
border-color: 1px solid #000;
height: 120px;
max-width: 100px;
padding:5px;
margin: 5px;
width: 100%;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.8);
animation: float 5s infinite;
}
input[type=submit] {
padding:10px 15px;
background:#ccc;
border:0 none;
cursor:pointer;
-webkit-border-radius: 5px;
border-radius: 5px;
margin: auto;
display: block;
font-size: 14px;
font-weight: 300;
margin-top: 10px
}
<div class="container">
<div class="table-fill">block 1</div>
<div class="table-fill">block 2</div>
<div class="table-fill">block 3</div>
<div class="table-fill">block 4</div>
<div class="table-fill">block 5</div>
</div>
<input type="submit"/>