Two adjacent divs styled with CSS one on top of the other

I'm attempting to align two divs to float right next to each other, as illustrated below:

__________
|.menutop|
|        |
----------
|.menu   |
|        |
----------

How can I achieve this effect? Here's what I've tried so far:

.menutop{
position: absolute;
width:7%;
height:30px;
float:left;
margin-top:97px;

}
.menu{ 
position:relative;
width:7%; 
height:auto; 
float:left;
margin-top:107px;
}

However, the above code results in .menu overlapping with .menutop.

Answer №1

To display them side by side, you can place them in a container and make it float:

<div class="itemContainer" style="float: left">
   <div class="topItem"></div>
   <div class="bottomItem"></div>
</div>

Answer №2

.menutop
{
  width:7%;
  height:30px;
  float:left;
  margin-top:97px;
}


.menu
{ 
  clear: left;
  width:7%; 
  height:auto; 
  float:left;
  margin-top:107px;
}

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 is the method for showcasing background images sequentially?

css code #intro { position: relative; background-attachment: fixed; background-repeat: no-repeat; background-position: center top; -webkit-background-size: cover; -moz-background-size: cover; backgr ...

What is the best method for embedding Microdata or JSON-LD for an ebook in SVG image format within an HTML5 document?

Recently, I came across Schema.org and am interested in implementing it on my webpages. However, due to time constraints, I haven't been able to delve deep into understanding it fully yet. The issue at hand involves converting a 670-page PDF book wit ...

Encountering a problem while attempting to loop through div content upwards in jQuery, specifically when displaying the latest news

Hey there, I'm fairly new to JQuery and I am working on dynamically appending content to a div. I need to continuously scroll the content of that div to the top. After some research, I found a solution that meets my requirements. Here's a snippe ...

Hexa-Responsive Menu - A Unique Approach

Currently, I am working on developing a Hexagon menu specifically for mobile applications. My latest progress can be viewed at JSFiddle. The main challenges that I am encountering are: Ensuring that the Hexagon menu remains responsive and always stays c ...

Preserve HTML client control values during page reloads

Is there a more efficient way to retain client-side HTML controls on postback? I've attempted using enableviewstate="true", but it didn't work. My current workaround involves creating a server-side function that resets all posted values using Cli ...

3D Carousel with Dynamic CSS, Perfect for Z-Axis Positioning

I am currently working on creating a 3D carousel using CSS and javascript. To view what I have accomplished so far, you can visit this page: Upon arriving at the page, please click the "initialize" button to transform the carousel into 3D space. By defaul ...

Apache Tomcat is informing you that the resource you are trying to access is currently unavailable. This error message occurs when attempting to access a resource that

This is my first time asking a question here (please be kind :)). I've searched high and low for the solution to my issue (and maybe lost my mind a little along the way). Currently, I am working with Tomcat 7 and the latest Eclipse IDE for Java EE de ...

Troubleshooting problem with CSS aligning <dl> and <dd> tags

Utilizing <dt> and <dd> typically assumes a single line definition for dd. However, in my scenario, I have multiple entries for the definition that I need to correctly display (the exact method will be clarified after reviewing the attached ima ...

Building a fluid two-column layout in CSS: Ensuring that the left column expands or shrinks based on

After conducting a thorough search, I haven't found an exact solution to my problem. My goal is to create Two Columns: Left fluid + Right fluid. The width of the left column should be dependent on the right column's width, with the left colum ...

Implement a slideshow feature that automatically changes a CSS attribute when preview images are shown

(Apologies for the perplexing title) My intention was to create a slideshow gallery, and I stumbled upon an example here: https://www.w3schools.com/howto/howto_js_slideshow_gallery.asp In this setup, you'll notice previews of images in a small bar b ...

Conceal the Navigation Bar Upon the Pop Up's Appearance

I Designed a Landing Page with a Fixed Mobile Nav Bar at the Bottom. There is also a Pop-Up Form that appears when clicked. How can I make sure the Nav Bar is closed when the form pops up? This issue is blocking the Send Button. Is it possible to achiev ...

End of container Bootstrap 4 row with two columns at the edge

I'm currently working on an angular project with bootstrap 4. Within the container, there are two rows. I specifically want one row to always be positioned at the bottom of the container. Despite trying methods like justify-content: flex-end;, botto ...

Arranging items in a semi-circular formation around the color Blue in a precise manner

I have a character named Blue (who is blue) and I would like to place some elements in a half-circle around him. Each element will consist of an image and a text span positioned below the image. My current attempt results in the elements rotating incorre ...

Tips on concealing Bootstrap 5 modal through button press

I've created a Bootstrap 5 modal that allows users to download a file by clicking a button. Everything works as expected, but I'm facing an issue with hiding the modal after the download button is clicked. I've been trying to use jQuery to ...

Display an image in response to a button click using JavaScript

I am currently working on a feature that will display information when a radio button is pressed. I also want to include an image, but I am facing an issue where the text displays correctly but the image does not appear. What steps should I take to resolve ...

The issue with the data backdrop not functioning properly in Angular 6 is ongoing and

My issue lies with the data-backdrop attribute in my Bootstrap 4 modal. It does not function as expected. The intended behavior is for the modal to close when clicked outside of it, but this is not happening. I am using Angular 6: I have attempted setting ...

Having trouble getting an HTML form with PHP to successfully save data into a MySQL database server

https://i.sstatic.net/lLH0V.jpg I'm currently working on a code snippet that generates a <textarea> for user input. However, I seem to be encountering an issue where the code only outputs "please include some content", even when there is text i ...

Custom pagination page size in AngularJS trNgGrid

I have been working on developing an Angular table using trNgGrid. It's functioning fine, but I am looking to incorporate custom pagination where the user can choose the number of page items to display per page. I checked out the TrNgGrid Global Opti ...

Styling with CSS: Utilizing the Float Left Property to Anchor Elements

Currently, I have implemented an anchor element that utilizes a CSS class to replace the text with an image. Despite its unusual nature, the end result is mostly satisfactory. .toolLink a { overflow:hidden; } .toolEdit { float:left; ba ...

Enhance your image viewing experience with a React component that smoothly zooms in on images without distorting their dimensions, all with

After searching extensively for a solution, I have been unable to find one that works. My current setup involves using React with Bootstrap. I am in need of a stateless functional component that can take an image path as input and return an img element. Th ...