Egal, was ich mache (seit ein paar Stunden), ich kann die <div class="kafelek">
nicht nebeneinander ausrichten; der aktuelle Code sieht so aus:
body { background-color: #003C3D; } .header { text-align: center; align-content: center; padding: 20px; font-family: 'Open Sans'; font-size: 24px; color: #C3CECB; } #headerlogo { width: 400px; height: auto; object-fit: cover; position: absolute; top: 20px; left: 50%; transform: translateX(-50%); animation: slide-in 1s ease-in-out forwards; } @keyframes slide-in { from { top: -100px; } to { top: 20px; } } .pre1 { width: 50%; text-align: center; align-content: center; font-family: 'Open Sans'; font-size: 24px; color: #C3CECB; float: left; } .pre2 { width: 50%; text-align: center; align-content: center; font-family: 'Open Sans'; font-size: 24px; color: #C3CECB; float: right; } .alignkafel1, .alignkafel2 { display: flex; flex-wrap: wrap; } .row { display: flex; } .kolumna { display: inline-block; width: 48%; font-family: 'Open Sans'; color: #C3CECB; text-align: center; display: flex; flex-wrap: wrap; justify-content: space-between; } .kolumna:first-child { margin-right: 0px; } .kolumna:last-child { margin-left: 0px; } .row:after { content: ""; display: table; clear: both; } @media screen and (max-width: 800px) { .kolumna { width: 100%; align-content: center; } } kolumna2 { display: inline-block; width: 48%; font-family: 'Open Sans'; color: #C3CECB; text-align: center; display: flex; flex-wrap: wrap; justify-content: space-between; } .kolumna2:first-child { margin-right: 0px; } .kolumna2:last-child { margin-left: 0px; } @media screen and (max-width: 800px) { .kolumna2 { width: 100%; align-content: center; } } .kafelek { background-color: #006D57; border-radius: 10px; text-align: center; height: 100px; font-family: 'Open Sans'; font-size: 20px; color: #C3CECB; margin: 5px; margin-top: 50px; margin-right: 50px; margin-bottom: 1px; margin-left: 30px; display: flex; align-items: center; justify-content: center; } @media screen and (max-width: 800px) { .kafelek { display: flex; justify-content: center; } } .kafelek:hover { border: 2px solid #7EDF00; transition: 0.3s; cursor: pointer; }
<div class="header"> <img src="" img id="headerlogo" /> <br /> <br /> Centrum zgłoszeniowe AOK </div> <div class="pre1"> Delivery Support </div> <div class="pre2"> Middle Mile</div> <div class="alignkafel1"> <div class="kafelek">Koszta Dodatkowe</div> <div class="kafelek">COMING SOON</div> <div class="kafelek">COMING SOON</div> <div class="kafelek">COMING SOON</div> </div> <div class="alignkafel2"> <div class="kafelek">COMING SOON</div> <div class="kafelek">COMING SOON</div> <div class="kafelek">COMING SOON</div> <div class="kafelek">COMING SOON</div> </div>
Ich habe mehrere Optionen ausprobiert, aber am Ende war alles ein Chaos.
Es sieht so aus: Website-Chaos
Ich möchte, dass jede der 8 .kafelek
(d. h. Schaltflächen) in einer Reihe perfekt aufeinander ausgerichtet und richtig zentriert ist, um mit .pre1 und .pre2
Bitte helfen Sie;-;
按钮容器的宽度为 0,这会阻止弹性盒正常工作。添加宽度可以解决问题。
我添加了
60%
的宽度,以使按钮与上面的pre
大致对齐。目前,pre
设置了float
属性。理想情况下,您希望父容器强制执行页面内容的边界并避免使用float
css 属性。