What is the solution for correcting skewed div content?

Currently, I am applying a transformation to a <div> element using the value of skewX(-18deg). However, I am facing an issue where inserting text into it causes overflow.

The content inside the skewed container is reverted back to its original state using skewX(18deg).

The desired final outcome should resemble the following:

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

Consider this code snippet:

(function() {
  // Your JavaScript goes here
})();
And the corresponding CSS:
body {
  background: #ffffff;
}

To further explore this concept, check out my pen titled "New version - Scroll one page" by Văn Lộc (@r0ysy0301) on CodePen.

Answer №1

@skav's link pointed me in the right direction, although shape-inside seems to be less dependable than shape-outside.

Here is how I tackled this:https://i.sstatic.net/yCNsv.png

You can add a div within your description div and apply an outershape to mimic the skewed image on the right. Keep the background transparent; I used green for visibility.

Additionally, when working with images, using clip-path reduces the amount of code needed. Organizing your text into p tags increases clarity, and adding ­ within words improves the appearance of justified text.

For HTML:

<div class="skw-page__content">
          <div class="triangle"></div>
          <h2 class="skw-page__heading">Page 1</h2>
          <div class="skw-page__description">
            <p>Lorem ipsum dolor sit amet, con&shy;sect&shy;etur adi&shy;pisi&shy;cing elit. Accu&shy;sa&shy;mus ha&shy;rum qui, pla&shy;ceat fugit de&shy;lec&shy;tus ma&shy;xime volupta&shy;tibus perspi&shy;ciatis, quia sit it&shy;aque!</p>
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/img-test.jpg" alt="random nice picture of a montain reflecting ine a blue lake"/>
            <p>Qui&shy;bus&shy;dam lib&shy;ero, cupi&shy;di&shy;ta&shy;te aspe&shy;rio&shy;res tem&shy;pora quos porro in&shy;ven&shy;tore? Prae&shy;sen&shy;tium ape&shy;riam dele&shy;ni&shy;ti nam a a&shy;li&shy;quid sequi ea perspi&shy;ciatis error recu&shy;sandae enim, do&shy;lorem quae.</p>
          </div> 

For CSS:

.skw-page__description {
    font-size: 14px;
    width: 100%;
    hyphens: auto;
    text-align: justify;
    padding: 0;
}
img{
      min-width: 0px;
      max-width: 75%;
      min-height: 0px;
      margin: 2% 0;
      clip-path: polygon(0% 0%, 100% 0%, 78% 100%, 0% 100%);
  }

.triangle {
    width: 300px;
    height: 100%;
    background-color: transparent;
    shape-margin: 0 0 0 2%;
    clip-path: polygon(98% 0%, 100% 0%, 100% 100%, 50% 100%);
    shape-outside: polygon(95% 0%, 100% 0%, 100% 100%, 50% 100%);
    background: green;
    float: right;
    right: 0;
}

There you have it :)

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 replace a regular expression in JavaScript?

I've recently been exploring the functionalities of MathJax, a Javascript library that enables the use of LaTex and similar mathematical markup languages within HTML. However, when attempting to incorporate it into my Javascript code, I encountered so ...

Validating File Names with Formik and Yup

I'm currently implementing file name validations using YUP with regex. I keep encountering an error whenever a file is uploaded; the file name must not begin with special characters. For more details, please check out the codesandbox link: Code Link a ...

Differentiating between swipe and click actions within Angular applications

Utilizing ng-click to display item details in a list while also implementing a jQuery mobile swipe event on the list item to reveal a delete button when swiped left has presented an issue. The problem arises when swiping triggers both the swipe event and a ...

What is the best way to horizontally align three animated progress bars alongside images?

Check out this jsfiddle that shows a vertical alignment of the progress bars. How can I modify it to align them horizontally and centered? https://jsfiddle.net/bLe0jLar/ .wrapper { width: 100px; height: 100px; } .wrapper > #bar, #bar2, #bar3 { ...

Enhancing the appearance of the MUI DatePicker

I'm currently using a DatePicker component from Mui Lab and I'm attempting to customize the appearance of the Calendar component by incorporating some border or background color. Although I've tried utilizing the PaperProps prop for DatePick ...

What is the best way to implement a function on every item within a specific class?

I'm new to coding and I have a website that showcases job listings. I want to create a function that dynamically changes the logo of a company based on the first 50 characters of the company name mentioned. The current function only works for the firs ...

The issue with Node.js arises when attempting to access data within a nested fs.readFile call

This is my initial attempt at a nodejs project and I'm struggling to pinpoint the issue: https://i.sstatic.net/NsI7M.png fs.readFile("/home/shaurya/Desktop/test.txt","utf-8", function(err,filedata1){ fs.readFile(filedata1,"utf-8",function(err, ...

Eliminate certain inline styles using jQuery

I am facing an issue with an asp menu I am using. It is automatically inserting style="width:3px;" into my menu table tds, creating an unsightly gap between my tabs. Instead of asking our developer to customize the menu just to fix this cosmetic flaw, I am ...

Item 'unreachable' displayed in Firefox console

I am working with several divs that have the class='class_name'. I have also defined var A = document.getElementsByClassName('class_name'); console.log(A[0]); Upon checking in the Chrome console, it displays: <div class="class_n ...

Is there a way for me to retrieve the header values of a table when I click on a cell?

I have a project where I am developing an application for booking rooms using Angular 2. One of the requirements is to be able to select a cell in a table and retrieve the values of the vertical and horizontal headers, such as "Room 1" and "9:00". The data ...

The presentation of the content on Github Pages differs from what is shown on VS Code

Upon opening my website on VS Code's live server, everything appears as intended. Media queries successfully resize the navbar, and the Jumbotron image displays correctly. However, when viewing the site on Github Pages, everything appears smaller - fr ...

Having numerous sections condensed into one cohesive page

Currently, I am working with backbone.js to develop a single-page application that takes inspiration from the functionality of trello.com. I am interested in learning how to display multiple pages on top of the original page and effectively structure the ...

Using React to Render a Component with Local Storage Information

I'm in the process of developing a history list component for a form within a react application and encountering difficulties with local storage. The goal is to display a list of previous user inputs from the local storage data. My current approach i ...

Tips for changing the anchor tag color without the cursor hovering over it

Hello, I am learning CSS and I've been practicing some coding. #IconHover:hover { background-color: #F18B13; color: #fff; height: 50px; width: 180px; } a:hover { color: #fff; text-decoration: none; } <table id="IconHo ...

When switching between tabs on Twitter Bootstrap, the page automatically scrolls to the top

I am encountering an issue with my tabs setup. Each tab has a different height and there is a Row on top of the tabs. You can see the problem in action on this JSFiddle. Whenever I switch from a tab with greater height to a tab with less height, the page ...

Using JQuery to limit the characters in a TextBox to only alphabets, numbers, and forward slashes

How can I limit a text field in ASP.NET to only allow alphanumeric characters and forward slashes (/)? I've tried the code snippet below: function jsCheckInput(e) { var evt = (e) ? e : window.event; var key = (evt.keyCode) ? evt.keyCode : evt ...

Google Maps fails to load when triggered by the jQuery show() function

One issue I'm facing is that the Google Map is not loading after the show() function is called in jQuery. Initially, I use display:none to close a division on page load. After some research, I found out that it can be resolved by using google.maps.eve ...

jQuery Nested Slider Transition

Having an issue building a nested slider with jQuery. I'm struggling with the logic for the tabs when trying to implement anchored slides based on tab clicks. I've hit a roadblock in coding as I can't figure out how to apply the logic. j ...

Is it possible to change text dynamically with an input box using JavaScript?

Is there a way to use JavaScript to create two input boxes for text replacement? Instead of constantly editing code to replace different text, I am looking for a simple user interface with Input Box A, Input Box B, and a button. The first input box will ...

Using values from an appsettings.json file as href variables in an AMP html: a complete guide

Currently developing an AMP website with the URL www-dev.example.com, directing users to a sign-up page. The sign-up page is hosted on an identity server under the subdomain auth.www-dev.example.com. Now, the goal is to deploy the AMP website to a staging ...