Tips on positioning the rotated div with an auto-fit margin at the top

I'm in the process of designing a receipt using HTML and PHP. While I've managed to create the correct layout, I'm facing an issue where I need to rotate my div by 90 degrees. However, when I do this, it seems to overflow to the top. To address this, I had to set margin-top:485px in the code below for the right side table to fit properly at the top.

<div class="rotate">  

I want to avoid fixing the margin as the content may fluctuate in length in the future.

MY CODE

.pagebreak {
  page-break-after: always;
  max-width: 8cm;
  word-wrap: break-word;
}

.rotate {
  -webkit-transform: rotate(-90deg) translate3d(0, 0, 0);
  -moz-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  -o-transform: rotate(-90deg);
  filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>


  <div class="pagebreak">
    <div class="rotate">
      <label class="font-weight-bold text-center">SOME TITLE</label>
      <table class="table">
        <thead class="thead">
          <tr colspan="3" class="">

          </tr>
        </thead>
        <tbody>
          <tr>
            <td class="text-nowrap">
              <div>
                <label class="font-weight-bold" style="font-size:24px;">Seat No :
                                    D6                                </label>
              </div>
              <div id="label0" class="font-weight-bold" style="display:inline-block;" title="2BDA5339-3DAC-48DD-C1C2-8AA7D327A666"><canvas width="75" height="75" style=&...
              [<script omitted>]
            </td>
            <td class="text-nowrap">
              <div><label class="font-weight-bold">Counter ID : PN001</label></div>
              <div><label class="font-weight-bold">Ticket ID : 7</label></div>
              ....
            
            </td>
            <td class="text-nowrap">
              ....
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</body>

</html>

Current output : The picture is cut in half

https://i.sstatic.net/49fjC.png

Expected output after rotating div:

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

Answer №1

.rotate-90-degrees {
    -webkit-transform: translateY(-100%) rotate(90deg); /* Safari */
    -moz-transform: translateY(-100%) rotate(90deg); /* Firefox 3.6 and above */
    /*-moz-transform-origin: right top; */
    -ms-transform: translateY(-100%) rotate(90deg); /* Internet Explorer 9 */
    -o-transform: translateY(-100%) rotate(90deg); /* Opera */
    transform: translateY(-100%) rotate(90deg); /* W3C standard */  
    -webkit-transform-origin: left bottom;
    -moz-transform-origin: left bottom;
    -ms-transform-origin: left bottom;
    -o-transform-origin: left bottom;
    transform-origin: left bottom;
}

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

Using MutationObserver in an iFrame with JavaScript

I currently have an iframe that is loaded with the source www.abc/main.html <iframe id="my-iframe" src="http://www.abc/main.html"></iframe> The main.html file from abc imports and runs some JavaScript files. My goal is to utilize a MutationO ...

Enhance iframe with hover effect

I'm currently working on a unique WordPress blog design where images and iframes (YouTube) transition from monotone to color upon hover. So far, I've successfully implemented the grayscale effect for images: img { -webkit-filter: grayscale(100% ...

Trouble with retrieving array values

After pasting an URL into an input field, I am trying to fetch details from the URL. However, I am facing issues with assigning these fetched values to another input field. You can check out the link here <form action="" method="POST"> <inpu ...

How to insert data into a MySQL database from a list using multiple submit buttons

I am faced with a challenge involving an HTML table with PHP loop and hidden fields. When a user selects an item from the list and clicks on the submit button, I want that specific item's data to be inserted into a database. However, the issue arises ...

Using Jinja to convert chat.js charts into images during template rendering

Before diving into my project, I have a question regarding the integration of JavaScript in Jinja2. This is crucial for me to determine if Jinja is the most suitable solution for my needs. One of my goals is to create an HTML email template that popul ...

Leveraging the power of React in conjunction with an HTML template

After purchasing an HTML template from theme forest, I am now looking to incorporate React into it. While I find implementing Angular easy, I would like to expand my skills and learn how to use React with this template. Can anyone provide guidance on how ...

An inclusive CSS-compatible calendar control for ASP.NET

I am currently using the Calendar control provided by .NET but I have encountered issues with how it renders HTML in certain situations. Unfortunately, this is hard-coded and cannot be changed. It seems that the Calendar control has not been updated in .NE ...

Utilizing Cookies in PHP to keep track of site visits

I'm a newbie to PHP and struggling with using Cookies! My goal is to create a cookie that tracks the number of times a page is loaded within a one-minute lifetime. Once the minute is up, the cookie should be unset and the counter reset to 0. Here&apo ...

What do you call this technique, and how can I replicate it? (Adjusting text)

Have you noticed the cool feature on ? It automatically changes the text midway through the page (Sketch is made for insert changing text here like you) after some time. I'm curious about how they achieved that and what it's called. I'm att ...

When I try to scroll on my mobile device, the element is forced to reload

My donate page has a header with a generic placeholder image. On mobile devices like iPhones and Androids, the page initially looks great. However, when I scroll down and then back up, the header disappears for a moment before reappearing as originally ren ...

Using Nginx to run both PHP and Node.js, with PHP files using the .php extension and Node.js files using the .html extension

Hello, I am trying to configure my server to handle PHP files and HTML files on the same server. Specifically, I want HTML files to be handled by Node.js on port 8080, while PHP files are handled by the PHP5 service. Here is the Nginx configuration I have ...

An SVG with a single enigmatic path/shape featuring a perplexing left margin or empty space. Not contained within an

I created a unique shape in Illustrator and adjusted the artboard to fit the shape perfectly, eliminating any excess white space. I double-checked this process to ensure accuracy. Upon opening the design in Chrome and inspecting it, I noticed that when ho ...

What is the best way to align an image and text in a grid?

As a novice in the world of HTML and CSS, I am attempting to master the 1fr 1fr grid layout for my "welcome" section. My goal is to have an image on the left side and text on the right side. However, when I switch to Responsive mode in Inspect, my grid col ...

`Unable to automatically redirect to new pages on the website`

After transitioning my website from plain HTML to WordPress, I encountered an issue with old links still using the .html extension. To address this problem, I decided to upload all the old HTML files to the new server and create redirects by removing the ...

Are spans not compatible with select options in HTML?

I have a dilemma with displaying options for products in a select dropdown. Here is the HTML code I am working with: <div class="form-group"> <label for="optSel">Select Option:</label> <select class="form-control" id="optSel"> ...

The styled-components seem to be having trouble injecting the necessary CSS to handle all the various props

I am curious to understand the potential reasons for styled-components not injecting all the necessary CSS into a page's header. In an existing project, I have defined a simple button like this: const Button = styled.button` background-color: ...

Reducing the size of header logo when scrolling on mobile devices

Struggling to find a solution for implementing a sticky header on our mobile Shopify site that shrinks the header logo when scrolling down and returns it to its original size at the top. If this also reduces the entire header size, that would be fine! Pre ...

Use script to reset the value of children

I attempted to reset the children of testId, but unfortunately, it did not successfully reset. <div id="testId"> <input type="text" /> <div> <input type="text" /> </div> <select> <o ...

What is the best way to create a sign-up box that appears on the same page when you click on the sign-up button

I am interested in implementing a 'sign up' box overlay at the center of my index page for new users who do not have an account. I would like them to be able to easily sign up by clicking on the 'sign up' button. Once they complete the ...