我尝试修复导航栏但是当我将position:fixed
添加到css时它会向左流动
.grid__header {
position:fixed;
min-height: 164px;
height: 164px;
width:100%;
display: -webkit-flex;
display: flex;
background: transparent;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-justify-content: space-between; /* Safari 6.1+ */
justify-content: space-between;
}
容器类不会.grid__header
起作用。如何解决?
答案 0 :(得分:4)
当您添加position:fixed
时,它会向左移动,使其居中,将以下CSS添加到.grid__header
position:fixed; left:0; right:0;
答案 1 :(得分:2)
Position
需要从left
和top
指定其位置。
.grid__header {
position:fixed;
left:0; right:0;
min-height: 164px;
height: 164px;
width:100%;
display: -webkit-flex;
display: flex;
/* background: transparent; */
background:#ccc;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-justify-content: space-between; /* Safari 6.1+ */
justify-content: space-between;
}
/*##setting height just for display##*/
body{height:1500px;margin:0;padding:0;}
<header class="grid__header"></header>