The backdrop refuses to be shown

Recently, I picked up a project from codepen.io and made some modifications to it. However, I am currently facing an issue while trying to add a background image that won't display on the screen. Below is the snippet of my code:

body {
  background-image: url("starwars.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

div.window {
  color: white;
  width: 500px;
  padding: .42rem;
  border-radius: 5px;
  background: #26466D;
  margin: 1rem;
  text-align: center;
  font-family: BlueHighway, Arial Black, sans-serif;
  margin: 0 auto;
}
div.window label {
  display: block;
  background: #660b0b;
  font-size: larger;
  border-radius: 5px;
  padding: .6rem;
  transition: .4s all linear;
}
div.window label:hover {
  cursor: pointer; background: #311;
}
input.toggle ~ div {
  height: 0px; margin: .2rem;
  overflow: hidden;
  transition: .6s all cubic-bezier(0.730, -0.485, 0.145, 1.620)
}
input.toggle:checked ~ div { height: 230px; }
input.toggle:checked + label { background: red; }
input.toggle { display: none; }
<div style="height: 240px; padding-top: 1.2rem">
<div class="window">
<input type="checkbox" id="punch" class="toggle">
  <label for="punch">Use the Force, Luke.</label>
  <div>
    <img src="http://images.sequart.org/images/Star-Wars-still-use-the-force-luke-e1415132076759.jpg" style="max-width:100%;height:auto" alt="Ackbar">
  </div>
</div>
</div>

If anyone can help me figure out why the background image is not showing up, I would greatly appreciate it! Thank you.

Answer №1

After giving your code a try, I can confirm that it is functioning correctly. It seems like the issue lies in the incorrect path of your background image.

If your Star Wars image is not located in the same directory as your HTML file, then the correct path should not be url("starwars.jpg");. Double-check to see if you accidentally placed it in a different folder.

Answer №2

Does the .html file using the image "starwars.jpg" have it stored in the same directory?

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

Implementing a single row of transparent text that covers all columns in a covert style using CSS

https://i.sstatic.net/eLdxa.png Looking to design a table with rows representing different status levels such as suspended, closed, and open. The challenge is that when the status is "open", it should not be displayed on the row. Any suggestions for imple ...

Aligning Text Vertically next to an Image

After exploring numerous solutions on Stack Overflow and other search engine results, I am still struggling to align text vertically alongside an image. The webpage in question can be found at this link. At the bottom of the page, you will notice a state ...

A unique way to present data: An HTML table featuring four fixed columns with horizontal scrolling

I've been having difficulty creating a table with fixed first four columns while allowing the rest to scroll horizontally. I came across this example first column fixed Although the example has the first column fixed, I'm struggling to extend it ...

Using jQuery to send both the selected file contents and parameters in an ajax request

Currently, I am utilizing this code snippet to transmit the selected file's contents to the server: <!DOCTYPE html> <html lang="en> <head> <title>Test</title></head> <script src="https://ajax.googleapis.com/ ...

Should the navigation bar stick to the top while scrolling?

I am in the process of creating my own website and I have come across a really cool effect on various websites where the navigation bar is positioned below an image, but then sticks to the top when you scroll past it. Check out this example Can anyone he ...

The background-repeat-x property is not being retrieved by the Selenium WebDriver getCssValue() function

My goal is to check if a background image exists and if the `repeat-x` property is set. I can successfully retrieve the background image using the following code: driver.findElement(By.xpath("//body").getCssValue("background-image"); This code returns a ...

How can I position a div in the center of a fullpage.js slide?

I'm currently utilizing the fullPage.js plugin sourced from this link: . I have successfully implemented vertical slides by using the following HTML code: <div class="section" id="section2"> <div class="slide" id="slide1"> ...

Adjust the GTK3 tooltip color exclusively for Eclipse when it is operating on Ubuntu

I am using Eclipse Mars on Ubuntu 15.04 and looking to customize the GTK3 tooltip fg/bg color specifically for Eclipse without impacting other applications. I have come across instructions for changing this color system-wide, but I need guidance on how t ...

Limitations of jQuery: onClick function not transferable

I am struggling to achieve the following functionality for my navbar dropdown menus: When the screen size is greater than 992px, I want the navbar dropdowns to open on mouse enter. For screens smaller than 992px, I want the dropdowns to open on ...

Issues with merging styles in TinyMCE 4

I've exhausted all the current configuration options and I'm still unable to resolve this issue. My goal is to have the style tag appended to the selected element without generating an additional span. For example: <p>Hello World!</p> ...

Display validation messages when the form is submitted or when a field is edited. Both custom and default validation messages will be shown upon submission

I am encountering two issues with custom error messages: Firstly, the error messages are displaying when the page initially loads, but I only want them to show when the form is submitted or a field has been modified. Here is the code snippet in question: ...

Ways to modify the anchor tag's background color in Magento

I am currently working on designing a Magento homepage and I'm looking to change the background color for a specific anchor tag. However, my navigation menu contains 5 different anchor tags and I specifically want to change the color of the 5th one. A ...

Ways to make a webpage automatically adjust its layout using pixels and incorporating rems

Using rem units allows for easy control of full page size to make it responsive. For example: div{ font-size:20rem; } @media only screen and (max-width: 576px) { html{ font-size:20%; } } But what can we do when using px units instead ...

Finding content in HTML tables using JavaScript and jQuery

I recently created a table and wanted to add a search functionality to it. I searched online, including on various forums like StackOverflow, but unfortunately, the solutions I found did not seem to work for me. Below is the code that contains both the HT ...

The lines intersecting with the ethereal image in the background

I'm trying to achieve button links with an image overlay, but so far I've only been able to do it using CSS: section a:link, section a:visited { width: 150px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: ...

Pressing the 'Enter' key within a textarea in a JQuery

This question seems fairly straightforward. I have a text area where hitting "enter" submits the content. Even though I reset the text to "Say something..." after submission, the cursor continues to blink. Is there a way to require the user to click on ...

Create a dynamic animation using Angular to smoothly move a div element across the

I currently have a div with the following content: <div ng-style="{'left': PageMap.ColumnWrap.OverviewPanelLeft + 'px'}"></div> Whenever I press the right key, an event is triggered to change the PageMap.ColumnWrap.Overvie ...

What is the best approach to choose the thead element from a dynamically created table?

My table in JavaScript/JQUERY is dynamically constructed. Once the table is created, I am attempting to target the thead element. Here is a snippet of my code: $(document).ready(function(){ buildTbl(); }); function buildTbl() { var tbl = '< ...

Adding dynamic attributes like pattern and title to input controls

I currently have an HTML input field that looks like this: <input type="text" value="<%= this.CustomerAcctNumber %>" name="CustomerAcctNumber" id="CustomerAcctNumber" maxlength="19" onkeyup="CustomerAcctNumberChange()" required > Upon loading ...

What is the method for creating transparent punch-through text using HTML and CSS?

I'm working with a div that has a css property of background: rgba(0, 0, 0, 0.85);. In the center of this div is the title of the page. I want to achieve a see-through effect for the title (knockout, punch-through, whatever term you prefer - essential ...