Log in Sign up

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?


a year ago, 3 replies   developers   blog-template   Edit 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 a year ago · Edit 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 a year ago · Edit 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 a year ago · Edit answer