I am trying to center the follow
div so it appears centered horizontally, but it’s not working.
This is what I have tried:
<div class="logo" style="margin: 0px auto; display: table-cell;">
<img src="images/nm-logo.png" />
Is it possible to center the
div with the
logo without giving it a
width? If not, I think I will just give it a fixed width.
Use display:table not table-cell and then it will centre horizontally.
Thank you, that has now centered it.
However, the logo image is appearing on a separate line to the logo-text
div. I’m wondering if this is because nothing has a set
It’s because logo-text is a block element (div) unless you have styled it differently.
You don’t show the styles associated with those elements so I can’t second guess what you have done.
Block elements like divs will of course naturally start on a new line unless you tell them not to.
Sorry, this is the CSS:
margin: 0px auto;
margin: 0 0 15px; 0
I’ve tried using display: flex which aligns the items on one line, but it doesn’t then center the whole thing.
I have created a fiddle:
Thank you, that worked great
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.