我有居中CSS六邊形的問題。我不確定這是如何完成的,所以如果有人能幫忙,我會很感激。完整的代碼與結果是here。提前致謝。居中CSS六角形
.container {
width: 1000px;
line-height: 1.3;
}
ol.even {
position: relative;
left: 5.45455em;
}
ol.odd {
position: relative;
margin-top: -6.5%;
margin-bottom: -6.5%;
}
.hex {
position: relative;
margin: 1em auto;
width: 6em;
height: 10.2em;
border-radius: 1em/.5em;
background: #74cddb;
transform: rotate(-90deg);
display: inline-block;
margin-right: 4.61538em;
transition: all 150ms ease-in-out;
}
.hex a {
display:block;
}
.hex:before, .hex:after {
position: absolute;
width: inherit; height: inherit;
border-radius: inherit;
background: inherit;
content: '';
}
.hex:before {
transform: rotate(60deg);
}
.hex:after {
transform: rotate(-60deg);
}
你能更好地解釋一下你的意思是「居中」嗎?水平居中在頁面寬度? –
水平和垂直。 – Da1T
你是否搜索了'垂直中心div'? - http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/ – Lee