The div on my website is rising to the top

My final div (well, not really final as I plan to add more divs) is moving upwards with the page (trying to adjust the height). I can't figure out why this is happening, especially since my second div is working perfectly fine. Link here:

HTML

   .indexthird  {
            width: 100%;
            height: 40%;
            background-image: url("http://vitas.sk/1/images/indexthird.jpg");
            background-size: cover;
            background-repeat: no-repeat;
            min-height: 300px;
            
        }
        .indexthirdbbg{
         background-color: rgba(0,0,0,0.7);
            width: 100%;
            height: 100%;
            text-align: center;
            padding-top: 7%;
        }
        
        .itquotes{
            
            font-size: 1.5vw;
        }
        .itautor {
            font-size: 1vw;
            margin-top: 1%;
            text-align: center
        }
 <div class="indexthird"><div class="indexthirdbbg">
        <i class="itquotes">"„Kým budu ľudia masakrovať zvieratá, budú zabíjať aj jeden druhého.<br> Ten kto seje vraždu a bolesť, nemôže vypestovať radosť a lásku.“"</i>
      <p class="itautor">Pythagoras</p>
    </div>
    </div>


   

  

Answer №1

give this a shot

   .indexthird  {
            width: 100%;
            
            background-image: url("http://vitas.sk/1/images/indexthird.jpg");
            background-size: cover;
            background-repeat: no-repeat;
            
        }
        .indexthirdbbg{
         background-color: rgba(0,0,0,0.7);
            width: 100%;
            height: 40%;
            min-height: 300px;
            text-align: center;
            padding-top: 7%;
        }
        
        .itquotes{
            
            font-size: 1.5vw;
        }
        .itautor {
            font-size: 1vw;
            margin-top: 1%;
            text-align: center
        }
 <div class="indexthird"><div class="indexthirdbbg">
        <i class="itquotes">"„While people continue to slaughter animals, they will also kill each other. <br> He who sows murder and pain cannot cultivate joy and love.“"</i>
      <p class="itautor">Pythagoras</p>
    </div>
    </div>


   

  

Answer №2

The reason for this issue is that the second DIV with the class (.indexsecond) has a height set to 80%, which changes as the browser window is resized. If the height is changed to pixels and overflow is set to hidden, the problem disappears.

In addition, the .indexthird class has a height set in percentage and the .indexthirdbbg class has padding-top set in percentage, which could be contributing to the issue when resizing the browser window.

One solution could be to define a window.onresize event and adjust the divs programmatically based on some internal logic.

Answer №3

Consider incorporating a "clearfix" div before the final one when implementing Bootstrap in your project.

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

SleekScroll, SafariAssist, and Adaptive Navigation

I have a few queries regarding this side here Is there a way to implement smooth scrolling? I've experimented with different options, but removing the .slim from jquery breaks the dropdown functionality. How can I resolve this issue? I encounter ...

Creating consistency in tab spacing within a text area

At the moment, I am utilizing an HTML textarea attribute to collect input from users and then displaying that text back to them formatted. However, there seems to be an issue with how it handles tabs. For instance, when attempting to input the following: ...

Steps for incorporating a storyline into a CSS Chart

I'm attempting to introduce a horizontal line at a specific point using chartscss.org For instance, on the given chart utilizing Charts CSS below, I'm aiming to include a horizontal line at 15.5... Similar to the illustration shown. I've e ...

When the text is in motion, the ::before element will stay static

I'm working on creating a unique custom SVG underline for a header design. My goal is to achieve something similar to this: https://i.sstatic.net/EI1aT.png Here's what my code currently looks like: HTML: <div class="container"> ...

Conceal elements that are overflowing slightly

I need help coming up with a purely CSS solution to hide div 3, which has extended beyond its container. Look at the picture linked below for reference. https://i.stack.imgur.com/isfvU.jpg ...

What is the best way to extract data from user input and display it in a table modal?

I need to retrieve all the values from the 'input' fields and display them in a modal table using JavaScript. What is the best way to achieve this? Here is my current script: <script> $(document).ready(function() { ...

An easy CSS conundrum when hovering

Looking for some assistance with CSS. I want to display the text "Featured Page" with a picture appearing on the right side upon hovering (mouseover). Currently, the picture shows up under the text using the following CSS, but I need it to be larger and pl ...

When triggered by a click, the function gradually fades in and out. It superimposes one image on top of another, but unfortunately, the sizes

Due to different screen sizes, the image does not appear on top of another image exactly. It seems like a new function is needed. One that does not overlap with another image (by clicking the function for a few seconds), but rather replaces it for those fe ...

Is there a way to automatically close a created div by clicking anywhere outside of it?

I'm facing an issue with a dynamically created div that I want to close by clicking outside of it. However, when I try to achieve this functionality, the div closes immediately as soon as it is opened. closediv(); } function closediv() { d ...

Can the load API in jQuery be utilized to load fragments using a class selector instead of an id?

I've been working on enhancing a website's dashboard by incorporating more widgets onto the page. Interestingly, these widgets are already present on another page within the same domain. After some research, I discovered that utilizing the load A ...

Setting a page title using PHP based on a conditional statement can be achieved by

I am attempting to display a different title for each page In the header.php file, I am checking the file name to set the correct title like this <?php $page = basename($_SERVER['PHP_SELF']); if ($page == 'index.php'): ?> <ti ...

Integrating a Find Pano functionality into a Kolor Panotour

I used a program called Kolor to create a panorama. Now, I am attempting to integrate the "find pano" feature, which involves searching through the panoramic images for display purposes. I have come across an HTML file that contains the search functionalit ...

Create spinning wheel - canvas

Hey there! I'm trying to create a cool spinning wheel using a canvas and JS. My wheel is supposed to have 10 segments, each saved as a .png file. https://i.sstatic.net/glN1p.jpg In order to achieve a "full circle", I want to draw these 10 segments i ...

Creating a website with a seamless image background that fills the entire page

! Is it possible to achieve the same effect using AngularJS? Below is the CSS code: .bg { background: url(holiday-car-rental.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-s ...

Enhance your image viewing experience with a React component that smoothly zooms in on images without distorting their dimensions, all with

After searching extensively for a solution, I have been unable to find one that works. My current setup involves using React with Bootstrap. I am in need of a stateless functional component that can take an image path as input and return an img element. Th ...

Display all event date markers, even if some dates are missing

Using the FullCalendar plugin has been a great experience for me. I have managed to successfully read data from a JSON object with the following code: function press1() { var employees = { events: [] }; ...

Implementing a delay of X seconds after a click event in JQuery: A step-by-step guide

Is there a way to delay the triggering of a click event after one has been recently triggered? I am facing an issue on my website where users can click multiple times on the "dropdown icon" and cause it to toggle the slide effect multiple times. What I wan ...

Creating a multi-level signup page in Angular 4 using Bootstrap

Currently, I am working with angular 4 and bootstrap 4 to create a multi-level sign-up page. One of the challenges I am encountering is how to properly include a JavaScript file into my angular project. import '../../../assets/js/js/multiform.js&apo ...

What could be causing the malfunction of my Superfish menu in Firefox?

I am currently experimenting with the Superfish jQuery plugin to improve a drop-down menu on my website. Unfortunately, in Firefox browser (v. 21.0), the drop-down menu does not open when hovering over it as expected. However, it works fine in Chrome and O ...

Utilizing CSS to position an image at both the top and bottom of a webpage

I have been struggling to find a solution to this particular issue. My goal is to position an image at both the top and bottom of the page using a background property. I understand that by making the positioning relative, the image will be placed at the bo ...