Stack Overflow em Português Asked by the witcher0 on January 2, 2022
O menu deve ser fixo e por isso usei o position: fixed;
. Quando uso o margin: auto
, que é para centralizar uma div
, não funciona…
#menubarra {
position: fixed;
height: 50px;
width: 80%;
background-color: #cccccc;
border-radius: 5px;
}
<div id="menubarra"></div>
Fixed
fica relativo ao viewport
, então vc tb tem que declarar um left
e right
para o elemento
#menubarra {
position: fixed;
height: 50px;
width: 80%;
background-color: #cccccc;
border-radius: 5px;
margin: auto;
left: 0;
right: 0;
}
<div id="menubarra"></div>
Answered by hugocsl on January 2, 2022
1 Asked on October 25, 2020 by raffa-ferreira
1 Asked on October 22, 2020
1 Asked on October 21, 2020 by gonalo
1 Asked on October 21, 2020 by leonardo-vinicius
0 Asked on October 20, 2020 by fabrcio-pinheiro-dos-santos
1 Asked on October 14, 2020 by gleison
1 Asked on October 10, 2020 by userdel
1 Asked on October 9, 2020 by andr-machoski
2 Asked on October 7, 2020 by thaissa
3 Asked on October 6, 2020 by leandro-marzullo
1 Asked on September 29, 2020 by nfe
1 Asked on September 23, 2020 by ivan-ferrer
0 Asked on September 22, 2020 by bruno-maciel
0 Asked on September 21, 2020 by igor
1 Asked on September 13, 2020 by ramonvicente
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP