Surround Content with Rotated Container

I'm trying to achieve a unique layout where the heading is rotated with CSS transform rotation, and I want the body text to flow around the rotated text.

The issue I'm facing is that when I apply float: left to the heading, the text wraps around the unrotated heading first before it actually rotates, causing overlap in the text.

Currently, here is an example of how my system is set up:

<html>
    <h1 style="transform: rotate(-60deg); float:left">
        Test Heading
    </h1>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris diam metus, mollis eu purus vitae, semper fermentum nunc. Phasellus nec iaculis sem, in imperdiet eros. Maecenas ligula nibh, elementum in felis eget, vehicula faucibus nibh. Morbi rhoncus vehicula feugiat. Pellentesque vitae lobortis arcu. Nullam vel mi elementum mi feugiat vehicula. Cras tincidunt purus dolor, eleifend aliquet velit ornare tristique. Maecenas lobortis tristique est, sed facilisis lectus pulvinar vestibulum. Nunc tristique tellus non facilisis elementum. Nam lobortis in velit non tempus. Phasellus lobortis vel neque non iaculis. Praesent tristique risus a gravida imperdiet. Quisque fringilla, massa quis placerat congue, nulla velit varius nisi, vel fermentum tortor velit ut nibh.
    </p>
</html>

Here is a goal behavior screenshot for reference: https://i.sstatic.net/O9yR8.png

Answer №1

If you want to enhance the appearance of the <h1> tag, consider adding some margin.

Here's an example:

<html>
<h1 style="transform: rotate(-60deg); float:left; margin:3em 2em;">
    Test Heading
</h1>
<p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit... (text truncated for brevity)
</p>

Answer №2

If you're looking to adjust the height, consider incorporating a :before element,

For more detailed examples, take a look at this resource -

Please review this code snippet below:

<html>
  <h1>
    Test Heading
  </h1>
  <p>
        Lorem ipsum dolor sit amet...
  </p>
</html>

h1 {
   display: inline-block;
   white-space: nowrap;
   transform: translate(0,90%) rotate(-60deg);
   transform-origin: 0 0;
   float: left;
}
h1:before {
   content: "";
   float: left;
   margin-top: 100%;
}

You can also view a live example here - http://jsfiddle.net/nudv9z43

Answer №3

Introducing a clever "hack" involving triangles that may be beneficial -

<html>
  <div class="wrap">
  <h1>
    Test Heading Y
  </h1>
  <div class="one"></div>
  <div class="two"></div>
  <div class="three"></div>
  <div class="four"></div>
  <div class="five"></div>
  <p>
        HLorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris diam metus, mollis eu purus vitae, semper fermentum nunc. Phasellus nec iaculis sem, in imperdiet eros. Maecenas ligula nibh, elementum in felis eget, vehicula faucibus nibh. Morbi rhoncus vehicula feugiat. Pellentesque vitae lobortis arcu... <a href="#" rel="nofollow noreferrer">Read More</a>
   </p>
  </div>
</html>

h1 {
   display: inline-block;
   white-space: nowrap;
   transform: translate(0,90%) rotate(-25deg);
   transform-origin: 0 0;
   position: absolute;
   left: 0;
   top: 22px;
}
.wrap {
  position: relative;
}
.wrap > div {
  height: 22px;
  float: left;
  width: 250px;
  clear: both;
}
.wrap .two {
  width: 200px;
}
.wrap .three {
  width: 150px;
}
.wrap .four {
  width: 100px;
}
.wrap .five {
  width: 50px;
}

http://jsfiddle.net/nudv9z43/20/

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 value does the "left" property default to?

When attempting to change the 'left: 0' property to 'left:none', I found that it did not work. Other properties such as margin and padding do work when overwritten. I aim to find a solution for this problem without altering the origina ...

How can I retrieve the URL for a specific location on Google Maps using latitude and longitude coordinates?

Is it possible to generate a URL using latitude and longitude coordinates that will take me directly to a Google Maps page showing that location? For instance, consider the following sample code: var lat = 43.23; var lng = 114.08; var url = 'http:/ ...

Working with CSS3 transitions in PHPStorm is a breeze

For some reason, my phpstorm does not provide code completion for CSS properties like -webkit-translate, translate, or animation. Has anyone encountered this issue before? Any suggestions on how to fix it? ...

jQuery UI Tabs - The initial slide is not being displayed automatically

My default setting for the first tab is .ui-tabs-hide, causing it to be hidden along with all other tabs. Here's my code snippet: <script> $(document).ready(function(){ $("#slide-container").tabs({ fx: { opacity: 'toggle' ...

What is the best way to create a close button using JavaScript?

I just started learning JavaScript and I want to figure out how to make the close button close the div .popup1 in the following code: https://jsfiddle.net/74hmx0vb/1 <div class='popup1' id="popup1"> <div class="containe ...

Dynamic JavaScript Banner Rotation

I am looking to create a dynamic rotating banner using Javascript for my website. The purpose of this banner is to display advertisements in the form of clickable images that change every 5 seconds. My ideal size for the banner is 728x90 pixels. I want t ...

Problematic Mouse Position Detection in FireFox

I'm encountering a problem with fetching mouse positions on the Firefox browser. It seems like there's an issue in my code causing it not to work correctly. Here is what I have done so far. Javascript Code: function GetMousePosition(event){ ...

Unable to view HTML without an internet connection

I have encountered an issue where my files work fine when uploaded to an online server, but do not work when accessed locally offline. An error message about a cross-origin issue appears. How can I solve this problem? Error message: Security Error: Conte ...

Tips for organizing the outcome of a seamless web scraping operation with Apify and Puppeteer

Extracting data from a table on the designated URL using Apify and Puppeteer is my current goal: https://en.wikipedia.org/wiki/List_of_hedge_funds The desired outcome should be an array of objects. Each element in the array must represent a <tr> ro ...

Tips for ensuring perfect alignment of all <TD> elements in a table

Is it possible to align table rows even if they have different content lengths? Take a look at the following fiddle: Here. Currently, the rows are vertically aligned, but I would like them to be aligned horizontally like the example below: One 1 Yes T ...

Struggling to align your image properly?

My attempt to center the image "Logo_Home.svg" on my page has failed, as it is currently positioned in the top left corner. Can anyone help me identify what I am doing wrong and guide me in the right direction? Thank you. EDIT 1 I realized that I forgot ...

How can I eliminate the gap above the footer in iframes alignment?

I have a setup with four iframes: header, menuframe, bodyframe, and footer. The menuframe and bodyframe are positioned next to each other with space between the footer and the menuframe/bodyframe. How can I remove this space? Here is the CSS: iframe{ ...

Using jQuery to iterate through an array and reverse its order

Is there a way to loop through an array and change the CSS background color chronologically rather than randomly? Additionally, is it possible to reverse through the same array when the back button is clicked? http://jsfiddle.net/qK2Dk/ $('#right&a ...

Update the parent node in the Google Org Chart

This is my first time working with Google Charts and I have a couple of questions: Is there a method in the API to update the parent of an existing node? I am facing a challenge where I need to build a tree structure top-down, which means that I know the ...

Combining and removing identical values in JavaScript

I need to sum the price values for duplicated elements in an array. Here is the current array: var products = [["product_1", 6, "hamburger"],["product_2", 10, "cola"],["product_2", 7, "cola"], ["product1", 4, "hamburger"]] This is what I am aiming for: ...

Pictures displayed in a bootstrap carousel are not completely filling up the entire carousel space

I recently started working with Ruby and decided to use the refile Gem for uploading multiple photos. I wanted to showcase the photos in a Carousel format using Bootstrap carousel. However, when I display the photos, they don't fill the carousel windo ...

What is the best way to position a div on top of another within a container using Bootstrap?

I have created a div with a date picker inside a form for future fields, but the initial display is next to the table instead of above it. I've searched for solutions similar to my issue, but none seem to work for me. You can view the correct layout ...

Having trouble adjusting the width and height of images to a full 100% scale

I'm currently working on an Angular and Bootstrap application where I am trying to integrate a Bootstrap carousel. However, I've encountered some resizing issues with the width and height of the images/graphs. You can view a demo of the issue he ...

Even after setting [attr.disabled]="false" in Angular, the Textarea still remains disabled

I am currently utilizing ngModel for a textarea, and I would like to be able to enable and disable the textarea based on a certain condition. Even though I have bound it correctly and the value is changing to [attr.disabled]="false", the textarea remains d ...

Unable to render a child div completely opaque using the opacity attribute

I am currently working on a popup feature that, when displayed, will blur the background of the page to a grey color. The .cover element is responsible for this overlay effect. Unfortunately, I am facing issues overriding its default opacity:0.6; property ...