Two floating elements collide as the first one drifts over the second

I am working on a simple webpage that should take up the entire browser window. There are only two elements in it, but the issue is that the second element is being overlapped by the first.

form 
{
    background-color:#996600;
    width:30%;
    height:100%;
    float:left;    
    font:"Arial Black", Gadget, sans-serif;
    color:#FFF
}

#risultati 
{
    width:70%;
    background-color:#0099FF;
    font:"Arial Black", Gadget, sans-serif;
    color:#FFF
}


<body>

<form action"">
 <label>Enter company name</label>
   <input name="key" onkeyup="showHint(this.value)"/>

 <!-- <input type="submit"/> -->
</form>

<p id="results">Results: <span id="txtHint"></span></p> 


</body>

Where could the problem be?

EDIT: I have noticed that the overlap only affects the background property of the second element (the word "Results" is displayed correctly). I was expecting the background to fill the remaining space of the browser starting from the end of the first element. Instead, it starts from the left side of the browser where the first element is positioned.

Answer №1

There seems to be an overlap issue between two elements due to one having float: left and the other not having it. To fix this, you can add float: left to the CSS declaration for #results:

#results 
{
    width:70%;
    background-color:#0099FF;
    font:"Arial Black", Gadget, sans-serif;
    color:#FFF;
    float: left;
}

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

Creating a directory using PHP's `mkdir` function with special characters results in a

My approach involves using special characters to display galleries-folders on the main page. The folders are created based on user input and I prefer not to use special characters in URLs, but rather to show content through the use of glob. $foldername= $ ...

Using jQuery, inject code and text into an element

There's a situation where I have an array with exactly 3 entries. First Entry: <i class="fa fa-star" aria-hidden="true"></i><i class="fa fa-star" aria-hidden="true"></i><i class="fa fa-star" aria-hidden="true"></i> ...

Manipulate the contents of children divs within a parent div using JavaScript or JQuery

<div id="abc"> <div id="a_b"> abcd </div> <div id="c_d"> xyz </div> </div> I have a challenge where the divs on my page are generated dynamically and their IDs change every time the page loads. When the window i ...

"Encountering a glitch with masterpage.cs in Aspx.net and C#

Currently facing a perplexing issue while developing a website using aspx.net and c#. The following code snippet is on my masterpage: protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Request.Url.AbsolutePath == "/ ...

When the mouse leaves, the background image will revert back to its original setting

https://i.stack.imgur.com/Ojd0Q.pngI need assistance in reverting a div's background image back to its default state using the onmouseleave method. Below is the HTML and JS code I have been working on: <script type="text/javascript"> functi ...

Is there a way to record form choices upon submission?

How can I retrieve selected options from a form upon submission? I have a basic HTML form that triggers a JavaScript function on exit. However, I am unsure of how to capture the chosen option from the <select> element. Please refer to the code snip ...

Is there a way to hide a paragraph or div using javascript?

I am experimenting with using buttons to hide paragraphs using javascript, but even when I set them as "hidden", there is still excess blank space left behind. Is there a way I can eliminate that extra space? Below is the javascript code: function backgro ...

I'm experiencing an issue with my Bootstrap Navbar Toggle not toggling

Struggling for weeks now to figure out what's wrong with this code. It works perfectly until I resize the browser, then the menu stays open no matter how many times I click the toggle. I want it to be closed by default and only open when the toggle is ...

Can someone explain the purpose of adding "v=747" at the end of /site_media/base.css?v=747?

Observing a webpage's source code, I came across the following CSS declaration in the header: <link rel="stylesheet" href="/site_media/base.css?v=747" /> Could you please explain the significance of "?v=747" at the end of this CSS declaration? ...

The Sublime/TAG feature "Eliminate Selected Attributes from Tags" does not support the removal of "data-reactid" attributes

I am attempting to utilize TAG in Sublime Text 3 -- https://github.com/titoBouzout/Tag When I apply the "Remove Picked Attributes From Tags (in Document)" feature with class it successfully eliminates all class attributes. However, when I use it with ...

PHP throws an error of "Undefined property: stdClass" when attempting to upload an image's path

I am currently uploading the description, number, and the image path using PHP database. However, I am encountering an error when attempting to retrieve the image from the controller. The error message reads: "Undefined property: stdClass::$imgPath .... o ...

Avoid cascading of the 'display' property in JavaScript styling to prevent inheritance

Is there a way in Javascript to toggle the visibility of a larger portion of HTML without affecting inner display properties with display: <value>? Despite setting an outer display property using Javascript, the inner display properties are also alt ...

How can you ensure that text inside a tag is styled as italic using font-style: italic and the !important keyword in HTML and CSS?

I've created an HTML site using chordpro.php generator, and the specific aspect related to this query is as follows: <div class="song"> <table border=0 cellpadding=0 cellspacing=0 class="songline"> <tr class="songlyricchord"><td& ...

Challenger arises in the realm of Chakra UI styling

Recently, I've encountered an issue with displaying a card using chakra UI and next js. The CSS of chakra UI seems to be messed up, causing all my components to display incorrectly. It was working perfectly fine until yesterday. I tried deleting the . ...

React component rendering twice due to width awareness

In a React component that I've developed, I have utilized ResizeObserver to track its own width. Within this component, two divs are rendered with each having a "flex: 1" property to ensure equal width distribution. Under certain conditions, such as w ...

The impact of CSS on AJAX controls

Struggling to understand why the AJAX control is behaving strangely in relation to this CSS file. Interestingly, removing the CSS file fixes the display issue. CSS File .tdMain { width:452px; font-family:Arial; font:bold,small; } .tdInput { ...

Checking links with AngularJS and HTML 5

Good day everyone: It seems like a simple question, but despite spending hours searching online, I am still unable to find the solution: how can an URL be validated with the inclusion of www without using http. Here's what I have tried so far: I a ...

What is the best way to center align a YouTube embedded video using bootstrap?

I'm having trouble centering a YouTube embedded video on my Bootstrap page. The video size is always the same. My html code is simple: <div class="video"> <iframe width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" ...

transforming unicode into regular characters prior to being presented on a webpage

I am currently utilizing the openinviter class to import contacts from emails. Sadly, it is showing Unicodes of non-English characters, like Polish, such as u0117 (and similar code types), instead of regular characters. Is there a way to convert these Unic ...

Tips for showcasing personalized validation alerts with jQuery in the HTML5 format?

One of the Javascript functions I designed is for validating file extensions before uploading: function validateFileExtension(field, extensions){ file_extension = field.val().split('.').pop().toLowerCase(); if ($.inArray(file_extension,exten ...