What could be causing the extra gap at the top of my div element?

BEFORE MAKING ASSUMPTIONS, READ THIS I have already attempted using margin-top: 0px;

  <html>
    <head>
    <style>
    html, body {
    padding: 0px;
    margin: 0px;
    }
    body {
    font: 22px trebuchet ms;
    }
    button {
    color: white;
    font: 18px verdana;
    background-color: #aef731;
    border-style: solid;
    border-bottom-color: #96d626;
    border-width: 0px;
    border-bottom-width: 7px;
    border-radius: 12px;
    padding: 5px;
    }
    button:active {
    border-bottom-width: 0px;
    position: relative;
    top: 7px;
    }
    button:focus {
    outline: none;
    }
    div.title {
    padding-left: 15px;
    color: white;
    background-color: #96d626;
    }
    cat.indent {
    padding-left: 30px;
    }
    img.slgm {
    border-style: solid;
    border-color: #000000;
    border-width: 4px;
    float: left;
    position: relative;
    top: 30px;
    left: 30px;
    }
    div.txt1 {
    border-style: solid;
    border-color: #000000;
    border-width: 4px;
    background-color: #e8e8e8;
    float: right;
    position: relative;
    top: 30px;
    right: 30px;
    padding: 5px;
    width: 600px;
    }
    div.txt2 {
    border-style: solid;
    border-color: #000000;
    border-width: 4px;
    background-color: #e8e8e8;
    width: 400px;
    position: relative;
    top: 200px;
    left: 30px;
    padding: 5px;
    }
    </style>
    </head>
    <body>
    <div class="title"><h1>60 Second Science!</h1><cat class="indent">Molecules of Solids, Liquids and Gases</cat></div>
    <img src="SLGM.png" class="slgm">
    <div class="txt1"><h3>Introduction</h3>Solids, liquids and gases all have different molecular structures. Today, we will explore each form of matter's molecules.<br><h3>Solids</h3>Solids(left) have a very compact structure. The molecules squish together and barely vibrate.<br><h3>Liquids</h3>Molecules in liquids(center) can move freely but stay bond together causing them to have a definite volume, but not a definite shape.</div>
    <div class="txt2"><h3>Gases</h3>Gases(right) have no definite shape or volume. This is because their molecular structure is very spacious. The particles have broke free of each other. Therefore, the gas can expand.</div>
    </body>
    </html>

When executing this code, there seems to be excessive space at the top of the "txt2" class div. I've attempted various solutions like eliminating top padding, revising the code, etc. Urgently seeking assistance to resolve this issue!

:D

Answer №1

The issue lies in the div.txt2 element where the rule top: 200px is causing extra height. I have adjusted this to top: 30px to match the height of the other <div> elements in my example.

It's worth noting that many of your elements have fixed width values in pixels which may not scale well on mobile devices. Consider using percentage-based values for better responsiveness.

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

What steps should I take to fix the "loading page" issue in VS2010?

Upon attempting to debug (F5) my website, I encountered the following error message: "Firefox cannot locate the server at www.localhost.com." Switching to IE did not resolve this issue either. Any suggestions on how to fix this problem would be greatly ...

Utilizing CSS and HTML to center elements

My jquery datepicker is set up to display color dots above certain days to represent information for that day. I'm running into some CSS issues. I'm trying to center the dots with the corresponding numbers, but when I do that, the days with dot ...

Ways to display closing tag in minimized code in JavaScript documents

I am encountering an issue where the closing tag of folded code is visible in my HTML file, but not in my JS files (specifically JSX syntax). I apologize if this is a trivial question, but I am hopeful that someone can assist me in making the closing tag ...

The Zoom CSS property seems to be experiencing some issues on the Firefox browser

After researching the issue, I discovered several solutions involving css3 transition techniques. Currently, I have been using {zoom:1.5} for all of my buttons. However, this method does not work on Firefox. When attempting to implement the transition pro ...

displaying HTML on the web page only, without appearing in the text input field

update1: I have updated the image to provide better clarity https://i.sstatic.net/hYLsI.png I am currently working on implementing chip filters similar to Google Flights. When selecting "sports," it currently displays "sports1" and replaces "sports" with ...

Integrating a title field into every p-column with ng-template

I am exploring ng-templates for the first time. I have managed to customize each column to display names accurately, but I am encountering an issue. I would like to incorporate a title field in order to show a tooltip with the full name when hovering over ...

Ways to enhance an image by zooming in when the user reaches a designated area on the webpage

I have implemented a feature where an image zooms in to letter L when the user scrolls on the page. However, I want this zoom effect to occur only when the user reaches a specific section of the site, rather than immediately when the image loads. In my exa ...

Is it possible to install a Chrome extension specifically for YouTube on Google Chrome?

Hey, I'm trying to eliminate thumbnail images from YouTube. The code I am currently using is: while (true) { $("ytd-thumbnail").remove() } As of now, when I input this code in the console, it successfully removes all thumbnail images. However, I ...

The Bootstrap form fails to function properly on mobile devices

On my Bootstrap form, everything works fine when entering data on the desktop version. However, I am facing an issue with the mobile version where I cannot input any information into the fields. The fields are unresponsive and not allowing me to enter an ...

Is it possible to create a form inside a tooltip?

Looking to incorporate a jQuery feature into a form where a simple yes or no question appears upon hovering over it. However, encountering issues getting jQuery to recognize the dynamically created tooltip and submit alert function not working ("$('#w ...

Ways to eliminate the influence of parent containers on child controls

Q: I'm encountering an issue with my date picker implementation using RadDatePicker within a table td and multiple containers (div). The problem arises from the navigation text being reversed - ">>" instead of "<<", ">" instead of "< ...

Enforcing Height Constraints on Images in HTML/CSS

I'm currently working on a design project and encountering a minor issue. Feel free to take a look at the final design example linked here: In the menu on both sides, you'll notice a small border that runs from top to bottom, matching the heigh ...

The motion defined in the CSS keyframes is failing to animate as expected

http://plnkr.co/edit/46U9HFEJ3bWoYnvmeulY?p=preview I am trying to create a keyframes animation in the plnkr above that will make links move from left to right with an opacity change on load. However, I am facing an issue where only the opacity change is ...

After reducing the size of the table, the data spills over

Hey there, amazing individuals of the internet! Hope you're all doing well today. I've encountered a rather perplexing issue that's got me stumped. So, here's the situation - I have this table full of data and I want it to initially be ...

Setting the maximum height for a div element

Struggling to understand how a div can occupy the entire height of a container. In this particular scenario, I am aiming for the "photo" div to take up the full height, with the yellow and green content appearing on the right side of the photo. Below is th ...

The value attribute in HTML is failing to display the desired output

<form> <?php $studentID = '111503062'; $database = new DB(); $query = "SELECT * from Extracurricular where MIS =" . $studentID; $result = $database->run_query($query); $data = mysqli_fetch_array($result); e ...

Is there a way to automatically highlight an input field upon page load?

Is there a way for certain websites to automatically highlight an input field upon entering a page? For instance, YouTube's login page automatically highlights the Username field as soon as you land on it. Even this site, particularly on the Ask Ques ...

Modal obstructing BsDatePicker

<!-- The Server Modal --> <div class="modal" id="serverModal"> <div class="modal-dialog" style="max-width: 80%;overflow-y: initial !important;" > <div class=" ...

Issue with Chrome (2) preventing HTML5 video from loading using video.js

This particular question is identical to the one found at HTML5 video (video.js) not loading in Chrome, which unfortunately was left unresolved. When attempting to load only a mp4 source on Chrome, I encounter the following message in the console: Array[ ...

The mobile responsive view in Chrome DevTools is displaying incorrect dimensions

Seeking some clarification on an issue I encountered: I recently created a simple webpage and attempted to make an element full width using width: 100vw. However, I observed that on screens smaller than around 300px, the element appeared smaller and not t ...