How can I set up a cycling image background for the main div and a floating menu?

I was wondering how I could keep a cycling image background stationary behind the main content while scrolling through the page. You can check out the project itself by following this link. Feel free to use any of the code, including the fixed header menu, in your own projects. I've been putting a lot of effort into developing this template.

Appreciate your help in advance!

Answer №1

To achieve this effect, simply add background-attachment: fixed to your CSS.

If you want to see a live example, take a look at this code snippet on JSFiddle.

Code Snippet:

body {
  background-image: url(https://support.files.wordpress.com/2009/07/pigeony.jpg?w=688);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

div {
  width: 100%;
  height: 250px;
  display: block;
  opacity: 0.6;
}

#a1 {
  background-color: black;
}

#a2 {
  background-color: green;
}

#a3 {
  background-color: red;
}

#a4 {
  background-color: blue;
}

#a5 {
  background-color: yellow;
}

#a6 {
  background-color: violet;
}

#a7 {
  background-color: purple;
}
<div id = "a1"></div>
<div id = "a2"></div>
<div id = "a3"></div>
<div id = "a4"></div>
<div id = "a5"></div>
<div id = "a6"></div>
<div id = "a7"></div>

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

Looping through radio buttons in jQuery to discover the container div with the most economical price

Is it possible to utilize Jquery to identify the lowest price, apply a class to the surrounding element, and update the 'checked="checked"' attribute to the correct option? <div><input type="radio" name="RateID" value="1" checked="check ...

jQuery is working perfectly on every single page, with the exception of just one

Check out my code snippet here: http://jsfiddle.net/9cnGC/11/ <div id="callus"> <div class="def">111-1111</div> <div class="num1">222-2222</div> <div class="num2">333-3333</div> <div class="num3">444-4444< ...

The attempt to run 'setProperty' on 'CSSStyleDeclaration' was unsuccessful as these styles are precalculated, rendering the 'opacity' property unchangeable

I am attempting to change the value of a property in my pseudo element CSS class using a JavaScript file. Unfortunately, I keep encountering the error mentioned in the title. Is there any other method that can be used to achieve this? CSS Code: .list { ...

What is the best way to use Javascript in order to automatically open a designated tab within SharePoint 2013?

Currently, I am in the process of developing a website project which incorporates Bootstrap tabs utilizing jQuery. While these tabs are functioning excellently on various pages, I am faced with the challenge of linking specific icons to corresponding tabs ...

What are the steps to create a dynamic background image that adjusts to various

When viewing the website on a computer screen, the entire cat is visible in the background image. However, when switching to a mobile screen size, only a portion of the cat is displayed, appearing as though it has been cut off. The image is not smaller on ...

"Enjoy a unique browsing experience with a two-panel layout featuring a fixed right panel that appears after scrolling

I am facing difficulty in designing a layout with two panels where the left panel has relative positioning and the right panel becomes fixed only after a specific scroll point. Additionally, I need the height of the right panel to adjust when the page scro ...

Tips for globally overriding MUIv4 class in JSS for nested themes

Summary: Skip to EDIT2 MUIv4 has generated the following classes for me based on my nested theming: <label class="MuiFormLabel-root-121 MuiInputLabel-root-113 MuiInputLabel-formControl-115 MuiInputLabel-animated-118 MuiInputLabel-shrink-117 M ...

Dash that serves as a barrier between two words to avoid them from breaking onto

Is there a way to keep a dash ( - ) from breaking a word when it is at the end of a line? Similar to how &nbsp; prevents a line break between two words. The issue I am facing currently is with a dynamic blog post that includes the word X-Ray. Unfortun ...

Encountered a JQuery error in the application: trying to call the 'open' method on dialog before initialization is complete

I am having trouble integrating a dialog box into my application and encountering the error mentioned above. Here is the jQuery code I'm using: $( "#dialog" ).dialog({ autoOpen: false, width: 450, modal: true, ...

To style a text box next to text within a paragraph in CSS, simply create an empty box

I have some CSS classes defined as follows: .p_box { position: relative; } .p_box span { background-color: white; padding-right: 10px; } .p_box:after { content:""; position: absolute; bottom: 0; left: 0; right: 0; top: ...

Instructions for selecting an <option> within a <select> element using Python

I am trying to select a specific option by id, but I am encountering an issue when dealing with the elements above the select dropdown. <ul style="display: block; visibility: visible;"><li><a href="#" index="0" class="" onclick="s_objectID= ...

No animated scrolling occurring

I have been struggling with this problem for a while now and despite having gone through 100 questions, I still can't find a solution as to why my code snippet is failing. Here is the jQuery code I am using: $("#readmore").click(function(event){ ...

Converting CSS colors from RGBA to hexadecimal format: A step-by-step guide

Within my selenium code, I am faced with the challenge of verifying that the background color code is #192856. However, when obtaining the CSS property of the element, it returns the color in rgba format. How can I retrieve the values in hex format? quick ...

Achieving consistent alignment for text on a curved path

I am working on a unique "flow-builder" project and I need to achieve this specific result: https://i.sstatic.net/6TTuS.png At the moment, my current edge looks like this: https://i.sstatic.net/9ydzx.png The text on the edge is currently aligned with the ...

What are some creative ways to design drop-down menus within an email?

The snippet of code I am currently using lacks the ability to format text, and it does not allow content below dropdown items to shift down properly in an email. <select> <option value="first">First-time users of the Vanguard Events app:&l ...

The dropdown navigation bar fails to close upon being clicked

I'm currently facing an issue with the navbar in my project. The bootstrap navbar doesn't close automatically after clicking on a link. I have to move my mouse away from the navbar for it to close, which is not ideal. Additionally, I'm worki ...

Insert the AJAX loader graphic

Hello! I may not be a master of jQuery, but I've been tinkering with some source code and stumbled upon an ajax script. I'm feeling a bit lost on how or where to insert an ajax loader image in this snippet: $.post(webroot+'quickLookUp.php&a ...

What are some clever ways to handle the transition of the display property?

While transitions for the display property may not work, I am exploring alternatives. I attempted using the visibility property but it didn't quite fit my needs. In my current setup, different text is displayed when hovering over an anchor tag by sett ...

Is it possible to display a subtle grey suggestion within an HTML input field using only CSS?

Have you ever noticed those text input boxes on websites where a grey label is displayed inside the box, but disappears once you start typing? This page has one too: the "Title" field works the same way. Now, let's address some questions: Is ther ...

Is it better to store JSON data locally using cookies or HTML5 local storage?

Currently, I am working on developing a mobile website using jquery mobile. My main concern right now is how to efficiently carry JSON data across multiple pages. I am debating whether it would be better to store this JSON data in a cookie or use HTML5 loc ...