← Desenvolvimento

Centrar CSS

Lida 1896 vezes

Offline

João Madeira 
Membro
Mensagens 655 Gostos 1
Feedback +3

Troféus totais: 25
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 4 Level 3 Level 2 Level 1

Olá alguem me consegue explicar como centrar uma imagem em css.

Deixo aqui o que quero centrar:

#menu {
   font-size: 1em;
   margin: 0px;
   padding: 0px;
   height: 41px;
   background-image: url(imagens/bar1.png);
   width: 805px;
}
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Queres centrar a imagem de fundo? Procura no google por background-position css
Offline

João Madeira 
Membro
Mensagens 655 Gostos 1
Feedback +3

Troféus totais: 25
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 4 Level 3 Level 2 Level 1

Consegui, muito obrigado!
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

margin: 0 auto;

Provavelmente isto funcionará, mas sem saber o resto do código não te posso dar certezas.
Offline

spec 
Elite
Mensagens 989 Gostos 1
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

background-position: top center;

...por exemplo
Offline

Cacofb 
Elite
Mensagens 1036 Gostos 3
Troféus totais: 34
Trófeus: (Ver todos)
Level 6 Tenth year Anniversary Linux User Mobile User Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter

margin: 0 auto;

Provavelmente isto funcionará, mas sem saber o resto do código não te posso dar certezas.

Também uso esse.
Podes sempre fazer umas continhas e dividir isso também.