Customize various page designs using a single CSS file to generate loops

I encountered an issue with different background images needed for each page, where the ID is generated from the following for loop statement:

`$`function nextButton() {
    if(curNum<numScreens) {
      curNum = parseInt(curNum)+1;
      document.location.href = '#'+curNum;
      $( init );
   }
}

This results in /#1, /#2, and /#3 pages.

To address this, I attempted to assign unique IDs/classes for each page in the HTML document like so:

<body id="1">
<body id="2">
<body id="3">

And then in the CSS:

body.1 { 
  background-image: url("bg.gif");
  background-repeat: no-repeat;
  background-attachment: scroll;
  background-position: 53% 10%;
  z-index: 1;
}

body.2 { 
  background-image: url("bg1.gif"); 
  background-repeat: no-repeat;
  background-attachment: scroll;
  background-position: 53% 10%;
  z-index: 1;}

body.3 { 
  background-image: url("bg2.gif"); 
  background-repeat: no-repeat;
  background-attachment: scroll;
  background-position: 53% 10%;
  z-index: 1;
}

However, this approach did not yield the desired result. Can someone please assist me?

Answer №1

In order to modify each of the body sections, you simply need to update them as follows:

body #section_1 {...}
body #section_2 {...}
body #section_3 {...}

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

Discover the hidden content within a div by hovering over it

Here is an example of a div: <div style="width:500px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce quis pulvinar dui. Nulla ut metus molestie, dignissim metus et, tinc ...

Use Jquery to revert the chosen element back to its original base state

I have implemented a select box where selecting a value in the main select box "Domains" will reveal another select box called "Types" such as Diatoms or Flagellates. I have successfully achieved this functionality, but now I am facing an issue with resett ...

Adding Text Above a Material Icon in Angular: A Guide

Here is some sample HTML code to consider: <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> <mat-icon class="fa fa-folder" style="font-size:48px;"><span style="color: re ...

Interacting with a DIV element can also have an impact on the links within

Below is my current CSS code: .contact{ padding:1rem; background:#023B6C; padding:1rem; position:fixed; right:-20px; top:27%; z-index:99; border-radius:5px 5px 0 0; border:2px solid #fff; transform:rotate(-90deg); transition:all .5 e ...

Can different versions of jQuery be loaded simultaneously on a single page?

I am in the process of creating a bookmarklet that will load jQuery if the object is not found. The script will also check for the version of jQuery before loading. Here is how the code looks: (function(){ var myBkl = { loadScript: function( ...

Tips for making a draggable div come to the forefront upon clicking

I'm looking to make a jQuery draggable div come to the front when it's clicked. I came across this post, and tried creating a JsFiddle based on it, but couldn't get it to work. Any ideas on what I might be missing? Thanks! Here's the l ...

Discovering the actual file path of an uploaded document in Asp.Net Mvc

When trying to use an HTML input file to select a file, I encountered an issue where JQUERY would return a fake path instead of the actual one. $("#inputfile").val() I am looking to obtain the selected file's actual path, such as: D:\Documen ...

How come my default design isn't displaying on my GitHub page?

I'm completely new to GitHub Pages, Jekyll, and YAML, and I've encountered some issues while working on my first project. I believe the problem may be with the _config file, but I'm not sure what it is. When you visit my site at mohmanyang.c ...

Double execution issue with jQuery radio button change event function

I have a simple function on my website that triggers when radio buttons are changed: $( 'form .radio_buttons' ).change( doTheFunction ) However, I recently noticed that the function is running twice whenever a change occurs. After some ponderin ...

Guide on populating dropdown menus and linked dropdown menus

Here is the code snippet for my ViewModel used in Dropdowns [Required(ErrorMessage = "This Field is Required")] [Display(Name = "Province")] [UIHint("DropDownList")] [AdditionalMetadata("DataController", "Register")] [AdditionalMetadat ...

Having trouble with Ajax retrieving the updated JSON file version

I'm pretty new to coding and terminology in general, so I've done my best to simplify my code, although it might still have redundancies. Appreciate your patience in advance. My task involves using an ajax and php script to write data to a file ...

the components progress down the line

For my right column implementation, I decided to use CSS position:relative and put different elements inside in position:absolute as shown below: <!-- Right Column --> <div class="col-xs-3 pl18" style="position:relative;"> <!-- Withou ...

The table dynamically adjusts based on the JSON data

My goal is to design a table that displays a JSON-object with multiple levels. The challenge is to showcase all the data in one row, even when it shows as [object object] like the Id in the plnkr example. ResultData=[ { "First_name": "xx", ...

How can you adjust the input size in Chrome with italic font styling?

Currently, I am troubleshooting an issue with the styling of my input fields. Specifically, I want to change the font style to italic when the input is modified. This functionality is performing correctly in Firefox. However, in Chrome, when I add font-sty ...

How is it possible for this code to function when the object is not explicitly defined within the javascript code?

While using JSLint, I encountered an issue where it stated: 'matte_canvas' is not defined. Although I have not explicitly defined 'matte_canvas' in my javascript code, it does output the canvas element in the console. Below is the code ...

Using conditional CSS values in Angular 8

I am currently working on a parent component and child component setup, where I am utilizing the child component's selector to display it within the parent component. Here is my child component's HTML: <div class="main-container" [n ...

Determine whether or not a selector has been designated

As I embark on developing my inaugural jQuery plugin, I aim to add a unique twist to its functionality. Let me clarify the main objective: The concept is basic - when an <input> field contains a title attribute, the input box will be pre-filled with ...

The specified MIME type (text/html) is not compatible with stylesheets

When attempting to link a css file to my express-handlebars file, I encountered the following error: The style from 'http://localhost:4000/cs366/style/draft.css' was refused due to its MIME type ('text/html') not being a supported st ...

What is the process for creating a List Grid View utilizing this particular code?

I attempted to modify the stylesheet extensively and also created a small function in JavaScript, but unfortunately it did not yield the desired results. <div class="row featured portfolio-items"> <div class="item col-lg-5 col-md-12 col-xs ...

The absence of a semi-colon in JSLint

I encountered an error message indicating a semicolon is missing, however I am unsure of where to place it. Here is the snippet of code: $('.animation1').delay(350).queue(function(){ $(this).addClass("animate-from-top") }); ...