I've been diligently working on a unique custom WordPress theme as part of a school project. Our task is to redesign the homepage of an association, in my case, a theater group.
One of the challenges I encountered was customizing the WordPress menu to include images for the four pages. Despite using width: auto
in the CSS, the <nav>
element containing these images ended up wider than expected. In an attempt to fix this, I resorted to repositioning the <nav>
using margin-right: -133px;
, which doesn't feel like the ideal solution.
Here is the HTML for the top banner (extraneous code removed for clarity):
<header role="banner" id="branding">
<a href="http://dev.zomis.net/talat/">
<img alt="" src="http://dev.zomis.net/talat/wp-content/themes/talat/talat-logo.png" id="header_logotype">
</a>
<nav role="navigation" id="access">
<a href="http://dev.zomis.net/talat/forening">
<img src="http://dev.zomis.net/talat/wp-content/themes/talat/talat_meny_forening_gray.jpg" id="menu_image_forening" class="menu_image">
</a>
<a href="http://dev.zomis.net/talat/scen">
<img src="http://dev.zomis.net/talat/wp-content/themes/talat/talat_meny_scen.jpg" id="menu_image_scen" class="menu_image">
</a>
<a href="http://dev.zomis.net/talat/film">
<img src="http://dev.zomis.net/talat/wp-content/themes/talat/talat_meny_film_gray.jpg" id="menu_image_film" class="menu_image">
</a>
<a href="http://dev.zomis.net/talat/natverk">
<img src="http://dev.zomis.net/talat/wp-content/themes/talat/talat_meny_natverk_gray.jpg" id="menu_image_natverk" class="menu_image">
</a>
<div class="menu-talat-container"><ul class="menu" id="menu-talat"></ul></div>
</nav>
</header>
To highlight the issue, I have colored the entire header
element in red and the nav
element in yellow.
Even after extensively using Firebug to troubleshoot, I am unable to pinpoint the source of the problem. While suspecting the empty
<div class="menu-talat-container">
within the <header>
, removing it temporarily doesn't seem to make a difference.
You can view the page here:
An image illustrating the issue, with the perplexing yellow part identified as "Why is this yellow part sticking out to the right?":
Upon removing the margin-right
property, the question shifts to "Why is there no image here?":