While typing in the box I am currently working on, another CSS box is shifting around

Whenever I try to add a paragraph to my box, the other one shifts. I've checked for any issues with margins or spacing, but nothing seems off from what I can tell. I have no clue how to resolve this. Here's how it appears before making any changes: https://i.sstatic.net/n5SFj.jpg And here's how it looks after adding text or any content to the box https://i.sstatic.net/y0Zyx.jpg

As you can see, the adjacent box is shifting down as I type more content. Any insights into what might be causing this would be greatly appreciated.

HTML CODE:

    <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Inlamningsuppgift 1</title>
    <link rel="stylesheet" href="css.css">
  </head>
  <body>
  <div id="wrapper">
    <header>
        <h1> Inlamningsuppgift 1 </h1>
    </header>
    <nav id="firstnav">
        <a href="start.html" id="start"> Start </a>
        <a href="filmer.html" id="filmer"> Filmer </a>
        <a href="bildspel.html" id="bildspel"> Bildspel </a>
        <select>
          <option value="Blue"> Blå </option>
          <option value="Red"> Röd </option>
          <option value="Violet"> Lila </option>
        </select>
    </nav>
  <section>
    <h3> Välkommen till min webbplats! </h3>

    <article id="presentation">
      <h4> Vem är skaparen av sidan? </h4>
    </article>

    <article id="anledning">
      <h4> Anledning till att jag gör denna sidan </h4>
      <p> hej
    </article>

    <article id="utmaningar">
      <h4> Tre saker jag tyckt varit utmanande med uppgiften </h4>
      <ul>
        <li> Sak 1 </li>
        <li> Sak 2 </li>
        <li> Sak 3 </li>
      </ul>
    </article>
  </section>
  <footer>

  </footer>
  </div>
  </body>
</html>

CSS CODE:

    #wrapper{
    margin-left:auto;
    margin-right:auto;
    width:970px;
}
header{
  background-color: grey;
  text-align: center;
  padding: 10px;
}
#firstnav{
  background-color: black;
  padding: 10px;

}
#start{
  margin-right: 250px;
  text-decoration: none;
  color: white;
}
#filmer{
  margin-right: 150px;
  text-decoration: none;
  color: white;
}
#bildspel{
  text-decoration: none;
  color: white;
}
nav select{
  float: right;
  width:250px;
}
section{
  background-color: grey;
  padding-top: 1px;
  padding-bottom: 40px;
}
section h3{
  text-align: center;
  padding-bottom: 12px;
}
#presentation{
  width: 350px;
  height: 100px;
  background-color: white;
  display: inline-block;
  margin-left: 75px;
  padding-left: 20px;
  clear: both;
}
#presentation img{

  width: 40px;
  height: 40px;
}
#anledning{
  display: inline-block;
  height: 100px;
  background-color: white;
  width: 350px;
  margin-left: 70px;
  padding-left: 20px;
  clear: both;

}
#utmaningar{
  background-color: white;
  width: 850px;
  margin-left: 70px;
}
#utmaningar > h4{
  padding-left: 10px;
  padding-top: 8px;
}
footer{
  text-align: center;
  background-color: black;
  color: white;
  padding: 10px;
}

The elements with IDs #presentation and #anledning are the ones moving.

Answer №1

Discovered the solution: It seems that adding

vertical-align:top;

helps resolve the issue.

Answer №2

Simply apply the style vertical-align: top

Cascading Style Sheets (CSS)

#presentation {
    width: 350px;
    height: 100px;
    background-color: white;
    display: inline-block;
    margin-left: 75px;
    padding-left: 20px;
    clear: both;
    vertical-align: top;
}

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

PHP and MySQL not displaying the image

I have written the following code to display information about an image, including its file, but for some reason, it is not appearing on the screen. <?php include('config/dbconnect.php'); if(isset($_GET['id'])) ...

Ways to break up the loop for showing 2 items on each slide and 1 item every 3rd slide

I have a database with approximately 19 images that I want to display in slides. The goal is to have 9 slides with 2 images each and the 10th slide with just 1 image. Additionally, every fifth item should be displayed individually. For example: Slide 1 - ...

Are there any Bootstrap 4 classes that have the "cursor:pointer" style other than "btn"?

I am currently utilizing the Bootstrap cards class for my project and I am trying to achieve a cursor pointer effect when hovering over certain cards. However, I prefer not to resort to using the style attribute and only want to utilize Bootstrap classes ...

What is the best way to display data in the User Interface when data is being received through the console in AngularJS?

I have created an HTML file and the corresponding controller logic for this page. I can see the data in the console, but it's not displaying on my UI. <div id="panelDemo14" class="panel panel-default" ng-controller="NoticeController"> < ...

Display advertisement in full screen on mobile devices with no need for scrolling bars

I am looking to develop a webpage using HTML/CSS/Javascript that can display an advertisement in full screen on mobile devices like smartphones and tablets. The ad should expand to the maximum width and height of the screen without any scrollbars. I have ...

Out-of-sync movement in animated characters

Looking for some assistance with my page coding. I have a scenario where two stars are moving around a button, simulating an animation by incrementing the CSS properties top and left. Initially, everything appears fine and they move synchronously. However, ...

Jquery is unable to detect duplicate class names

if ($(".event_list")[0]){ if($(".event_list").find(".type").length == 0 && $(".event_list").find(".sold").length == 0) { $(".event_list").click(); } } else { $('#something').click(function() { location.reload(); }); } I attemp ...

In Angular 16, allow only the row that corresponds to the clicked EDIT button to remain enabled, while disabling

Exploring Angular and seeking guidance on a specific task. I currently have a table structured like this: https://i.stack.imgur.com/0u5GX.png This code is used to populate the table: <tbody> <tr *ngFor="let cus of customers;" [ngClass ...

What is the best way to adjust a div's height to fill the remaining space of the viewport after the header's height

Is there a way to create a hero section that fills 100vh minus the height of the header, especially when the height of the header is not fixed? I initially used CSS with a height property set to calc(100vh - 310px), where 310px represents the height of t ...

How can I retrieve the input value on the current page using PHP?

Hey there, so I'm pretty new to PHP and I have a question. Is it possible to retrieve the input value from an existing input field on a page using PHP when the page loads, and then assign that value to a variable? For instance, let's say I have ...

Setting the table's float property to left will prevent the colspan attribute from functioning

I want to implement a colspan in my table with this specific CSS styling. tr { display: block; float: left; } th, td { display: block; border: 1px solid black; } I have experimented with using colspan and rowspan, but it only seems to cover one column ...

Is there a way to transfer JavaScript data to PHP?

<div> <p>This is a sample HTML code with JavaScript for tallying radio button values and passing them to PHP via email.</p> </div> If you need help converting JavaScript data to PHP and sending it via email, there are v ...

Position dropdown elements using absolute alignment

I am attempting to replicate the drop-down menu style used on Twitter. Here is an example of what I am trying to achieve: (Click on the language option). To accomplish this, I have implemented the following HTML: <a href="#language">English</a ...

BASH-SHELL SCRIPT: Display a specific portion of content from a file

Recently, I stumbled upon a text file containing a snippet of HTML code: >>nano wynik.txt which includes the following text: 1743: < a href="/currencies/lisk/#markets" class="price" data-usd="24.6933" data-btc= "0.00146882" My goal is to extr ...

Is there a way to incorporate a Bootstrap dropdown menu into a Kendo

Having some trouble with the z-index of the bootstrap dropdown in the kendo table. Here is a working fiddle: http://jsfiddle.net/DTcHh/3142/ The dropdown is appearing underneath the table body. Unsure what the issue could be? HTML <table class="tab ...

Dreamweaver's JSON stringify works perfectly in preview mode, but fails to function when accessed from the .AIR file after application creation

For a while now, I've been working on a basic application using Adobe AIR, specifically the HTML and JavaScript version. What this application does is submit a form to an online URL, with the form values being converted to JSON strings. In order to ...

Foundation framework enables the creation of a full width footer that stands out

I'm having trouble getting my footer panel to stretch across the entire page, it seems stuck in the center. The header at the top of the page spans the full width just fine. Am I missing something? My goal is to make both panels at the bottom of the p ...

The div containing the AJAX POST success message suddenly vanishes within moments of being uploaded

Encountering an issue following a successful AJAX post, where the updated div disappears shortly after Here are the jquery/PHP/POST data in sequence. Button On Click Function: function Delete_ID(clickBtnValue,clickBtnID,clickBtnName) { var my_data = {& ...

Center alignment of text and images within the button's image

Can someone help me format my CSS properly? I have a button image where the text should be on the left side and another image on the right side. Currently, everything is centered. Thank you in advance. Here is the current code: button { /* padding- ...

Tips for shifting a stuck div 200px upward once the bottom of the page is reached while scrolling:

I've set up a page layout with two columns, one fixed and the other scrollable. The left column is fixed (containing Google ads) and stays in place as I scroll down the page. The right column displays posts and scrolls along with the rest of the con ...