简体   繁体   English

当使用浮动对齐徽标时,header 变得不稳定 HTML

[英]When aligning the logo using float the header goes wonky HTML

So I'm extremely new to html and css and I want to create a website.所以我对 html 和 css 非常陌生,我想创建一个网站。 But when I use float: left;但是当我使用 float: left; to make my logo stay to the left, the header goes wonky.为了让我的标志保持在左边,header 变得不稳定。

https://jsfiddle.net/bm0dynw6/ https://jsfiddle.net/bm0dynw6/

 .logo { float: left; }
 <div class="header"> <img class="logo" src="PolyNOTEMBLEM.png" width="330" height="82.5" /> <button id="Home" class="tablink" onclick="window.location.href='[Redacted]'" > Discord invite </button> </div>

You can use您可以使用

.header::after {
    display: block;
    clear: both;
    content: "";
}

or或者

.header {    
    display: flex;
    justify-content: space-between;
}

and remove the float:left from logo并从徽标中删除float:left

USE THIS用这个

.header {    
    display: flex;
    align-items:flex-start;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM