Bootstrap Navbar Centered Vertical Alignment

Recently I was working on a website layout using Bootstrap for which the design called for a large logo image as the navbar brand, with the navbar entries vertically centered with it. I thought “Yo, that’s crazy, there’ll be a lot of dead space in the navbar,” but the designer just said “Yo, I am crazy, do it.”

There’s many StackOverflow questions and blog posts on vertically aligning a Bootstrap navbar, but most of them don’t really work. Worse, all of the working solutions I found involved manipulating the line height of the entries. Unfortunately, that also fails with an additional crazy designer requirement: The navbar entries might be multi-line, so playing games with line-height thus wouldn’t arrange each entry’s text correctly. Eventually I was able to work out the details of another approach using table-cell, shown in this post. As is typical with HTML/CSS, especially with Bootstrap thrown in, and double especially regarding vertical alignment, the actual code is really short and seems obvious, but is much less so when trying to work out the magical incantation from scratch.

This demonstration is built on a Bootstrap’s Starter Templates, showing a navbar fixed to the top of the screen. I’ve just switched the navbar from navbar-inverse to navbar-default to use the lighter color scheme and added dummy text:

step00Note that the basic Bootstrap styling does not by default work with the fixed top, it obscures the page title. This is fixed in the last step of this demo.

Next I change the brand (“Project Name” in the template) to a large logo image and made one of the menu entries multi-line by fixing the width of the entries. The logo especially doesn’t work out well:

step01

Adjusting the Bootstrap navbar’s height requires adjusting the height of both the navbar and navbar-header class entries. The latter is used when the navbar is collapsed for small screens, to start the nav menu rolldown at the right place. Bootstrap’s default navbar brand top and bottom padding is 15px, so for my logo I increase the minimum height to 202px, 30px more than its height:

.navbar        { min-height: 202px; }
.navbar-header { min-height: 202px; }

step02

Moving on to the actual objective here, the first step is to vertically align the navbar entries among themselves along their middles. The easiest, most elegant way to do this is to change their display style to table-cell, which respects the vertical-align: middle property. There are two gotchas to this: The parent list must be set to display: table-row mode, and, more obscurely but sensibly in retrospect, the cells cannot be floats. Note that, unlike a few comments I did find, the parent container does not need to be in mode display: table. Thus:

      #navbar > ul {
      display: table-row;
      }
      
      #navbar > ul > li {
      display: table-cell;
      float: none;
      vertical-align: middle;
      }

step04

At this point the whole navbar line just needs to be shifted downward to center it with the logo. There is probably some convoluted mechanism or arcane invocation to do this automatically, but I’ve just been doing it by hand. To keep calculations simple I first add the padding to the navbar, and then shift the row down:

      #navbar {
      padding-top: 15px;
      }
      
      #navbar > ul {
      padding-top: 48px;
      }

step05
Note that for middle alignment it’s not necessary to set the height of the row, it just needs to be moved down by the padding.

After that the last tweaks are to center the cells and shift the page contents down below the heightened navbar:

      #navbar > ul > li {
      text-align: center;
      }

      body {
      margin-top: 202px;
      }

step06

Unfortunately this doesn’t really work well when the navbar collapses into the mobile navigation list dropdown:

step07

To address that, all of the above needs to be wrapped in a media query such that the stylings only take effect when the navbar is not collapsed. By default in Bootstrap this is when the window is at least 768px wide:

      @media (min-width: 768px) {

        #navbar {
        padding-top: 15px;
        }
      
        #navbar > ul {
        display: table-row;
        padding-top: 48px;
        }
      
        #navbar > ul > li {
        display: table-cell;
        float: none;
        vertical-align: middle;

        text-align: center;

        width: 80px;  /* crazy designer's fixed-width, multi-line entries */
        }
      }

step08

And with that, the objective of vertically centering multi-line entries with a large logo in a Bootstrap navbar is accomplished. #victory!

Mortalis Solypsus WIP

banner

Yesterday Colin and I got started on construction for the July PAGE/Redcap’s 40k event: Mortalis Solypsus. A bit over-ambitiously, we intend to run a full day of Zone Mortalis-styled games, capturing the fighting inside the Lab, Mine, and other installations of Solypsus 9. Note that the fluff here is that you’re fighting in huge facilities. Vehicles can fit through part of them, but may not be able to make it into narrower sections or rooms. Think NORAD, not office building.

Everybody should take note of the draft rules being collected on the event page. There are a number of restrictions and special rules to suit the indoor fighting. A basic restriction is that large vehicles are outright not permitted. Further, even permitted larger models like Dreadnoughts will not have full mobility throughout a board as they won’t fit through doorways and such. An example special rule is that blasts and templates gain Shred, and only scatter and take effect within the confines of the walls.

Although there’s a long way to go, we wanted to post some notes and pictures for both players thinking about what armies to prepare, and for the other hobbyists building boards for the event to follow along. As the boards are being constructed by several people and using a variety of styles, they will definitely vary a bit. But this is roughly how most of them will work.

If you are committed to playing in the event, please sign up on the Doodle poll so we can plan appropriately.

Colin starts measuring out walls.

Colin starts measuring out walls.

Layout

The game boards will all be 4×4, to suit the 1000 point armies. They are made up of 2×2 or 1×1 tiles, to give some variety in laying out a board. Each tile has a fixed layout of walls making corridors, generally along an 8×8 or similar grid. This gives just enough room for small vehicles such as a Rhino to move through, but in a somewhat restricted way. With other models present or scatter terrain such as debris, containers, or consoles, it may be difficult to have them turn in place and such to head in a new direction.

Line of sight is very limited by the walls. A number of walls do have doorways, but they’re staggered such that even with all of them open there is no line of sight across the board. Indirect attacks are in general not permitted, see the rules for details. Close up shooting and assault will definitely be emphasized compared to a normal game.

One of Colin's 2x2 tiles.

One of Colin’s 2×2 tiles.

Doorways

The doorways on our canonical board design are 2 inches wide and tall. This means anything up to about a Space Marine Centurion can easily move them them. Dreadnoughts, monstrous creatures, and other large models simply won’t fit. Although the tile designs generate discourage fully enclosed spaces, it will certainly be possible for troopers to huddle up away from a bigger foe and force it to take a roundabout route to them and the objective they are defending for the corpse god and/or false idols.

It doesn’t matter for gameplay purposes because they’re treated as an infinite surface, but for building purposes, the walls should be 3 to 4 inches tall. Many models need at least a 3″ wall to look right. At 4″ though the walls start to feel pretty cavernous against infantry, which might be an appropriate look for some themes.

A Kingbreaker checks out his new digs.

A Kingbreaker checks out his new digs.

Burn It Down!

Again, take a look at the draft rules to see some of the changes and special effects. And, if you are committed to participating, please sign up on the Doodle poll so we know how many people to expect.

Two WIP tiles together.

Two WIP tiles together.

Tournament of Blood

Sunday we held our monthly 40k event at Redcap’s. Six players came out despite being summer break for the colleges, Sunday, and Father’s Day to boot. Armies featured Space Marines, Blood Angels, Khorne Daemonkin, Chaos Space Marines, Chaos Daemons, and Tyranid. A few more photos than those here are in the gallery. Full results are on the event webpage.

Michael's excellent converted Knight ally stalks the ruins for its Tyranid masters.

Michael’s excellent converted Knight ally stalks the ruins for its Tyranid masters.

Missions

This time around the core of the event was a straight competition, rather than the alliances and deliberative pairings we’ve been doing recently. Matchups were all paired individually in pure tournament fashion and the missions straightforward. The one note with them is that I’ve begun experimenting again with players choosing continuous versus final objective marker scoring for their primary objective. It seemed to work well within our overall format, which already gives substantial strategic options via the choice of secondary objectives. An even mix of players chose each primary objective mechanism, a good sign.

Colin also made the point that our Maelstrom missions should always include our Meatgrinder (kill Troops), Assassination (kill characters), or similar secondary objective options, to help counter armies overtuned for that format—namely the updated Space Marines. I had been doing so as part of the overall goal of balancing primary missions oriented toward ground control with several kill points options (alongside a ground control option to double down on that), and vice versa. I had not though thought of that specifically as a way to help neuter those armies a bit, so it was a good observation to keep in mind.

The Tournament of Blood

Keeping with our goal of including narrative components or other side tracks alongside the tournament competition, we did run one small thematic aspect: The Tournament of Blood! Each player got a card of achievements their warlord could work toward throughout the day. At the end of each game they marked off particular accomplishments for their boss, and were scored separately and a prize given purely on those points.

This seemed to work out pretty well. With the players warned in advance, most of the chosen warlords came ready to fight. I do think though that there’s enough diversity among the achievements for factions that don’t have characters suited for direct combat to still score well. Several account for a support oriented or backfield command role, and ultimately those players can just focus on the primary missions anyway.

In the end there was a good distribution of achievements scored. Obviously they mostly tracked with overall success, but some players did focus more or less on the achievements. The second highest player in the general scoring came out last on the achievements, while the second highest warlord came out second to last in the general scoring. The two of them just had different priorities and capabilities, exactly what we’re trying to support. The latter in particular came out specifically for this event because his warlord’s a great character with a whole background story and such that he wanted to have fight the others, so I considered that a success. The one minor presentation tweak I have to make is having a place to scribble the warlord character’s name on the card, for the post-event storytelling.

Warlord achievements in The Tournament of Blood.

Warlord achievements in The Tournament of Blood.

Titles

So, with that, we announce the titles for the inaugural Tournament of Blood:

  • The Lord of the Cheese: Alex, Swords of Dorn (12pts)
  • The Young Pup: TJ, Sanguine Hunters (12pts)
  • The Berzerker: Chris, Chaos Space Marines (11pts)
  • The Old Gods’ Faithful: Colin, Daemonkin (9pts)
  • The Slowballer: Brett, Chaos Daemons (4pts)
  • The Lonely Xenos: Michael, Tyranids (3pts)

Again, a few more photos than those here are in the gallery and full results are on the event webpage.

The Swords of Dorn battle Chaos horrors among ravaged forests.

The Swords of Dorn battle Chaos horrors among ravaged forests.