Positioning background images in Bootstrap CSS with fixed position

Currently, I am developing a website using bootstrap, HTML, and CSS. The structure of the HTML code is as follows:

wrapper for fixed footer at bottom {
  content
  fixed bg
  content
}

The overall wrapper has relative positioning. The fixed background is defined as:

figure {
  position: relative;
  width: 100%;
  height: 60%;
  margin: 0!important;
}
.fixed-wrap {
  clip: rect(0, auto, auto, 0);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
#fixed {
  background-image: url('img/mac.png');
  position: fixed;
  display: block;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center center;
  -webkit-transform: translateZ(0);
          transform: translateZ(0);
  will-change: transform;
}
<figure>
 <div class="fixed-wrap">
    <div id="fixed">
   </div>
 </div>
</figure>

The issue I'm facing is that the fixed background and content below are not sticking to their designated positions correctly. It seems like there might be an issue in my CSS code.

As per my current CSS code, the fixed background does not appear at all. If I change the position of the figure to absolute, then it shows up, but the contact form ends up overlapping it. I hope this explanation makes sense, please forgive me if anything seems unclear or messy in this post since this is my first time posting here.

Answer №1

height: 60% of your figure will be 0 because it needs to be 60% of the parent element, which currently has a height of 0. Consider specifying a height for the parent element in pixels. For instance, use the body tag or another parent element with a defined height.

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

Utilizing Various jQuery Selectors for Option Values

I'm currently facing a challenge with including extra value selectors in jQuery. My goal is to include option[value="18:00"] so that if option [value="17:00"] is not chosen, it will trigger the function when 18 is selected. Below is the code snippet: ...

Is there a way for me to select elements that don't have the class "class" and are an even

I've been utilizing CSS for various tasks, however, there is a particular situation where it doesn't seem to function correctly. My goal is to create a list similar to a spreadsheet, with each line alternating between light grey and slightly dar ...

Nav bar breaching the Bootstrap threshold

I am new to using bootstrap and currently in the learning process. I am facing an issue with the navigation bar I created. All the contents are aligning to the right, but the search bar and tabs are breaking onto a new line. I have attempted various soluti ...

Tips for transferring the content of a variable to a handlebars block

Currently, I am grappling with HTML code that involves handlebars templates to store internal variables. While I may not be an expert in handlebars, I am trying my best to navigate through it. The crux of my issue lies in the need to access a lengthy list ...

Explore the world of HTML by uncovering both the tags and

I am currently focused on enhancing a table I created to allow sorting rows in both ascending and descending order, as well as the ability to rearrange columns through click-and-drag functionality. While the basic structure is working, I am seeking to refi ...

Adjust the ZIndex on a div through interactive clicking

For my new project, I'm exploring a concept inspired by Windows 7. The idea is that when you double click on an icon, a window will open. If you keep double clicking on the same icon, multiple windows should appear. The challenge I'm facing is im ...

The webpage appears fine on the local server, but displays incorrectly on IIS (Internet Explorer 11)

My project looks great when I run it locally on my computer and open the page in Internet Explorer 11: https://i.stack.imgur.com/yZvo2.png However, when I deploy the page to an IIS server and navigate to the page, it appears differently in Internet Explo ...

Moving from a static full screen div to a dynamic relative position with a smooth transition and animated effects

I am in need of a div element that initially occupies the entire viewport. After a specified delay, this div should transition to a relative position and adjust its dimensions to fit the width while maintaining a 16/9 ratio. The transition must be smooth a ...

Are there any pre-existing pop-up methods available for AngularJS?

Is there a way to create a simple pop-up window with static text and just one "Ok" button? In Java/Swing, it's possible to achieve this with just one line of code using pre-defined classes. However, when it comes to Angular pop-ups, it seems like the ...

A Step-by-Step Guide to Creating Vertical Tabs Using Flexbox in CSS

I have been experimenting with CSS to create vertical tabs without altering the HTML structure. The current CSS solution I am using works perfectly for horizontal tabs. Is it possible to tweak the CSS code to achieve the desired layout change? [role=t ...

What is the best method for fetching data from PHP to display on my Angular page?

I am struggling to retrieve data from MySQL to display on my AngularJS page, using PHP as my server-side language. I can fetch the data from my PHP file but unable to render it on my page. If you have any alternative solutions, please let me know. Below i ...

The synchronization between the First Column Scroll and Table Filter Function is out of alignment

I haven't coded for a while and my knowledge of JavaScript is still in its early stages, so please excuse me if this question seems a bit naive. Essentially, I've created code that filters an HTML table based on the items in the first column. Th ...

Is there a way to remove an individual file from an HTML file input field?

I recently took on the task of implementing a delete function for an HTML file input with the type "file". The goal is to delete a single file from a list of multiple files. While deleting all files at once is simple, I am having trouble with my function t ...

Ways to deduct a specific value from the total sum of values stored in a Database

To calculate the remaining amount in John's account, we need to subtract a given value from the sum of all payments recorded in the database. For instance: Let's consider User "John" who has made two deposits of $100 and $50 into his account, to ...

CSS: Continuous Automated Slide Transitions

What CSS code do I need to incorporate into my code to create a continuous Slider Animation? I want the pictures to slide automatically one by one, with a specified time interval between each slide when not on hover. The hover function is already included ...

What is the best method for combining several variables into a single one using a parameter?

On the webpage, there is a table containing 11 checkboxes. I am looking to create a keyword that allows testers to input just 1, 2, or 3 to select a specific checkbox without needing multiple lines of element variables. Here are the elements: xpath=(//in ...

Tips for inserting an icon alongside a list item in HTML

https://i.sstatic.net/sTWRu.png Can you help me with adding an icon to a list item using Font Awesome or any other method? I want the icon to appear on the right side of the text. I have four sections of text that I want to convert into expandable dropdow ...

Is it possible for a div with fixed position to still have scrolling functionality

My fixed positioned div (#stoerer) appears to be moving while scrolling, although it is just an optical illusion. Check out this visual explanation: view gif for clarification Below is the code snippet in question: <div id="stoerer"> <button ...

Trouble with Fancybox 2 and CSS classes not applying correctly

Despite my previous successful experiences with fancybox, I am currently facing an issue where the CSS styling is not being applied as expected. The large images appear grouped correctly, but without any styling, causing them to shift to the right after ap ...

Arranging progress bars between various nodes using HTML and CSS

I am currently facing a challenge in creating a stepping wizard form layout that features a bar at the top of the page. This bar displays a dynamic number of steps (nodes) and progress bars that connect these nodes. However, I am encountering difficulties ...