Ways to stop Content from Showing below a div container

Hey, I just created a login panel using CSS and HTML. After applying some floats, all the content ended up displaying under the panel. I attempted to use clear: both, but that didn't resolve the issue. My goal is to have all other contents displayed after the panel, not below it as shown in the image: https://i.sstatic.net/P9vhW.png

Here is my implemented HTML Code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Mobile Web Page</title>
    <link rel="stylesheet" href="css/styles.css" />
    <script
      src="https://kit.fontawesome.com/f99e299e1f.js"
      crossorigin="anonymous"
    ></script>
    <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Monsieur+La+Doulaise&display=swap" rel="stylesheet">
  </head>
  <body>
    <div class="panel-container">
      <div class="panel">
        <div class="left-side">
          <div class="left-text">
            <h1 class="header">Lorem, ipsum dolor.</h1>
            <h4 class="under-header-text">Lorem ipsum dolor sit amet consectetur.</h4>
          </div>
        </div>
        <!--           -->
        <div class="right-side">
          <div class="right-side-container">
            <h1 class="header2">Lorem ipsum dolor sit amet.</h1>
            <div class="login">
            <a href="#" class="google-login"><div class="login-div" >Login with Google</div></a>
          </br>
          <a href="#" class="facebook-login"><div class="login-div">Login with Facebook</div></a>
          </div>
          <h2 class="horizontal-line"><span class="or-text">or</span></h2>
          <form>
            <label>Email</label>
            <input type="text">
            <br>
            <label>Password</label>
            <input type="password">
          </form>
          <a href="#"><div class="login-button">LOGIN</div></a>
        <a href="#" class="forgot-pass">Forgot Password?</a>
          </div>
        </div>
      </div>
    </div>
    <!--v v v v Content I want to display under the login panel v v v v v-->
    <div><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Possimus doloremque ullam hic earum nostrum magnam, consequuntur ut, nulla, suscipit optio sequi eius. Maxime exercitationem facilis, officia, officiis eligendi error hic voluptatibus asperiores aut, labore possimus? Ad, aperiam consequatur. Qui similique nobis mollitia consequatur laborum provident dolore inventore quia dicta a?</p></div>
  </body>
</html>


And here's how I styled the elements in my CSS:


(body styling and panel layouts)

I've tried using 'clear both' and also experimented with pseudo-elements like 'panel:after' and 'clear both page:after', but still couldn't get the desired result. Any guidance or alternative solutions would be greatly appreciated. Thank you for your assistance.

Answer №1

This code snippet demonstrates the structure and styling of a mobile web page layout. The main issue identified in this code is the unnecessary use of positioning, specifically with the .panel class. By changing the position from absolute to relative and adding margin-bottom: 10vh, the intended design can be achieved without disrupting the flow of the page.

Here is an example showcasing the same content without any positioning:

Lorem ipsum dolor sit amet consectetur adipisicing elit. Possimus doloremque ullam hic earum nostrum magnam, consequuntur ut, nulla, suscipit optio sequi eius. Maxime exercitationem facilis, officia, officiis eligendi error hic voluptatibus asperiores aut, labore possimus? Ad, aperiam consequatur. Qui similique nobis mollitia consequatur laborum provident dolore inventore quia dicta a?

Answer №2

To correct the issue, simply delete position: absolute; from the .panel.

body {
  margin: 0;
  background-color: aliceblue;
}

a {
  text-decoration: none;
}


.page {
 ...
 ...

        <a href="#" class="forgot-pass">Forgot Password?</a>
      </div>
    </div>
  </div>
</div>
<!--v v v v Content i want to display under the login panel v v v v v-->
<div">
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Possimus doloremque ullam hic earum nostrum magnam, consequuntur ut, nulla, suscipit optio sequi eius. Maxime exercitationem facilis, officia, officiis eligendi error hic voluptatibus asperiores
    aut, labore possimus? Ad, aperiam consequatur. Qui similique nobis mollitia consequatur laborum provident dolore inventore quia dicta a?</p>
</div>

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

Looking for assistance with changing the class of a span when a radio button is selected

I'm facing an issue with toggling the class of a <span> when a radio button is clicked. <html> <head></head> <style type="text/css"> .eHide { display:none; } </style> <script type="text/javas ...

What are some tips for improving the smoothness and efficiency of my CSS @keyframes animation on SVG elements specifically in Firefox?

I noticed that this particular animation is causing high CPU usage on all browsers, although it runs more smoothly in Chromium. Is there a way to optimize its performance? Here's the SCSS code which is relatively simple: @keyframes laptop { from { ...

Applying a CSS class (or style) dynamically depending on the variable with the help of a directive

I'm facing a situation where I need to apply ng-style (or ng-class) multiple times depending on a variable. However, this repetitive task of writing ng-class for the same functionality for each widget is quite cumbersome for me. Is there a way to si ...

Is it necessary to upload static files in included HTML when using Django?

I am currently in DEBUG mode and I need to convert an HTML page into a PDF using PrinceXML. Within my main HTML file, the code looks like this: {% extends "base.html" %} {% load staticfiles %} {% load url from future %} {% block title %}Title{% endblock ...

Load Image Timing Discrepancy in Web Development (jQuery/PHP/HTML)

I am currently using jQuery to develop a basic slideshow feature. Within my home.php file, I have created a slideshow. Additionally, there is a menubar that allows users to navigate to different pages. Upon clicking on "Home" in the menu, the home.php con ...

Encountering a NaN outcome when summing values from various select options

I'm working on a project that involves adding up the prices based on the surface chosen by the user. I'm struggling with calculating the partial cost when the user's choice changes. totalSum.ts num: Calculation totalAmount: number cate ...

Enhanced auto-zoom feature with orientation change for iOS 7

My web page was functioning perfectly until the release of iOS 7 by Apple today, causing the layout to break when the screen orientation is changed. When focusing on a text area and rotating the screen to landscape view, the entire page zooms in. However, ...

Looking to crop a canvas without changing its dimensions using jQuery

I'm currently working on a project that involves overlaying two images; one uploaded by the user and the other a default image. However, I am facing an issue when the uploaded image is a rectangle instead of a square, causing the canvas to resize it. ...

Incorporating a custom background image for Google Maps

Can a live Google map achieve the same overlay effect as a static image? Discover more here Many thanks, Greg Update: Check out this Fiddle that was created based on another Fiddle by @SinistraD ...

Implement a hover animation for the "sign up" button using React

How can I add an on hover animation to the "sign up" button? I've been looking everywhere for a solution but haven't found anything yet. <div onClick={() => toggleRegister("login")}>Sign In</div> ...

Employing AJAX to send form data to a pair of destinations

Can anyone help me out? I am having trouble using AJAX to submit my form to one location and then to another. Once it's posted to the second location, I want it to send an email with PHP to a specified recipient, but for some reason, it's not wor ...

What's the easiest method for moving div content from side to side?

Working on a plugin for WordPress, I am faced with the task of moving content in a slider from left to right and right to left. My current attempt is as follows: var effect = 'slide'; // Set the options for the chosen effect type var opti ...

Toggle the visibility of elements (such as a form) with a click of a link - Utilize ajax to

I'm attempting to use jQuery to toggle the visibility of a form. This functionality is triggered by clicking on a specific link... The goal is to hide all links with data-action="edit" and only display the form that follows the clicked link, as there ...

Creating a smooth transition effect on text length using Javascript and CSS: Fading the text as it

I have been searching everywhere for a solution to my issue, but I haven't found it yet. I keep coming across methods to fade text on and off on load, which is not what I need. My goal is to fade some text on the same line, and I have created a mockup ...

Using Angular material to display a list of items inside a <mat-cell> element for searching

Can I use *ngFor inside a <mat-cell> in Angular? I want to add a new column in my Material table and keep it hidden, using it only for filtering purposes... My current table setup looks like this: <ng-container matColumnDef="email"> < ...

Steps for displaying the dropdown menu

I am having trouble with displaying the dropdown menu when hovering over the class (dropbtn). I tried adding .dropdown:hover .dropdown-content-strategy{..} but it's not working as expected. If I do manage to show the dropdown menu, it stays visible ev ...

The scrolling feature induces a contraction to the left side

Recently, I implemented the code below to fix my menu when scrolling the page: var num = 5; $(window).bind('scroll', function () { if ($(window).scrollTop() > num) { $('.scroll').css({'position':'fixed&apo ...

In my ejs file, I need to input a name and then process it in my post request

I am working on an ejs file where I need the user to input their username into a form. I will then use this username in a .get request to perform certain logic. However, I am encountering an issue where the username is showing up as undefined. Here is a s ...

Fadein and FadeOut Div transitions are operating correctly in a loop, however, the initial DIV is not being displayed

Why is the first DIV not fading in at all when I have 3 divs set to fade in and out? I'm confident that my code is correct, any ideas? My jQuery/Javascript code: <script type="text/javascript"> $(document).ready(function() { function fade( ...

React JS makes it simple to create user-friendly cards that are optimized

I have a collection of objects that include a name and description. The name is short and consists of only a few characters, while the description can vary in length. I am looking to showcase this data within Cards in my React project, and have tried using ...