Here is my HTML and CSS :
@import url("https://fonts.googleapis.com/css2?family=Inter&family=Montserrat:wght@100;200;300;500&family=Nunito+Sans:wght@300&display=swap");
* {
list-style: none;
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: "Montserrat";
}
nav {
display: flex;
width: 100%;
margin: 0;
align-items: center;
}
nav ul {
display: flex;
text-transform: uppercase;
justify-content: space-between;
align-items: center;
}
nav ul li {
display: flex;
justify-content: space-between;
}
<!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>Gaming Campus</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<nav>
<ul>
<li>Accueil</li>
<li>Business school</li>
<li>Ecoleesport</li>
<li>Cours de jeuvidéo</li>
<li>Le campus</li>
<li>Newsroom</li>
<li>Parents</li>
<li>FR/EN</li>
</ul>
</nav>
</body>
</html>
For some reason, space between doesn’t seem to work : the elements won’t space and stay glued together, I have no idea why given it’s parent (nav) is set to occupy 100% of the width of it’s own parent (body). Any idea ?
Thanks
2
Answers
Since nav has display flex, the ul is not 100% width.
Either remove
display: flex
from nav,or add
width: 100%
to the ul if you must have display: flex on navhttps://jsfiddle.net/e3rgmpuz/ shows both uses
FWIW not a direct answer but I tend to prefer
grid
and put a grid-gap in.I put ugly borders on to show what is where.