Positioning additional elements underneath the two div elements that were previously aligned next to each other

Here is the code I attempted:

#tools
{
    float:left;
}
#sketch 
{
    border: 10px solid grey;
    float:left;
    width: 700px;
    height: 500px;
    position: relative;
}

This is the HTML code snippet:

<div id="tools">
    <p>These are my tools</p>
</div>
<div id="sketch">
    <p>This is my sketch</p>
</div>
<button type="button">Click</button>

I have positioned the two divs side by side, however, the button is displaying next to the divs. I want the button to appear below the divs.

Access the Fiddle here

Answer №1

Remove the float:

button { clear: both; }

Answer №2

To maintain layout integrity, insert a wrapper with a clearfix:

<div class="wrapper cf">
<div id="tools">
<p>These are my tools</p>
</div>
<div id="sketch">
<p>This is my sketch</p>
</div>
</div>
<button type="button" >Click</button>

http://jsfiddle.net/brutusmaximus/5KmK6/3/

Answer №4

There are a couple of options you can use:

1) Apply the following CSS to the button element: clear : both;

2) To clear the float added, you can add a class called "clearfix" to the Div with the ID "sketch". This will add a pseudo element to the DOM after it.

  <div id="sketch" class="clearfix">
          <p>This is my sketch</p>
   </div>
  .clearfix:after {
     visibility: hidden;
     display: block;
     font-size: 0;
     content: " ";
     clear: both;
     height: 0;
   }

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

The browser is lagging behind a few frames when repainting on high-resolution displays

Currently, I'm working on a website that features an infinite grid. Users have the ability to navigate through the grid by simply holding down the right click on their mouse and moving it around. The technical details: To achieve this functionality, ...

Unable to dispatch the form on a connected page using jQuery Mobile

I have encountered an issue while trying to submit a form using jQuery Mobile. The problem arises when the form is placed on a linked page, as it fails to submit properly. To illustrate, if my home page is mysite.com/page.html, placing the form code on tha ...

I am looking to adjust the width of an element within an Iframe

In my single post, I have a social sidebar on the left side. Currently, the buttons in the sidebar are appearing in different sizes, but I want them all to be the same size as the "Twitter" button. To see the issue, please visit this link. I've tried ...

Can anyone help me identify the issues in my PHP code?

My PHP code doesn't appear to be functioning correctly. Instead of displaying any errors, it simply shows a blank page. Can you identify what I might be doing incorrectly? <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_ ...

Transforming an HTML file into a Vue.js component

I'm working on a login.vue file and I need to incorporate styling along with the necessary js and css files. Unfortunately, I'm clueless about how to achieve this within the login.vue file. Below is a snippet from the html file: <!DOCTYPE ht ...

How to use image source and mouse hover effects in CSS3

Can we create a CSS3 class for the src, onmouseout, and onmousehover properties? <img src="http://www.example.com//images/pic.png" onmouseout="this.src = 'http://www.example.com/images/pic.png'" onmouseover="this.src = 'http://www.examp ...

Update links within a designated div section

How can I change the color and alignment of anchor tags within the third child div that is part of a set of three nested divs? These child divs are arranged side by side within a parent div with the class .logo-bckgrnd-rpt. Although I have successfully tar ...

How to easily center text across multiple lines using CSS

Looking for a way to center text horizontally and vertically within a div? I had it all working perfectly with this code snippet from a Stack Overflow post: text-align: center; vertical-align: middle; line-height: 90px; /* set line height to match you ...

Is it possible for me to enlarge the image within the iframe?

Can someone please explain how to zoom an image within an iframe? For instance, I would like to be able to view the image at 50% zoom, 75% zoom, and 100% zoom. Is this achievable? Thank you in advance for your assistance. ...

Steps for arranging text in a dropdown list option

How can I format 3 words in a dropdownlist option so they are aligned properly? eg. <option value="1">ABCDE - ALPHA</option <option value="2">1234 - NUMERIC</option> <option value="3">ABC123 - ALPHANUMERIC</option> I woul ...

Tips for maintaining aspect ratio when embedding Vimeo videos in HTML?

My goal is to maintain a 16:9 aspect ratio for my videos, but some of them are not 1920x1080. Specifically, two of them have resolutions of 1920 x 1012 and 1000 x 416. When I attempt to embed these videos in an HTML file, they end up distorted with eithe ...

Tips for ensuring that jQuery is the first script to load in the header of a WordPress website

My website and plugins are inserting some jQuery code between the HTML tags, along with a jQuery dependent plugin as the first script tag. No matter what I do to insert jQuery as the first script in the head section, it doesn't seem to work. I have a ...

Add a button at the base of a row within Bootstrap

I've been struggling to position a button at the bottom of the column, but so far, I haven't had any luck. After reading this post, I added the CSS classes d-flex, flex-column, and mt-auto, but they don't seem to be working as expected. Can ...

How to trigger a hover effect on a div and its child simultaneously using HTML and jQuery

Here's my concept: I want the text to be contained within div elements with an integrated image, rather than just having fading in and out pictures. Here's my attempt: #first{ position: absolute; } #second{ position: absolute; -we ...

How do I change the 'CSS Theme' of my website?

With Halloween approaching, I am eager to transform my website's BODY css into a spooky Halloween theme. The challenge is that my .Net pages are Templates. Is there a way for me to ensure that the body class checks for an existing CSS theme override? ...

Looking to update properties for elements within the Angular Material 16 mat-menu across the board?

Currently working with Angular Material 16 and I have a question regarding the height of buttons inside the mat-menu element. Here is an example of the code: <button mat-icon-button> <mat-icon>more_vert</mat-icon> </button> ...

Activate a CSS button upon clicking and update the content within the div

In order to achieve the desired result of having menu CSS buttons change the content of a div when clicked, I have managed to do that successfully. However, a problem arises when clicking on the 2nd or 3rd button/link - it changes the div content, but as s ...

Guide on excluding certain words within a paragraph using PHP

In my database, there is a paragraph that looks like this: $str ="this is a paragraph i show shortly and when i click on the view more it will show completely for that i am using the ajax and retrieve it " I display it as follows: this is a paragrap ...

Tips for centering heading <h1> on the webpage

I am trying to align either <h1> or <div class="heading"> in the center of my webpage. The method I have attempted involves body { text-align: center; } However, I am puzzled as to why this approach is not yielding the desired result. I utili ...

How to use CSS to make a child element's width automatically fill the width of its

Is there a way to make the child div info fill the parent div video-featured width while remaining absolute, allowing it to overlap the parent div without using a fixed width? <div class="video-featured col-md-4"> <div class="video"> < ...