<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lost and Found</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Anton&display=swap" rel="stylesheet">
</head>
<body>
<div class="nav" >
<img src="img.png" alt="logo" srcset="">
<div class="b"><span>Electronics</span></div>
<div class="b"><span>Plastics</span></div>
<div class="b"><span>Wearables</span></div>
<div class="b"><span>Others</span></div>
<input id="srch" type="search" value="Search">
</div>
<div class="main">
<div>
<h1 style="font-size: 60px;">Electronics</h1>
<h1 style="font-size: 60px; font-family:cursive; text-decoration: underline;">-Electronics</h1>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
</div>
</div>
</div>
</body>
</html>
*{
margin: 0px;
padding: 0px;
}
.nav{
background-color:bisque;
width: 100%;
height: 60px;
display: flex;
align-items: center;
position:fixed;
}
.b{
height: 60px;
width: 10%;
background-color: antiquewhite;
margin: 2px;
justify-content: center;
font-family: 'Anton', sans-serif;
border-radius: 20px;
align-items: center;
display: flex;
}
img{
width: 80px;
height: 60px;
}
#srch{
width: 10%;
height:60px;
right: 0%;
position:fixed;
font-size: larger;
}
.main{
height: 1700px;
width: 100%;
border-color: blue;
border-style: double;
background-color:lightgoldenrodyellow;
}
.head{
display: inline-block;
margin-top: 60px;
margin-left: 0px;
margin-right: 0px;
box-sizing: border-box;
width: 30%;
height: 250px;
border-color:red;
border-style: groove;
border-width: 5;
font-family: cursive;
font-size: larger;
}
.head 是盒子的類別,而 . main 是放置所有框的 div。其余代碼不應與此問題相關。如何讓盒子之間有均勻的空間?我需要在一行中有 3 個盒子。我是初學者,試圖學習 css、html 和 java 腳本。請幫忙
uj5u.com熱心網友回復:
.head-container{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.head{
display: inline-block;
margin-top: 60px;
margin-left: 0px;
margin-right: 0px;
box-sizing: border-box;
flex:0 1 30%;
height: 250px;
border-color:red;
border-style: groove;
border-width: 5;
font-family: cursive;
font-size: larger;
}
<div class="head-container">
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/450677.html
下一篇:行沒有完全填滿容器寬度
