Utilizing the transform: origin property to perfectly align an element

I've tilted a basic paragraph and I'm attempting to position it on the left side of the browser at 0% from the top of the browser at 50%.

http://example.com

p {
    position: fixed;
    -webkit-transform-origin: left center;
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);

}

My initial idea was to use top: 50% and left: 50%, but the rotation completely distorts those properties.

I attempted to understand these resources, but I'm feeling perplexed.

Answer №1

When using the <code>transform-origin
property, you're essentially determining the point where the element is anchored for transformations. For example, if you specify left center, it will anchor the element in the vertical middle and at the left side. This means that when you apply a transformation, such as rotation, part of the element may be hidden due to its positioning.

To achieve the desired effect of dropping the element from the top and left, you can first rotate it and then use the translate function to slide it back into view. http://jsfiddle.net/fyYS7/2/

p {
    position: fixed;
    top: 0;
    left: 0;
    transform-origin: top left;
    transform: rotate(-90deg) translateX(-100%);
}

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 best way to arrange two divs inside a main div so they remain fixed in place at all times?

Struggling with aligning two smaller divs within a main wrapper for my website. Despite confining them to the main div, they don't stay fixed or aligned properly. How can this issue persist even when contained within a main div? I've attempted s ...

Issues arise when the elements <html> and <body> fail to adhere to a 100

Lately, I've been struggling with various problems related to heights. I was able to resolve the height issues of certain elements using flex:auto and flex-shrink:0. However, I'm facing difficulties getting the HTML and Body tags to cooperate ( ...

"Tagging multiple content snippets within a label element to create a truncated text

How can I truncate a specific inner span of a label, containing multiple span elements, to prevent overflow into the next line? To address this issue, I have created a JSFiddle available at https://jsfiddle.net/keltik/k18892xe/3/. Here is a snippet of the ...

Tips for creating a gradual fade-out effect on a bootstrap modal window

One issue I'm facing is with my modal dialog (#busyIndicator). It simply displays a message that reads "Please Wait". Sometimes, the operation it's tied to completes so quickly that the visual transition between showing and hiding the dialog beco ...

Is the hover rotation feature not functioning properly?

I am trying to achieve a small rotation effect when I hover over my div. It works perfectly on another div, but for some reason it's not working on this one. Below is the code snippet: .more, .more:visited { color: #fff; min-width: 88px; heigh ...

Changing the size of the logo as you scroll through the page

I have implemented the following code to resize the logo as I scroll down the page. $(document).on('scroll', function() { if ($(document).scrollTop() >= 10) { $('.logo img').css('width', '50px'); } else ...

Save information in a session using html and javascript

I'm having trouble accessing a session variable in my javascript code. I attempted to retrieve it directly but ran into issues. As an alternative, I tried storing the value in a hidden HTML input element, but I am unsure of how to properly do that wit ...

Resetting form fields when clicking the "Next" button with the FormToWizard jQuery Plugin

I am in the process of developing a lengthy form using the jQuery plugin called formToWizard. Within one of the fieldsets located midway through the form, there are hidden fields that are displayed upon clicking a button. The strange issue I am encounterin ...

CSS-only: Align items in flexbox column with equal width and centered position, without the need for a wrapper

https://i.stack.imgur.com/vAJv2.png This particular challenge involves creating a responsive mobile menu. In this design, the width of all children is determined by the longest child element. The CSS should ensure that the .index class spans the full wi ...

Submitting forms with Ajax in IE(8)

Sample Google form Related spreadsheet I modified the original code to create two custom forms: First created form Second created form Both forms are functional on most browsers except for IE(8). Any idea why? First form: <!DOCTYPE html> <h ...

Tips on obtaining the element selector when a div is being dynamically loaded during an AJAX call

When running two ajax calls, I encounter an issue where the second call loads some HTML onto the page that is needed for processing a specific div in the first call. However, since the div is not present until after the second call is completed, I receiv ...

Add the file to the current directory

As a newer Angular developer, I am embarking on the task of creating a web page that enables users to upload files, with the intention of storing them in a specific folder within the working directory. The current location of the upload page component is ...

How can I use JavaScript to create a drop-down menu that only appears after selecting the previous one?

<div class="row"> <div class="col-md-4"> <label for="selectCustomers">Customer Select</label> <select class="form-control pointer" name="tableCustomers" id=" ...

Structured chat interface with unchanging top and bottom sections

I'm currently trying to come up with a way to structure my chatbox so that it has a fixed header at the top and a fixed footer at the bottom, while allowing the chatbox body to scroll within those constraints. I've experimented with various appro ...

Utilizing data attributes and JavaScript to dynamically assign a class to carousel navigation items

Hello there! I recently created a carousel and carousel navigation system using Bootstrap. I am now trying to figure out how to detect the value of 'data-slide-to' and then apply a specific style to the corresponding navigation item based on that ...

How to Overlay a Semi-Transparent Object on a Background Video using CSS and HTML

Hey there, I'm encountering a puzzling issue with my website. I have a background video set up, and I wanted to overlay a floating textbox on top of it. However, no matter what I do, the background color and borders of the textbox seem to be hiding be ...

What is the best method for retrieving text from elements designated by class?

I am currently using BeautifulSoup to scrape data from a website, but I am facing an issue with extracting only the text I need. The specific part of the website data that I want to grab is: <div content-43 class="item-name">This is the te ...

"Adjusting the height of a div element while considering the

I have 2 elements with different heights and I want to make them equal: var highestEl = $('#secondElement').height(); $('.element').first().height(highestEl); I understand that the second element is always taller than the first one. W ...

Why Chrome Doesn't Alter the State of li Elements

I'm unsure why, but the CSS code in this particular fiddle fails to function correctly on Chrome. On Firefox, when hovering over one of the li elements, the text becomes visible as expected, whereas this does not occur on Chrome. It seems that changin ...

Generate a custom comment page for every URL identifier

I am currently working on creating a PHP comment page that displays unique comments for each specific URL ID. However, I have encountered an issue where the comment page is shared among all URLs. I understand that I need to add the URL ID (bug ID) to the M ...