I have this page, it only has an image on it right now but since I'm pretty new to this I thought that would be enough. On a normal desktop screen, I want the image to be left-aligned. And that's how it is. But when it's in portrait mode, and the max-width is 480px, I want the image to be centered, horizontally.
My code is:
@media (max-width: 480px)
{
img
{
display: block;
margin-left: auto;
margin-right: auto;
}
}
Now, the above code works great on the computer. When my PC is in landscape mode and the max-width is greater than 480px, the image is left-aligned. And when I put my PC in Portrait and Shrink the browser window's width to less than 480px the image becomes centered.
But this does not work on my phone. My phone's width is 480px. Why isn't is working then? I don't understand.