Prevent Div from hiding beneath another Div

After searching Google for an hour and tinkering with the code, I'm still unable to figure out why my divs refuse to stack on top of each other.

One div keeps appearing below the other, and I'm experiencing a mental block at the moment. Any suggestions would be greatly appreciated.

To rephrase the issue: How can I make all divs push down the content of other divs instead of going underneath the subsequent div?

To see the problem in action, please visit this Codepen link: https://codepen.io/livinglegendparagon/pen/wzWwya

   /* Custom Styles */
  body {
    background-color: #000;
    color: #000;
  }

    #bg {
      height: 100%;
      width: 100%;
      left: 0;
      top: 0;
      opacity: 1;
      position: relative;
      height: -webkit-calc(100vh);
      height:    -moz-calc(100vh);
      height:         calc(100vh);
    }
  #PUTBACKGROUNDHERE, #PUTBACKGROUNDHERE2, #PUTBACKGROUNDHERE3, #PUTBACKGROUNDHERE4 {
    background-color: #fff;
    width: 100%;
    position: relative;
    height: 100%;
    // min-height: -webkit-calc(100vh);
    // min-height:    -moz-calc(100vh);
    // min-height:         calc(100vh);
    padding: 2.5% 0;
    background-color: #fff;
    display: block;
    float: left;
    clear: both;
    @media (min-width: 280px) {
      padding: 2.5% 5%;
    }
  }
  #backGroundForViewWelcome {
    background-color: white;
    min-height: -webkit-calc(100vh);
    min-height:    -moz-calc(100vh);
    min-height:         calc(100vh);
  }
  .wrapper {
    height: 100%;
    width: 100%;
    display: block;
  }
  .boxForServices {
    position: relative;
    height: 21.5vh;
    margin: 3vh auto;
    width: 100%;
    color: white;
    &:first-child {
      margin-top: -webkit-calc(3vh + 40px);
      margin-top: -moz-calc(3vh + 40px);
      margin-top: calc(3vh + 40px);
    }
    &:last-child {
      margin-bottom: -webkit-calc(3vh - 40px);
      margin-bottom: -moz-calc(3vh - 40px);
      margin-bottom: calc(3vh - 40px);
    }
  }
  .boxForServicesTitle {
    cursor: pointer;
    position: relative;
    text-align: center;
    top: 50%;
    border: red 5px solid;
    background-color: blue;
    border-radius: 5px;
    margin: auto 5vh;
    padding: 5vh 10%;
  }
  #sizeThisTextBoxForServices {
    margin: 10% 10%;
    width: 80%;
  }
  .centerBox {
    margin: auto;
    text-align: left;
  }
  .otherInput {
    display: block;
    width: 100%;
    margin-bottom: 5%;
  }

Answer №1

The element .boxForServices needs a height attribute specified.

To resolve this issue, add a height of 100% to the CSS code.

I find that asking questions often leads me to the answers I seek, especially after posting the question.

      .boxForServices {
        position: relative;
        height: 21.5vh;
        margin: 3vh auto;
        width: 100%;
        height: 100%;
        color: white;
        &:first-child {
          margin-top: -webkit-calc(3vh + 40px);
          margin-top: -moz-calc(3vh + 40px);
          margin-top: calc(3vh + 40px);
        }
        &:last-child {
          margin-bottom: -webkit-calc(3vh - 40px);
          margin-bottom: -moz-calc(3vh - 40px);
          margin-bottom: calc(3vh - 40px);
        }
      }

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

How to Fetch Data Using jQuery AJAX in PHP Without Page Refresh

I am trying to prevent the page from refreshing when clicking on a select option, but when I do so, the data does not get updated. Here is the code: echo "<form name='frmtopdevotees' method='post' action='topuser_load.php&apos ...

Can someone help me locate the selector for using .click in Nightmare.js?

I am currently using Nightmare.js to automate the scraping of a webpage. As a sysadmin, my understanding of Node.js and CSS is limited. So far, I have been able to successfully use Nightmare to input and click on certain buttons in order to log in. I iden ...

Trouble with Firebase import despite successful installation

I attempted to create a basic website to gain knowledge about Firebase 9, but I am facing issues when trying to import firebase files. I have searched for tutorials on configuring firebase, but they either do not address my problem or are based on older v ...

Javascript failing to apply placeholder script when requested

Is there a way to make a navigation bar stay fixed at the top of the page without it jumping when it transitions positions? I've tried using a placeholder but it doesn't seem to work. Any suggestions on how to solve this issue? #navbar { wid ...

ng-required is ineffective when used with number inputs that have a minimum value requirement

In my form, I have implemented a checkbox that, when checked, toggles the visibility of a div using AngularJS's ng-show. Within this div, there is an input field of type "number" with a validation setting of min="10000". I am trying to prevent the f ...

Jquery is unable to showcase search results based on the 'data-name' attribute

Building a search feature below that filters results based on the data-name attribute. For instance, if the user types "XL," all div elements with data-name as "XL" will be displayed. I am able to see all results but the other buttons aren’t showing any ...

What is the process for displaying a three.js project?

I've been trying to follow a beginner's tutorial on three.js from this link, but I'm encountering an issue in part 2 where nothing seems to render on my webpage. Despite checking out other guides, I can't seem to solve the problem. I u ...

Conceal the Standard Select Dropdown Arrow in Internet Explorer 9

VIEW DEMO I attempted to use the CSS property appearance: none; to hide the select dropdown arrow, but it still shows in IE9. Refer to the image for clarification. Does anyone have a solution to hide the arrow using either CSS or jQuery? Below is my cod ...

I am having trouble getting IF statements within an onchange function to properly execute when using Javascript

My goal is to use JavaScript to trigger a function whenever a select dropdown menu undergoes a change. This is the HTML structure: <select id="select" onchange="characterchange()"> <option value="spidey">Spider-Man <option value="panth ...

Content in an adaptable image map and its regions

I have implemented an image map structure like this. <div class="container"> <div class="row"> <div class="col-lg-12"> <img src="..." style="width: 100%;" usemap ...

Changing the content of a form with a personalized message

I am currently working on a Feedback modal that includes a simple form with fields for Name, rating, and comment. After the user submits the form, I intend to display a custom message such as "Your feedback has been submitted." However, I am facing an issu ...

PHP POST data not displaying in output

Having an issue with displaying the chosen value from a database enum in a text field on my website. The enum table has options like Bachelor of Science, Master of Science, Bachelor of Education, and Master of Education. I want to show the selected option ...

Create an HTML table cell that shows only part of the text with a button labeled "Show more/less" to toggle between displaying or hiding the complete text

Concern: I am dealing with a HTML table that contains multiple columns, with the last column being "Stack Trace" which is often lengthy. The complete display of the stack trace leads to poor table formatting. Goal: My aim is to showcase the "Stack Trace" ...

Python: A comprehensive guide on utilizing find_element_by_css_selector in Selenium

I am attempting to scrape news comments. My goal is to extract the number '72' from this blue-lined HTML code. https://i.sstatic.net/mKC85.png This is the code I have been using: per_male = driver.find_element_by_css_selector('div.u_cbox_ ...

Locating the following child element in Selenium: A step-by-step guide

I'm encountering obstacles in determining the precise location of the second div.row element based on the preceding child element (the second div.trigger element on the page) <div id='subscription'></div> <div class='set ...

Position div elements randomly on the webpage when it first loads

I am trying to achieve a set of divs that will appear randomly on the page when it loads. Currently, I have the divs moving around the viewport in a random manner, but they all seem to load in the top left corner. This is the method I am currently using: ...

Give permission to a SPAN element to exceed the boundaries of its enclosing DIV element

I am attempting to add a watermark sample over an image (and rotate it) using the code below. However, I am encountering issues when the text size is too large or lengthy, causing the words to wrap and create two lines. If I disable wrapping with white-spa ...

When there are multiple elements within the parent container, the CSS hover margin-top alteration fails to take effect

I am currently working on creating a dynamic menu bar that has elements which smoothly move upwards on hover. However, I have encountered an issue where this movement effect only works when the parent container contains exactly one element (such as in titl ...

Attempting to align text around an image within Bootstrap 4

I'm struggling to wrap text around my image at approximately 1355px. I attempted using float-left on both the div container and the img tag, but nothing seems to be working. Could it be due to the column setup I have in place? Should I perhaps add an ...

What causes the translation of text within HTML tags to occur when attempting to retrieve it during Web Scraping?

Exploring the world of web scraping, I am currently immersed in a small project. In this snippet of code, I am capturing the HTML content and storing it in a variable named soup. source=requests.get(URL) soup=BeautifulSoup(source.text,'html.parser&apo ...