How to Fix Twenty Fourteen Header Image Not Stretching to Full Width
Content
A common issue reported by users of the Twenty Fourteen theme is that the header image does not stretch to the full width of the screen, leaving unwanted white space on the sides. This problem typically occurs after users modify their site's layout to be full-width but discover the header image remains constrained to its original maximum dimensions.
Why This Happens
The Twenty Fourteen theme is designed with a fixed maximum width for its content and header. The default header image size is 1260 pixels wide. When CSS is used to make the overall site layout full-width (e.g., max-width: 100%;), the container for the header expands, but the image itself is still served at its cropped, predefined size. This creates a discrepancy where the header space is full-screen, but the image within it is not.
Common Solutions
1. Use a High-Resolution Header Image
Before attempting more complex solutions, ensure your source image is large enough to fill modern, wide screens. As seen in Thread 2, a user resolved their issue simply by using an image that met the recommended size. For a full-width design, your image should be significantly wider than 1260px; a width of 1920px or more is a good starting point.
2. Override Image Dimensions with CSS
The most straightforward fix is to use CSS to force the header image to scale to 100% of its container's width. You can add the following code to your theme's "Additional CSS" section or your child theme's style.css file.
#site-header img {
width: 100% !important;
height: auto !important;
}
This code tells the browser to make the image fill the entire width of its parent container while maintaining its aspect ratio. The !important rule helps ensure this declaration overrides any other conflicting styles.
3. Modify the Theme's Header Image Size (Advanced)
For users who are comfortable with code and are using a child theme, a more permanent solution is to change the theme's default header image size. This requires adding a function to your child theme's functions.php file. Note: Incorrectly editing this file can cause errors, as shown in Thread 3, so proceed with caution and always have a backup.
function my_custom_header_setup() {
$args = array(
'width' => 1920, // New width in pixels
'height' => 400, // New height in pixels
'flex-width' => true, // Allows the width to be flexible
'flex-height' => true, // Allows the height to be flexible
);
add_theme_support( 'custom-header', $args );
}
add_action( 'after_setup_theme', 'my_custom_header_setup' );
This code redefines the supported header image dimensions, allowing you to upload and use a much larger image. After adding this code, you will need to re-upload your header image.
Important Considerations
- Child Theme: Always use a child theme when modifying theme files (like functions.php) to prevent your changes from being overwritten during a theme update.
- Image Quality: Using a very large image can impact page load speed, especially on mobile devices. Consider using responsive image techniques or a plugin to serve optimized images.
- Mobile View: A full-width desktop header may not look good on mobile. You may need additional CSS media queries to adjust the header's appearance on smaller screens, as mentioned in Thread 17.
By following these steps, you should be able to successfully create a full-width header image for your Twenty Fourteen theme.
Related Support Threads Support
-
Stretch header image to full screenhttps://wordpress.org/support/topic/stretch-header-image-to-full-screen/
-
headerhttps://wordpress.org/support/topic/twenty-fourteen-header/
-
Header Issue Twenty Fourteen Themehttps://wordpress.org/support/topic/header-issue-twenty-fourteen-theme/
-
Header Image Background Colourhttps://wordpress.org/support/topic/header-image-background-colour/
-
2014 Theme -header image not full size on Full Screen Monitorhttps://wordpress.org/support/topic/2014-theme-header-image-not-full-size-on-full-screen-monitor/
-
Featured Header Image Not Properly Aligned?https://wordpress.org/support/topic/featured-header-image-not-properly-aligned/
-
after update to sql 5.7 header image not showinghttps://wordpress.org/support/topic/after-update-to-sql-5-7-header-image-not-showing/
-
header image full size problemhttps://wordpress.org/support/topic/header-image-full-size-problem/
-
Header image widthhttps://wordpress.org/support/topic/header-image-width-4/
-
Header Image Clickablehttps://wordpress.org/support/topic/header-image-clickable-1/
-
How to make the header image responsive?https://wordpress.org/support/topic/how-to-make-the-header-image-responsive-1/
-
how do i stretch single post header images like this one?https://wordpress.org/support/topic/how-do-i-stretch-single-post-header-images-like-this-one/
-
Can The Header Be Made Wider Than 1260?https://wordpress.org/support/topic/can-the-header-be-made-wider-than-1260/
-
Changing the Banner Sizehttps://wordpress.org/support/topic/changing-the-banner-size/
-
Header image(s)https://wordpress.org/support/topic/header-images-15/
-
Few challendges with the theme related to post font and header imagehttps://wordpress.org/support/topic/few-challendges-with-the-theme-related-to-post-font-and-header-image/
-
change the site-header image on mobilehttps://wordpress.org/support/topic/change-the-site-header-image-on-mobile/
-
Increased the side of my header image to match the new full page widthhttps://wordpress.org/support/topic/increased-the-side-of-my-header-image-to-match-the-new-full-page-width/