Are the horizontal divisions colliding with one another?

I am facing an issue with two divs on my webpage. The first div is a header containing a logo image and a search input field. The second div is meant for displaying navigation links in a horizontal row.

The problem I'm encountering is that the second div overlaps with the first div, taking up all the space between the logo image and the search box.

Below are the HTML codes for the two divs:

<div id="container">
    <div id="logo">
        <img src="HeaderLogo.jpg" alt="logo">
    </div>
    <div id="searchboxcontainer">
        <form action="search.php" method="post">
            <input type="text" name="searchterm" id="searchbox" />
            <input type="submit" name="search" value="Search" id="searchsubmit" />
        </form>
    </div>
</div>

<div id="navbar">   
</div>

Here is the CSS code being used:

#logo {
    width:30%;
    float:left;
    margin-left:50px;   
} 

#searchboxcontainer {
    background-color:#A3E0FF;
    width:30%;
    float:right;
    margin-right:50px;
    margin-top:60px;
    padding:15px;
}

#searchsubmit {
    background-color:#19A3D1;
}

#navbar {
    width:100%;
    background-color:#CACABC;
    height:60px;
}

Answer №1

Adding #navbar{clear:both } could potentially resolve the issue you are facing

On a side note, if you want the parent element #container to encompass the height of floated elements, you can try using #container{overflow:auto;}

For the full code example, please refer to this link http://jsfiddle.net/2Mh9y/

I hope this information proves helpful!

Answer №2

Take a look at this fiddle, I've included:

border-box and overflow auto

I removed some margins and added some padding. Let me know if this is what you were looking for: http://jsfiddle.net/WSaj8/12/

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

Updating a "total" textbox using jQuery with values from another textbox and radio buttons

I am facing challenges trying to make a simple piece of jQuery/JavaScript work. I have a textbox and 2 radio buttons that I want to automatically update the 'total' textbox when a user changes their values: <tr> <td>Value:</td&g ...

The footer refuses to stay positioned at the bottom of the page

Can you help me locate the CSS style for the footer? #footer { background-color: #000; bottom: 0px; color: #fff; clear: both; text-align: center; padding: 5px; } What is the best way to ensure the footer is positioned at the bottom of ...

Undo a CSS transition when clicked

There is a div named learn-more which expands to fill the whole page when a CSS class is added like this: .learn-more{ padding:10px; font-size: 20px; text-align: center; margin-top:20px; font-family: klight; -webkit-transition:2s; ...

Is drag and drop functionality in Safari on iOS automatically enabled, or will I need to write code to implement it myself?

Is there a way to detect when an HTML element is being dragged and dropped specifically for Safari events? For drag and drop functionality on Safari iPad, do I need to manually detect mousemove events on HTML elements and update their positions as the mou ...

Child div within a parent div with absolute positioning does not extend to the full height of the webpage

I am currently facing an issue with a bug in my project that I am working on. The mobile menu is not taking the full height of the viewport when the screen size is less than 768px, even though it has been set to 100%. It only becomes visible when toggled ...

Is it feasible to preserve the HTML form content data even after refreshing the page?

Can someone offer a suggestion that doesn't involve using Ajax? I'm wondering if there is a way to achieve this using JavaScript/jQuery or some other method. Here's my issue: When submitting a page, the action class redirects back to the sa ...

Utilizing PHP and JQuery Variables within the CodeIgniter Framework

Can someone please provide guidance on the best approach to handle this particular situation? I currently have a sidebar populated with Li Elements using a foreach loop, which is working perfectly. Each element contains a link that, when clicked, trigger ...

Are there any similar tools to Graphstream in Java that can be used with HTML5 using canvas and JavaScript?

GraphStream is a revolutionary graph library created in Java that offers Java developers a simple way to visually represent dynamic graphs either in memory, on screen, or in files. Check out this demo video. With GraphStream, you can effectively handle th ...

How come I'm unable to showcase the inventory of items to the customer even though they are saved in the database and visible in the Network tab on the console?

Basically, my goal is to showcase products on the client side. I am using Angular 12 with .NET 5 for the backend. Although I am fetching products from the product's controller, they are not visible to me. However, I can see the "welcome" title and I k ...

HTML code containing a dropdown menu with selectable options pulled from a Django framework

Here is the HTML code snippet I am working with: <select name="txn" tabindex="3" id="txn" class="fixed" onfocus="highlightInput(this.id)" onblur="unhighlightInput(this.id)"> <option value="RR" my="{{txn|genselected:"RR"|safe}>RR</option ...

JavaScript library for creating animated car movements on a map using JPG images

Looking for a way to animate a car's movement on a map? I have a map image in jpg format (not svg) and a sequence of (x,y) points ready to go! If you could recommend a JavaScript library that can help me easily create an HTML page with this animation ...

Error in onchange event due to incorrect index variable

My goal is to add onchange events to select tags within a div that contains multiple tags. To achieve this, I am using a for loop to attach events to each tag. The purpose of these events is to update a select tag in another container by removing the "disa ...

How can I retrieve the value from an input form using jQuery if it returns null?

Despite trying various methods, I have been unsuccessful in retrieving form values using jQuery and sending them in an AJAX GET request. The value keeps showing as null even after spending more than 18 hours on it. Any help would be greatly appreciated. $ ...

`Is it possible to interpret HTML using AutoHotkey?`

I am struggling with the parsing of HTML files. The examples I have come across are quite complex for a beginner like me, making it difficult to understand. Although I've tried reading the GetNestedTag manual, I believe there might be a simpler soluti ...

Changing the style.backgroundImage property overrides any image transition effects

I am currently working on creating a button for a player. You can check out the video (here) The button works, but in order to give it a "pressed" effect, I have to change its background-image on click. However, this action seems to override the transitio ...

"Modify the MySQL database each time a user changes the value in a

As a student, I am looking to update value(s) whenever a student changes the value(s) in the correction or update form. So far, I have been able to retrieve and display values in text boxes based on the name selected from a dropdown list from the database ...

Tips for vertically aligning values in a Bootstrap table

Currently, I am working on generating reports for an NGO that conducts surveys in schools. Once the reports are created, they need to be sent out in a specific format. While a simple table structure would suffice, I have decided to use Bootstrap classes to ...

Isotope grid shatters when browser window is resized

My goal is to design a 3-column grid using Twitter Bootstrap and Isotope. However, when I resize the browser to force the layout into a single column mode, Isotope fails and leaves large spaces both vertically and horizontally. Regular Layout Issues in ...

Error loading Google Maps in Bootstrap 3.0 modal due to incomplete loading

Embedding the jQuery location picker into the content box of a Bootstrap modal 3 can be done like this: HTML: <a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a> <div class="modal" id="myModal"> ...

Struggles with Aligning CSS Layout

I'm encountering some challenges with the layout of my webpage, particularly with alignment. Here are the issues I'm facing: The login section doesn't fit well in the header and lacks proper alignment. I aim to replicate the design from ...