Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

javascript - Display:flex not working when added into my css no matter what I try

My css and html looks like this:

#TopBar{
    

display: flex;
justify-content: space-between;
z-index: 1;
position: fixed;
top: 0px;
left: 0px;
background-color: rgb(25,25,25);
height:115px;
width: 2000px; 
}
#Logo{

    
top: 0px;

height: 110px; width: 110px;
display: inline-block;

z-index: 2;
background-size: contain;
}
.NavList{

color: grey;
text-decoration: none;
font-family: Arial;
font-size: 30px;
margin-top: 1.3%;
z-index: 3;
}
    

<div id = TopBar>
<ul style = "list-style-type:none;">
<a class = NavList id = NavHome href = "../index.html">HOME</a>
<a class = NavList id = NavLogin href = "AccountPage.html" onclick = 
"account()">ACCOUNT</a>
<a class = NavList id = NavAccount href = "../Rules 
Page/Rules.html">RULES</a>
<a class = NavList id = NavDark href = "FillerPage.html">LIGHT</a> 
</ul>
</div>
<a href="https://google.com"><img src="../Images/VenomLogo5.png" id = "Logo"> 
</img></a>
</div>
</head>

Whenever I add flex or any other things along with it like justify content it doesn't do anything, and I have no idea what I am doing wrong. I feel like it's very simple but I can't figure it out. Thanks in advance!

question from:https://stackoverflow.com/questions/66056745/displayflex-not-working-when-added-into-my-css-no-matter-what-i-try

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

See if this is what you want. You need to set the width in ul and set it to the flex container. Then you are able to add the space-between .

For the css part, I use the SCSS so that you can write nesting css.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...