What could be causing the background of the wrapper image not to display?

I am looking to add a background image specifically within the wrapper div on my website. Below is the HTML document:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <title><?php echo get_bloginfo_rss('name'); ?> | <?php echo get_bloginfo_rss('description'); ?></title>
    <link rel="shortcut icon" href="<?php echo get_template_directory_uri (); ?>/genericons/favicon.ico" type="image/x-icon"/>
    <link rel="icon" href="<?php echo get_template_directory_uri(); ?>/genericons/favicon.png" type="image/png"/>
    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/style.css" type="text/css"/>
    <?php wp_head(); ?>
</head>
<body>
    <div id="wrapper">

        <?php wp_footer(); ?>

    </div>
</body>
</html>

Here is the content of my CSS file:

body {
    background-color: #020111;
}

#wrapper {
    background-image: url('http://example.com/wp-content/themes/theme/background.jpg');
    background-color: #020111;
    background-size: cover;
    width: 960px;
    height: auto;
}

I have tried adding the snippet both in the CSS body section and through inline styling for the body tag, but I want the background to be applied only to the wrapper. However, it does not seem to be working as expected!

    body {
      background-color: #020111;
    }
    #wrapper {
      background-image: url('http://example.com/wp-content/themes/theme/background.jpg');
      background-color: #020111;
      background-size: cover;
      width: 960px;
      height: auto;
    }
<div id="wrapper">

some text

</div>

Answer №1

It appears that your div is empty and has collapsed, with a height of 0. However, adding padding-top: 200%; to your CSS worked on my local machine. I found the solution here need-empty-div-with-background-image-to-force-height-and-must-be-responsive

Alternatively, setting width to 1920px and height to 1080px also produced the desired result.

Answer №2

To boost your height, consider adjusting the padding. If adding more padding affects the design negatively, try increasing only one aspect such as bottom-padding:50px; etc

I believe this solution will be beneficial for you. Thank you

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for safeguarding against the insertion of scripts into input fields

Is there a method to stop users from inputting scripts into text fields or text areas? function filter($event) { var regex = /[^a-zA-Z0-9_]/; let match = regex.exec($event.target.value); console.log(match); if (match) { $event.pre ...

Display solely the initial row in the tbody segment of a table. Is there a method to obscure subsequent 1st rows?

The initial row of each tbody acts as the row header, containing the column names. Subsequent rows in each tbody are unnecessary and should be hidden. Classes utilized: toprowHeader = first row containing column names recordsRow = holds additional recor ...

How to eliminate the checkbox attribute when using jQuery's clone function

When I try to add a new row using my script code and HTML, the property of the last checkbox is automatically selected if it is checked. In the new row, a checkbox with a check is added, but I want to remove the checkbox when it's checked in the new r ...

Swap the image when hovering over it

Is it possible to modify this specific code so that a hover effect is triggered on mouseover? I attempted to look into similar questions and answers, but I found them difficult to understand. Here is the HTML snippet: <a href="RR.html"><img src ...

What strategies can be implemented to decrease the value of the writing box by 2.5%?

I would like to decrease the value in the input box by 2.5%. Here is the HTML code snippet: <div class="ZakatCalc"> <div class="calcimg"> <img src="" alt="" srcset="" class=" ...

What is the reason for index always being not equal to 0?

<script> var index = 0; $.getJSON("./data/data.json", function(json) { $.each(json, function(data) { var html = ""; if(index == 0) { console.log(index + " fir ...

Having a concise way to submit forms with Javascript and JQuery

Seeking a more concise way to submit form data to Electron in JSON format as a beginner in JavaScript and jQuery. How can this code be rewritten for brevity? <section> <input id="server" type="text" placeholder="Server"> <i ...

Fill the next Thursday with JavaScript

I'm having trouble updating the date for the upcoming Thursday using JavaScript. The current script works fine until the end of the month, but if it's the 25th of August, the output will be "Next Thursday - 8/32/2022". I need a more intelligent s ...

Mastering Tooltip Placement Using CSS or JavaScript

I have been working on creating a CSS-only tooltip for a web application and so far I have managed to create some useful tooltips with different classes: tooltip-up tooltip-down tooltip-left tooltip-right The distinguishing factors between them are t ...

Error Type Not Caught on Console

Could you please help me understand the error message below? I'm not very familiar with JavaScript. Uncaught TypeError: $(...).sss is not a function at HTMLDocument.<anonymous> (codejs.js:3) at i (jquery.min.js:2) at Object.fireWith [as resolve ...

Modify the design of the button in the CSS code

I am facing an issue with the layout of the Visible Columns button and unable to standardize it like the buttons above using CSS enter image description here The code snippet for the Visible Columns button is as follows: import React, { useState, useEffe ...

Increase the gap between columns in Bootstrap for a better layout

I have implemented a web layout using bootstrap 3. You can view the JSFiddle here. In order to make the layout responsive, I had to structure it in a slightly unconventional way. The final output on small screens includes three information boxes within an ...

Can you provide instructions on how to use jQuery to target divs similarly to selecting areas in Photoshop?

Is it possible to use jQuery to select a group of div elements on specific positions, similar to how you would select objects in Photoshop using the mouse? ...

What is the best way to determine the size of the URLs for images stored in an array using JavaScript?

I am working on a project where I need to surround an image with a specific sized 'div' based on the image's dimensions. The images that will be used are stored in an array and I need to extract the height and width of each image before disp ...

`Issues with CSS/JQuery menu functionality experienced in Firefox`

After creating a toggleable overlay menu and testing it in various browsers, including Internet Explorer, everything seemed to work fine except for one major issue in Firefox (version 46). The problem arises when toggling the overlay using the "MENU" butt ...

Exploring the process of constructing this form with the assistance of Bootstrap

Create Dropdown Form https://i.sstatic.net/rqJtS.png I am looking to create a form that allows for updating team scores based on kills. I am struggling to divide the form into 2 sections for input, as demonstrated. I am using only bootstrap for styling, ...

perform an action if any division element is void of content

Currently, I have a statement that checks if any of the Divs with the ID #Drop are empty. If one is found to be empty, an alert is shown. However, there seems to be an issue where the statement stops working when any div contains content. What I am trying ...

Words existing outside of an element

Currently, I am developing a slider using Bootstrap, and I have encountered an issue where the text displays on the left instead of aligning to the center in relation to the elements. To see this issue in action, you can check out the live demo here: In ...

issues with auto-fill functionality in Firefox and Internet Explorer

I am looking to have my username and password automatically filled in when a user is already logged into the website. I have enabled autofill using the code below. Ideally, when a user visits the site again, both the username and password fields should be ...

Hovering over the Laravel Breeze dropdown will activate a dropdown feature

Recently, I've been working on a project with Laravel Breeze and have been utilizing some default components. The dropdown component used in the navigation bar caught my attention. By default, it requires a click for the menu to drop down below. Howev ...