Enabling images to exceed the boundaries of the parent div while ensuring that content below is properly adjusted

Here is the design I am aiming for

Hey there! This is my first time posting here :)

I am currently stuck and have been struggling for hours.. haha

I am trying to place an image beneath some text inside a div, which should overflow down the page. Unfortunately, the image is running under my footer instead of pushing it down. I have tried using position:relative on the div & position:absolute on the footer but I can't seem to make it work!

I have included my code below. Although the image is random, it is similar in size to the one I am using locally.

Any assistance would be greatly appreciated

/* My Work page */

   .wallpaper {
     margin: 0px;
     height: 800px;
     background-color: var(--peach);
     position: relative;
   }

    .my-work-text {
      /* position: absolute; */
       /* top: 30%; */
        /* left: 50%; */
         /* transform: translate(-50%, -100%); */
         color: var(--black);
         font-family: "playfair display";
         max-width: 60%;
         margin: auto;
         padding-top: 20%;
       }

       .my-work-screenshot {
          margin: auto;
       }


      /* FOOTER */

      footer {
         /* margin-top: 100px; */
          color: #fff;
           background-color: var(--black);
            text-align: center;
            padding: 40px;
             position: absolute;
              width: 100%;
           }

            footer>h5 {
             padding: 8px;
           }

           footer>p {
            line-height: 0.4rem;
          }

          footer>hr {
           margin: 30px 0 20px 0;
         }

         footer>ul {
          list-style: none;
        }

        footer>ul>li>a,
        a:link,
        a:hover,
        a:visited {
         text-decoration: none;
         color: var(--white);
        }
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="781a17170c0b0c0a1908384d56485648551a1d0c1949">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" />

        <!-- MAIN TEXT & BG -->
         <section>
          <div class="wallpaper">
           <div class="container">
            <div class="my-work-text">
             <h2>Bryan Johnston Cichlids</h2>
              <p>Bryan is a specialist aquarium fish seller and was looking for site to showcase his business. I provided Bryan with a complete service from design, functionality & development</p>
           </div>

          <div class="my-work-screenshot container">
           <img src="https://www.xda-developers.com/files/2018/04/longshot-example.png" class="img-fluid shadow" alt="Responsive image">
          </div>
         </div>

        </div>
      </section>




     <!-- FOOTER -->
     <footer>
      <h5>BLOXY WEB DESIGN & DEVELOPMENT</h5>
       <p>Professional website designer and developer</p>
       <p>Tel: 07806 615231</p>
       <p>Email:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4132353420333501322b232d2e3929202c6f222e6f342a">[email protected]</a></p>

        <hr />
        <ul .footer-links>
         <li><a href="#">Home</a></li>
          <li><a href="#">My work</a></li>
           <li><a href="#">Get in touch</a></li>
        </ul>
       <p>© Copyright Bloxy Web Design & Development</p>
     </footer>

Answer №1

1. To achieve a standard footer layout, apply position: relative to the footer element. If no position is specified, it defaults to relative.

2. If the page content does not fill the entire screen height, the footer will not stick to the bottom of the page. To accommodate additional content like an image at 'https://i.sstatic.net/8z2UC.png', either use position: relative or remove the position attribute from the footer CSS.

  1. If there is minimal content and the footer is not positioned at the bottom, opt for position: fixed with bottom: 0 and left: 0. This allows the footer to stay fixed in place, and adding z-index: 555 ensures it appears above other elements.

  2. When utilizing position: absolute, remember to set the parent container to position: relative so the child element knows where to align itself. For absolute positioning, include left: "number" and top: "number". In both absolute and fixed positioning, specify at least one value for each X-axis (left or right) and Y-axis (top or bottom). Failure to assign a relative position to the parent container will result in absolute positioning based on the entire page.

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

What is the best way to eliminate the default background color applied to the body automatically?

I'm currently developing a Covid-19 tracking web application and I am using chartJS to showcase data from an API. In my CSS, I have assigned a background color to all elements with an asterisk (*), but for some reason there are empty spaces around the ...

Utilize varying sizes within a single column using Bootstrap

I am struggling to create a heading that spans the entire width of my listview within Bootstrap. Despite being in the same column, the heading does not extend as far as the listview. I desire for the title to stretch all the way across the list, leading m ...

Importing an Excel file in .xlsx format cannot be done through AJAX JQUERY

I am trying to display the content of an Excel file when a button is clicked. It works fine when I change the extension to .csv, but when I change it to .xlsx, I get a character type error that looks like "y!+EfMykK5=|t G)s墙UtB)". These strange charact ...

transferring information back and forth between a javascript array and php

Currently, I am developing a design website that allows users to create designs on an HTML5 canvas and save them on the server. All user information is stored in a MySQL database, while the designs are saved in a JavaScript array. My goal is to seamlessly ...

The uploaded file does not display its name

My form includes a section for uploading images, but I'm facing an issue where the label for the uploaded image does not display the actual file name. I tried implementing a code snippet that partially solved the problem by displaying the image as "C: ...

Dynamically changing the borders of WebGL canvases: a guide to adding and

Here is my code snippet for creating an HTML canvas: <canvas id="glCanvas" class="canvases" width="20" height="20></canvas> To set the color, I am using the following: gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clear(gl.COLOR_BUFFER_BIT); I am w ...

What strategies can be used to avoid a single dangling word at the end of a line within an HTML element?

I am in the process of developing a straightforward webpage with marketing content. One aspect I find unfavorable is when a line of text stretches too long and breaks onto the next line, which is acceptable; however, it often splits in a manner where there ...

Tips for designing a horizontal sub-navigation menu using CSS?

I have limited experience with list menus and am struggling to create a horizontal submenu with its own styling. Despite multiple attempts, I have been unsuccessful in finding a solution and have put the project on hold for now. Here is what I currently h ...

Inserting multiple values into my PDO database

I am facing an issue with my code that I need help with. I am trying to include more data than just my :SteamID in my database. This function/PDO is currently executing every time someone visits my site. Working code: /*Check possible existing data*/ $odb ...

I'm having trouble with my tablet view taking priority over my desktop view - what could be causing this issue?

Styling for different screen sizes: @media (min-width: 991px) and (max-width:768px){} .container, .container1, .container2 .container3{ float: left; } .container1{ width: 50%; } .container2{ width: 50%; } .container3{ width: 100%; } /**** ...

Unable to load CSS in Node.js when the parameter in Express.js is too long

I have been working on an application using Node.js, express.js, and ejs. I am utilizing the following code to incorporate ejs and load css: app.engine('.html', require('ejs').__express); app.set('views', __dirname + '/vi ...

Is it possible to combine the :last-child pseudo-class with the universal selector (*) in CSS or Sass

Here is the code I am currently using: .loken5 * padding-right: 5px .loken5:last-child padding: 0 I am wondering if there is a way in SASS to achieve the same effect with just one '.loken5' tag for saving space. Thank you :) ...

When working with Vue.js, toggling the 'readonly' attribute of a textarea between true and false may not be effective

My goal is to accomplish the following: Allow the textarea to be edited when double-clicked; Prevent the textarea from being edited when it loses focus; However, regardless of toggling the 'readonly' attribute, I am currently unable to achieve ...

Associating checkbox options with an array that is void of elements

I have a series of arrays linked to checkboxes and I am trying to create a unique array based on the selected checkbox values. Here is an example of the HTML structure: <input type="checkbox" value="value1">Value 1 <input type="checkbox" value=" ...

Stylesheet compilation with SCSS scripts

I am facing an issue with prefix:css. I am not very familiar with the scss build process, so if anyone knows what the problem is, please help me out. "watch:sass": "node-sass src/styles/global.scss src/assets/css/style.css -w", ...

The functionality of the Bootstrap collapsible feature is not functioning as expected

Just starting out with Bootstrap and Angular, and I'm trying to create a collapsible list group. However, it's not collapsing as expected. Is there something else that needs to be included? My current setup is using Angular4 & Bootsrap 4. ...

Styling images with unique shapes using CSS

I'm attempting to design a unique shape using only CSS so that it resembles the following: image of custom image shape I've been experimenting with CSS3 Mask, but unfortunately the support isn't broad enough as I need it to work in IE 10, Fi ...

Leveraging the sibling combinator for altering the class of a sibling SVG element with the assistance of Material

I have created an SVG picture that I am trying to animate. Behind the elements I want to animate on mouse hover, I have added transparent rectangles. The hover effect works well on these elements as the cursor changes to pointer. However, when I attempt t ...

Loading logos dynamically using Jquery upon selection of an option

In the form I created, there is a dropdown logo selection at the bottom. The options in the dropdown are populated from folders in the root directory using the following code: $dirs = glob('*', GLOB_ONLYDIR); Each of these directories contain ...

Even after setting [attr.disabled]="false" in Angular, the Textarea still remains disabled

I am currently utilizing ngModel for a textarea, and I would like to be able to enable and disable the textarea based on a certain condition. Even though I have bound it correctly and the value is changing to [attr.disabled]="false", the textarea remains d ...