我不知道我錯過了什么。我正在嘗試用這4件物品制作一個帶display:flex的2x2盒子。我現在能做什么?我不能讓它工作。我還將所有的div包裝到一個
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:700|Roboto:100,300,700');
html,body{
margin:0;
padding:0;
font-family: Roboto;
font-size: 10px;
line-height:3.5;
font-weight:300;
}
h1,h2,h3,h4,h5{
font-family:Roboto Condensed;
}
h1{
font-size:9em;
text-align:center;
text-transform:uppercase;
}
h2{
font-size:5em;
text-align:center;
text-transform:uppercase;
line-height:4em;
color:white;
text-shadow: #020819 8px -20px 9px
}
h3{
font-size:4.2em;
text-align:center;
line-height:1em;
margin-top:0;
}
h4{
font-size:1.5em;
letter-spacing:0.4;
line-height:1em;
}
h5{
font-size:1.2em;
line-height:1em;
margin-top:0;
margin-bottom:0;
}
.service-box{
font-size:1.7em;
text-align:center;
border:2px solid #eee;
border-radius:20px;
boxing-size:border-box;
box-shadow: 2px 2px 10px 0 #eee;
margin:50px 5% 0 5%;
padding:20px;
width:40%
}
.service-box img{
width:150px;
}
#structure div {
display: flex;
justify-content: space-between;
flex-direction:row;
flex-wrap: wrap;
}
<section id="structure " >
<div>
<article class="service-box" >
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-training.png">
<h3>Training</h3>
<p>We teach all the necessary things to jump from the plane without any kind of problem.</p>
</article>
</div>
<div >
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-get-ready.png" >
<h3>Get Ready</h3>
<p>You are already prepared, you just need the suit and a parachute. All sizes available.</p>
</article>
</div>
<div >
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-fly.png">
<h3>Fly</h3>
<p>You are ready, and the plane is waiting for us in the hangar. Let's fly</p>
</article>
</div>
<div >
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-jump.png">
<h3>Jump!</h3>
<p>You have done the most complicated. just one step left... jump!!</p>
</article>
</div>
</section>
你需要改變你的html的結構,也改變寬度:40%到寬度:40vw,你應該都設置好了
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:700|Roboto:100,300,700');
html,
body {
margin: 0;
padding: 0;
font-family: Roboto;
font-size: 10px;
line-height: 3.5;
font-weight: 300;
}
h1,
h2,
h3,
h4,
h5 {
font-family: Roboto Condensed;
}
h1 {
font-size: 9em;
text-align: center;
text-transform: uppercase;
}
h2 {
font-size: 5em;
text-align: center;
text-transform: uppercase;
line-height: 4em;
color: white;
text-shadow: #020819 8px -20px 9px
}
h3 {
font-size: 4.2em;
text-align: center;
line-height: 1em;
margin-top: 0;
}
h4 {
font-size: 1.5em;
letter-spacing: 0.4;
line-height: 1em;
}
h5 {
font-size: 1.2em;
line-height: 1em;
margin-top: 0;
margin-bottom: 0;
}
.service-box {
font-size: 1.7em;
text-align: center;
border: 2px solid #eee;
border-radius: 20px;
box-shadow: 2px 2px 10px 0 #eee;
margin: 50px 5% 0 5%;
padding: 20px;
width: 40vw;
}
.service-box img {
width: 150px;
}
.structure {
display: flex;
justify-content: space-between;
flex-direction: row;
flex-wrap: wrap;
}
<section class="structure ">
<div>
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-training.png">
<h3>Training</h3>
<p>We teach all the necessary things to jump from the plane without any kind of problem.</p>
</article>
</div>
<div>
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-get-ready.png">
<h3>Get Ready</h3>
<p>You are already prepared, you just need the suit and a parachute. All sizes available.</p>
</article>
</div>
</section>
<section class="structure ">
<div>
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-fly.png">
<h3>Fly</h3>
<p>You are ready, and the plane is waiting for us in the hangar. Let's fly</p>
</article>
</div>
<div>
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-jump.png">
<h3>Jump!</h3>
<p>You have done the most complicated. just one step left... jump!!</p>
</article>
</div>
</section>
你想要一個2x2的網格,因此你應該使用網格而不是Flexbox。
#structure {
display: grid;
grid-template-columns: 1fr 1fr;
}
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:700|Roboto:100,300,700');
html,body{
margin:0;
padding:0;
font-family: Roboto;
font-size: 10px;
line-height:3.5;
font-weight:300;
}
h1,h2,h3,h4,h5{
font-family:Roboto Condensed;
}
h1{
font-size:9em;
text-align:center;
text-transform:uppercase;
}
h2{
font-size:5em;
text-align:center;
text-transform:uppercase;
line-height:4em;
color:white;
text-shadow: #020819 8px -20px 9px
}
h3{
font-size:4.2em;
text-align:center;
line-height:1em;
margin-top:0;
}
h4{
font-size:1.5em;
letter-spacing:0.4;
line-height:1em;
}
h5{
font-size:1.2em;
line-height:1em;
margin-top:0;
margin-bottom:0;
}
.service-box{
font-size:1.7em;
text-align:center;
border:2px solid #eee;
border-radius:20px;
boxing-size:border-box;
box-shadow: 2px 2px 10px 0 #eee;
margin:50px 5% 0 5%;
padding:20px;
/* width:40% */
}
.service-box img{
width:150px;
}
#structure {
display: grid;
grid-template-columns: 1fr 1fr;
}
<section id="structure">
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-training.png">
<h3>Training</h3>
<p>We teach all the necessary things to jump from the plane without any kind of problem.</p>
</article>
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-get-ready.png">
<h3>Get Ready</h3>
<p>You are already prepared, you just need the suit and a parachute. All sizes available.</p>
</article>
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-fly.png">
<h3>Fly</h3>
<p>You are ready, and the plane is waiting for us in the hangar. Let's fly</p>
</article>
<article class="service-box">
<img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-jump.png">
<h3>Jump!</h3>
<p>You have done the most complicated. just one step left... jump!!</p>
</article>
</section>
上一篇python 暫停和回復
下一篇vue custom