Your sites Log in Sign up Menu

Centering navigation on Blog template on mobile only?

I'm using a forked version of the Blog template for Tangible Life. I like the desktop layout with left and right justified elements, but they look odd on mobile size classes. How can I achieve a centered blog title, then Pages and Search/RSS icons centered below that on mobile only?


4 months ago, 3 replies   developers   blog-template   Improve this question

You'll want to amend your template's CSS file and add a set of conditional rules to center the header when the viewport size is small, e.g.

@media screen and (max-width: 600px) {
        ...
}

Those rules will vary depending on the specifics of what you're trying to accomplish but happy to answer any questions you have

Answered 4 months ago · Improve this answer

Thank you. I've tried (and failed) to get the elements of the blog title, Pages and the search/RSS icons to center using the placeholder sections you have at the bottom of the Blog template that referend the @media code. Any tips for what I'm doing wrong with just this simple example for the blog title/#logo may point me in the right direction. This CSS seems to have no bearing on that element at any screen size I've tested with (including just collapsing the browser window to a more narrow width and mobile devices).

@media screen and (max-width: 600px) {

#logo {
      display: block;
    width: 100%;
      margin: 0;
      align-content: center !important;
}
  .main, .margin {width: 100%;}
  .wide {width: 100vw;margin-left: -2rem;margin-right: -2rem}
  .wide.right {margin-left: 0;margin-right: 0;width:100%;}
  .margin {left: auto;position: relative;padding-left: 0}

}
Answered 4 months ago · Improve this answer

Have you checked using the developer tools on your web browser whether the CSS you have added is applying to the elements you are trying to center?

Answered 4 months ago · Improve this answer