Swapping out background images for individual pages

How can I make sure that the background images stay fixed regardless of the amount of text on the page? I have two background images, one on the left and one on the right. The text article is overlaid on top of these images. However, each page has a different amount of text, causing the images to not align properly. If I add height: 100% to .pozadi, the images stay in place on every page but the text overflows its parent element (.pozadi).

I understand that providing a webpage as an example may not be ideal since it could change or disappear. However, let me try to explain my issue better.

If you visit this link - - and open the pages "prodej kompresorů" or "opravy kompresorů", you will see the helix in the background which illustrates my problem.

The sroubovice attribute belongs to the body, so I created a wrapper div for demonstration purposes.

#primary_nav_wrap {
  float: left;
  width: 22%;
  margin: 0;
  z-index: 1;
}

#sroubovice {
  background-image: url(http://matmasar.wz.cz/fotky/pozadi.png), url(http://matmasar.wz.cz/fotky/pozadi.png);
  background-position: left, right;
  background-repeat: no-repeat;
  height: 100%;
}

.tlacitka {
  color: white;
  background: #000;
  padding: 10px 20px 10px 20px;
}

.pozadi {
  background: #e7f1f5;
  float: right;
  width: 76%;
}
<div id="sroubovice">
  <img src="../fotky/zahlavi3.jpg" id="zahlavi">
  <article>
    <section>
      <h1>Prodej kompresorů</h1>
      <div id="wrap">
        <nav id="primary_nav_wrap">
          <ul>
            <a href="../index.html">
              <li class="tlacitka" style="border-top-left-radius: 15px;">Domů</li>
            </a>
            <a href="kompresory.html">
              <li class="tlacitka">Kompresory</li>
            </a>
            <a href="opravy.html">
              <li class="tlacitka">Opravy kompresorů</li>
            </a>
            <a href="../kontakt.html">
              <li class="tlacitka" style=" border-bottom-left-radius: 15px; border-bottom: none;">Kontakt</li>
            </a>
          </ul>
        </nav>
        <div class="pozadi">
          <br> If your current compressor station is failing or if you're designing a brand new compressed air installation, we can offer solutions using high-quality compressors and other accessories from companies like <a href="gardnerdenver.html">Gardner Denver</a> and <a href="compair.html">CompAir</a>.
          <a href="gardnerdenver.html">
            <img src="../fotky/gardnerdenver.png" alt="Gardner Denver logo" title="Gardner Denver logo" class="logo"></a>
          <a href="compair.html"><img src="../fotky/CompAir.png" alt="CompAir logo" title="CompAir logo" class="logo" style="margin-bottom: 50px;"></a>
          <ul style="font-weight: bold;">
            <li>Request a price quote</li>
            <li>Let's discuss your project together and suggest the ideal solution.</li>
            <li>Don't hesitate to contact us.</li>
          </ul>
        </div>
        <!-- End of the pozadi div -->
      </div>
      <!-- End of the wrap div -->

Answer №1

Here's a suggestion for you:

#screwdriver {
    background-position: center top;
}

Answer №2

After some investigation, I was able to figure out the solution.

I made the decision to remove .pozadi from the body and instead replaced article with div as the first child element of the body. Here is how it looks now:

<body>
<div id="sroubovice">
<section>
....
</section>
</div>
</body>

Next, I included height 100% and adjusted the background-position property to left top (or 140px for a more precise result) for the left side and right 140px for the right side in the .pozadi selector.

#sroubovice{
background-image: url(../fotky/pozadi.png), url(../fotky/pozadi.png);
background-position: left 140px, right 140px; 
background-repeat: no-repeat;
height: 100%;
}

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

creating a square root symbol using css

Creating a scalable square root symbol using CSS can be achieved with the following code snippet: .root { display: inline-block; vertical-align: middle; } .radix1 { display: inline-block; width: 0.2em; height: 1.5ex; vertical-align: bottom; ...

Within jQuery Mobile, text appears obscured by a listview containing a count bubble

After creating a listview with count bubbles and item descriptions, I noticed that the description text is falling behind the count bubble. Is this a glitch in the code or something that can be fixed with CSS? echo '<li><a value="' . $r ...

Retrieving PHP variables within the HTML document of the current page

Suppose I have a page with a link <a href='edit_info.php?id=1001'>1001</a>. In the edit_info.php page, I want to use this id to query a database, like so: SELECT * FROM table WHERE id = $_GET['id'] Now, I need to populate ...

Concealing website links in the browser's address bar

Running my own website on a personal server with Ubuntu server, I noticed that my public IP address is displayed in the status bar when visitors browse my site or hover over links. Even after purchasing a domain name from godaddy, I couldn't find an o ...

Is it possible to access forms and input fields in an AngularJS script without having to pass them from the HTML code?

Seeking a solution for input field validation, I have written code where input field states are passed from HTML to a script through a function. However, my goal is to directly retrieve the values in the script without passing them from the HTML when calli ...

CSS button with folded corner illusion and dynamic transitions

I have been using the code provided below to create a folded corner effect on a button, but I am having trouble with the white background that appears in the upper left corner of the button. Is there a class I can use to make this transparent so that the y ...

A variable in Javascript storing data about jQuery DOM elements

Currently, I am using the slick slider for my development (http://kenwheeler.github.io/slick/) In JavaScript, there is an event that returns a variable called 'slick' When I print the variable using console.log, this is what I see: https://i.s ...

Is there a way to remove the jQuery .css() upon clicking a different button?

I am currently working on a jQuery switch where I want the clicked button to revert back to its original state when another button is clicked. Additionally, I want the 'OFF' button to be automatically clicked first when the page loads. Despite tr ...

Ways to conceal a primary page section upon clicking a different tab

I am currently implementing the w3schools HOW TO - tabs feature on my website to create tabbed navigation. However, I'm running into an issue where clicking on tabs other than 'Home' still displays the 'Home' content along with the ...

Adjust the padding at the top of the content according to the height of the fixed header

Currently, I am working on a design layout that includes a fixed header, a main nav, and an additional navigation bar called #sub_nav. The problem arises when the #sub_nav contains numerous items to choose from - as I decrease the width of the browser wind ...

Angular validation with input binding using if statement

I have developed a reusable component for input fields where I included a Boolean variable called "IsValid" in my typescript file to handle validation messages. Here is the code from my typescript file: export class InputControlsComponent implements OnIn ...

Tips for importing HTML modules using AJAX technology?

Is it possible to load the correct module on my site depending on the path that the user enters? Would storing the HTML in a file named some_file.htm, ajaxing that file to the client, and then appending it to the DOM work for this purpose? I'm curio ...

Move the accordion slider to the top of the browser

I'm working with an accordion menu that has some long content. To make it more user-friendly, I want to add a slide effect when the accordion items are opened. Right now, if you open the first two menu items, the last item's content is cut off a ...

What is the best way to ensure the logo remains aligned with the left side of the name and title?

I am looking to have the logo and name/title styled similar to the image below. Additionally, I want the logo to remain on the left side of the name/title when the display screen size is reduced (currently it moves above). Any suggestions would be greatly ...

Model data is missing from the form submission

I recently created a basic HTML POST form with a model embedded within it. Here is the link to view the demo: https://jsfiddle.net/pilotman/rn9gspz8/6/ Keep in mind that the JS fiddle example is just for demonstration purposes and may not be flawless. Af ...

How to customize TextField error color in Material-UI using conditional logic in React

Currently, I am incorporating the React Material-UI library into my project and faced with a challenge of conditionally changing the error color of a TextField. My goal is to alter the color of the helper text, border, text, and required marker to yellow ...

JQuery's document.ready function triggers prematurely on dynamically loaded HTML content

When loading dynamic content, I use the following method: $('#my-div').load('my.html'); The code inside my.html looks like this: <html> <head> </head> <body> <script> $(fu ...

An interactive top navigation bar paired with three dynamic columns housing scrollable content, all crafted seamlessly with Bootstrap 4

I recently updated my layout using bootstrap but I am facing a glitch. I want the layout to have fixed scrolling only within the columns, without affecting the entire page. Everything works fine until I add some text inside any of the columns, then the who ...

Transforming HTML features into PHP scripts. (multiplying two selected values)

I am currently working on converting these JavaScript functions into PHP in order to display the correct results. I need guidance on how to use PHP to multiply the values of the NumA and NumB select options, and then show the discount in the discount input ...

Utilize Vuetify to showcase a vertical layout consisting of a header and a v-card, occupying the full height

<template> <div> <div style="height: 20px; color: yellow"> test </div> <v-card class="markdown-preview" tile> <v-card-text v-html="previewText"> </v-card-text> ...