The alignment of the element is not in the proper position

After attempting to rotate elements with varying widths, I noticed that two elements were not in their proper places after being rotated and stacked. Even when I tried adjusting the CSS positioning of the elements based on their placement post-rotation, they still ended up stacked inaccurately.

https://i.sstatic.net/OkPki.png

.drop{
      border: 1px solid gray;
      width:50px;
      height:200px;
      margin:50px;
    }
.drop div{
      transform:rotate(90deg);
      margin:0 auto;
      padding:0 auto;
    }

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/> <div class="drop"> <div class="box1 bg-warning" style="width:50px;height:50px;"></div> <div class="box2 bg-dark" style="width:75px;height:50px"></div> <div class="box3 bg-danger" style="width:100px;height:50px"></div></div>

https://i.sstatic.net/rq15J.png

I aimed for a specific outcome where, despite rearranging the elements, the display remained organized.

Answer №1

The default rotation of div elements is centered, but you can change this using the transform-origin property.

If you want to rotate them from the top left corner, use transform-origin: left bottom

.drop{
      border: 1px solid gray;
      width:50px;
      height:200px;
      margin:50px;
    }
.drop div{
      transform:rotate(90deg);
      transform-origin: left bottom;
      margin:0 auto;
      padding:0 auto;
    }
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="11737e7e65626563706151243f233f23">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="drop">
      <div class="box1 bg-warning" style="width:50px;height:50px;"></div>
      <div class="box2 bg-dark" style="width:75px;height:50px"></div>
      <div class="box3 bg-danger" style="width:100px;height:50px"></div>
</div>

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

Tips for displaying average progress using a progress bar

I'm in the process of creating a website and I would like to incorporate a progress bar that reflects the average of all the input numbers obtained from an HTML form. Although I have some experience with JavaScript, I am currently in need of the Java ...

What is the best way to divide a bootstrap card into two columns?

Currently, in my Angular 9 application, I have a component that utilizes Bootstrap cards. My objective is to create the following layout within this component: For the desktop view, the layout should resemble the image below: https://i.sstatic.net/3MGKm. ...

How can I expand my Jquery slideshow to occupy the entire screen?

I am working on stretching my JQuery slideshow to fit the entire browser, but I am running into some difficulty. I have downloaded the jQuery Vegas plugin, but I can't seem to figure out what the problem is. I would like my slideshow to resemble the o ...

The bottom border of the check boxes is not displaying in Internet Explorer

https://i.stack.imgur.com/EAkMC.pnghttps://i.stack.imgur.com/ysU1R.png While the checkboxes function correctly in Chrome, they are experiencing issues in Internet Explorer. Below is the HTML code being used: <div class="patient-div-w" style="width: 9 ...

Personalize the file button for uploading images

I have a button to upload image files and I want to customize it to allow for uploading more than one image file. What is the logic to achieve this? <input type="file" />, which renders a choose button with text that says `no files chosen` in the sa ...

Syntax errors within the Twitter Bootstrap framework

I successfully integrated Twitter Bootstrap into my Asp.net MVC 3 application. However, upon reviewing the bootstrap.css file, I noticed several syntax errors as shown below. I am utilizing Visual Studio 2010 with CSS 3 support. List of Errors 1: List o ...

Tips for monitoring input content "live"

Currently, I am in the process of developing a web form that includes a text field intended to receive numeric values. If the user enters non-numeric characters into this field, the form will not submit. However, there is no error message displayed to noti ...

Implementing CSS to Style Images in JavaFX FXML

After creating the FXML structure below, I attempted to define a border in CSS for the Image by using code in the customerform.css file: <VBox id="customerFormPane" styleClass="customerForm" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.exampl ...

Issues with the functionality of CSS Modules and hover styles_integration

After creating a react web-app with a custom build - including webpack, webpack-server, typescript, image-loaders, css, scss, and css-modules - I encountered an issue with CSS pseudo elements. The hover effect is not working as expected. .image { height ...

I'm struggling to understand why the background-color is affecting the margins as well

Check out this code snippet: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <style type="text/css"> * {border: 0px; padding: 0px;} ...

Column div being obscured by footer

My footer is causing overlap issues with the div above it on my mobile website. Here's a visual representation: Current view on my phone: https://i.stack.imgur.com/RpvWM.png Desired view: https://i.stack.imgur.com/KHVcm.png The code for the are ...

Mobile navigation menu options on the left and right sides

I've encountered an issue with my mobile navigation. I have two navigation menus - one on the left and one on the right, designed to slide out when triggered. The left menu functions correctly with a smooth transition, but the right menu abruptly pops ...

Creating a unique dimming effect for modals in a React application

Could someone assist me in adding opacity or dimming the background while a modal is open using the code provided? You can view the working example here. ...

Aligning image vertically

I'm working on aligning an image vertically in my header. Currently, it's horizontally centered. header { background-color: blue; height: 118px; width: 1024px; text-align: center; } .container { margin-left: auto; margin-right: aut ...

Ensure the footer remains at the bottom of the page without utilizing a minimum height of 100

When trying to address the common issue of making the footer stay at the bottom of a page, one popular solution is to enclose everything in a div with position:relative and min-height:100%, as explained in this helpful tutorial here. The challenge arises ...

"Using jQuery to dynamically add and remove classes upon a click event on form labels

I am trying to implement a simple addClass and removeClass function that should execute on click. Here is the code snippet: $('#filter').click(function() { $(this).closest('fieldset').find('.selectedfilter').removeClass(&apos ...

The data labels in the main chart of a Highcharts column with drilldown appear blurry, with the exception of the columns that have been drilled

When setting up a Column Chart with Drilldown: The main chart displayed data labels in a blurred black color. However, when clicked, the next columns that appear (the drilled down columns) are clear and easy to read (white color, no blur). I discovered a ...

Using attribute value for CSS background-image styling is a handy technique to

In my current situation, the design calls for the use of two different images as background images - one for desktop and another for mobile. These images are uploaded through a CMS, allowing me to retrieve the URLs for both using PHP. Is there a way to pa ...

Enable the choice for Bootstrap collapse animation to be customized

Is there a way to allow users or admins on my website to decide whether or not Bootstrap 4 collapse elements should be animated? The concern is that when many elements are moved by the animation, it becomes less smooth. Therefore, it would be ideal to give ...

What is the best way to create a smooth sliding effect using CSS?

Need help with creating a transition effect within a bordered div that reveals hidden content when a button is clicked? I'm looking to have the <a> tag displayed after clicking the button, with both the button and text sliding to the left. Here& ...