What could be causing the div class to move downward in the CSS code?

I have posted a question, but unfortunately, no one has answered it yet. Here is my code snippet:

* {
    margin: 0;
    padding: 0;
}

body {
    width: 100%;
    font-family: 'Cabin', sans-serif;
    background-color: #333;
}

.firstnav {
    margin:auto;
    height: 1500px;
    display: block;
    width: 70%;
    -webkit-flex: 3 1 60%;
    flex: 3 1 60%;
    -webkit-order: 2;
    order: 2;
}

#third {
    background: #f00;
    position:relative;
    display:inline-block;
    width: 30%;
    margin-left:auto;
    margin-right:auto;
    height: 500px;
    -webkit-flex: 1 6 20%;
    flex: 1 6 20%;
    -webkit-order: 3;
    order: 3;
}

#second {
    background: #fff;
    position:relative;
    display:inline-block;
    margin-left:auto;
    margin-right:auto;
    width: 67%;
    height: 1500px;

    -webkit-flex: 1 6 20%;
    flex: 1 6 20%;
    -webkit-order: 3;
    order: 3;
}

#registration-form {
    font-family:'Open Sans Condensed', sans-serif;
    width: 100%;
    margin: 20px auto;
    position: relative;
    display:block;
    position:absolute;
}

#registration-form .fieldset {
    background-color:#d5d5d5;

    border-radius: 3px;

}

#registration-form legend {
    text-align: center;
    background: #364351;
    width: 100%;
    padding: 30px 0;
    border-radius: 3px 3px 0 0;
    color: white;
    font-size:2em;
}

.fieldset form{
    border:1px solid #2f2f2f;
    margin:0 auto;
    display:block;
    width:100%;
    padding:30px 20px;
    box-sizing:border-box;
    border-radius:0 0 3px 3px;
}
<div class="firstnav">

<div id="second"><p>second<p></div>
<div id="third">

    <div id="registration-form">
        <div class='fieldset'>
            <legend>Todays news
            </legend>
            <form action="#" method="post" data-validate="parsley">

            </form>
        </div>
    </div>

</div>

It seems that the content in the second container is aligning incorrectly. Despite making changes to the "#second" code, the containers are still not side by side as intended. Can someone help me figure out why this is happening?

Answer №1

It appears that a single line is absent. The elements are not floated correctly. Consider including float: left; to #second.

Experiment with it on JSFiddle. I have already implemented the modification for you. Does this achieve what you had in mind? https://jsfiddle.net/jr0gpaqg/

Answer №2

Do you think this solution will be effective for your needs?

Check out this code snippet on JSFiddle

#second {
  background: #fff;
  position:relative;
    display:inline-block;
    float:left;
 margin-left:auto;
  margin-right:auto;
  width: 67%;
  height: 1500px;

   -webkit-flex: 1 6 20%;
           flex: 1 6 20%;
   -webkit-order: 3;
           order: 3;
}

Answer №3

In response to your query...make a modification.

#third {
  background: #f00;
  position:relative;
  display:inline-block;
  width: 30%;
  margin-left:auto;
  margin-right:auto;
  height: 500px;
  -webkit-flex: 1 6 20%;
       flex: 1 6 20%;
  -webkit-order: 3;
       order: 3;
}

Change it to the following...

#third {
    background: #f00;
    position:absolute;
    display:inline-block;
    width: 30%;
    margin-left:auto;
    margin-right:auto;
    height: 500px;
    -webkit-flex: 1 6 20%;
    flex: 1 6 20%;
    -webkit-order: 3;
    order: 3;
}

The issue was with the positioning.

Here is the jsfiddle link for reference.

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

Enable users to choose multiple rows at once or alternatively choose by checking the checkboxes

When using Tabulator with the setting table.selectable = true, any cell click selects the row. However, I specifically want rows to be selected only via checkboxes, so I set selectable = false. The issue now is that the checkboxes behave like a radio butt ...

How to Keep Images Within Table Borders From Overlapping?

I am in the process of experimenting with creating a newsletter and have developed a template. I am very new to design and have created a table of album releases that is not fitting within the border I established. How can I resolve this issue? The code s ...

Steps to reveal a child element when the parent is set to overflow:hidden

There seems to be an issue with a child element having overflow:visible; while the parent element has overflow:hidden;. The height of the child element exceeds that of the parent element. Why is the child element hidden even when its overflow property is ...

How to iterate dynamically over arrays using JavaScript

I am working on a JavaScript project where I need to create a graph with 25 different data points. While my current JavaScript method is effective, I am facing an issue - I have multiple arrays and I am looking for a solution that allows me to use a for lo ...

Is there a way to optimize downloading multiple identical images using html, css, jquery, etc.?

My chess board features 64 squares, each with a picture of a board piece on either a light or dark square. To ensure proper formatting, a Clear knight is placed on the board. The design utilizes a div element with a background image (representing light or ...

Utilizing CSS to create a text box with angled left and right edges

.soccer-field{ width: 50%; box-shadow: 0 4px 12px 4px rgba(0,0,0,0.2); } .text-sf p{ float:left; } .right-curve{ float:right; width: 0; height: 0; border-style: solid; ...

Using HTML and JavaScript to verify email addresses

I have been working on an "Email Validation" code, but it seems to be malfunctioning. I can't figure out why. Would you mind taking a look at it? Thank you. I suspect that the issue lies with this line document.getElementById("custEmail").onchange = ...

Retrieve the initial image link from a blogger's post in cases where it is not being stored on the Blogger platform for use in related

I am currently using a hosting service to store the images that I include on my blogger platform. However, I have encountered an issue where blogger does not automatically fetch the image url to use as the thumbnail when the image is hosted externally. C ...

"Utilizing flex-box to create a hover effect for child elements

I am attempting to create a grid caret with a top and bottom caret that displays a grey area when the user hovers over each side. <div class="control-wrap"> <div class="caret-wrap"> <span class="caret">▲</span> </div&g ...

Show the user's username on their profile page by retrieving the name from the database

Upon successful login/signup with various services, I want to display the username on the profile page. However, my database stores user data in different fields depending on the service used - user.twitter.name for Twitter logins, user.google.name for Goo ...

A vertical scroll bar should be created specifically for a div within a dialog box in

I am working on a jQuery dialog that contains three divs. I want the middle div to have a vertical scroll bar when its content exceeds its height. The first div (top) should remain fixed at the top of the dialog box, and the third div (lower) should stay f ...

Using Javascript to choose an option from a dropdown menu

const salesRepSelect = document.querySelector('select[name^="salesrep"]'); for (let option of salesRepSelect.options) { if (option.value === 'Bruce Jones') { option.selected = true; break; } } Can someone please ...

Using jQuery to handle multiple buttons with the same ID

Is there a way to address the issue of multiple buttons sharing the same id? Currently, when clicking on any button, it only updates the record with id=1. How can this problem be resolved? div id="ShowPrace"> <?php try { $stmt = $pdo->prepare(" ...

Hovering over graphics for automatic scrolling

I have successfully implemented a hover effect that scrolls down an image inside a div. However, I am facing an issue with making the scroll longer for images of varying lengths by using calc inside the transition property. Below is the code snippet that ...

Using Slick Slider and Bootstrap CSS to display text on top of images

Currently, I am utilizing the slick slider from and I want to overlay text on top of the image. I tried using bootstrap carousel-caption, which works well with any image. However, with slick slider, it seems like the text is not at the highest level as I ...

Adjust the viewport to fit the width of the screen and display large images

Currently, I am experimenting with using a WebView to display a large image while incorporating multitouch functionality to prevent memory crashes. My webView is configured as follows: setInitialScale(20); WebSettings settings = getSettings(); ...

Identifying geometric coordinates within Canvas

Currently, I am adding drag and drop functionality to my HTML5 Canvas application. I have encountered a challenge in determining how to detect if the shape being clicked on is not a rectangle or square. For instance, within my 'mousedown' event h ...

React Router Link Component Causing Page Malfunction

Recently, I delved into a personal project where I explored React and various packages. As I encountered an issue with the Link component in React Router, I tried to find solutions online without any luck. Let me clarify that I followed all installation st ...

Transmit HTML form information through a POST request to an ASP.NET web service

Having an HTML page with a contact form is great, but I'm facing the challenge of sending the data using AJAX. I attempted to send the data to a webservice without converting the structure to JSON format, but unfortunately, I did not succeed. Is ther ...

The content division does not have a set position

The content div is not adapting to different screen sizes properly. As the width and height of the browser shrink, it's overlapping with the header and footer. I'm using flex but I'm unsure if I'm implementing it correctly. display: ...