Is there a way to add text to a slanted comic panel using CSS?

I am currently working on a project to practice designing comic layouts, and I would like to create a section of the page that resembles a comic panel.

By using transform: skew(10deg);, I have successfully skewed the panel, and I can reverse the skew for the content with transform: skew(-10deg);. While this is a good start, I am now looking to ensure that the text fills the skewed shape, similar to the sketch I have shared below.

What CSS techniques or properties should I utilize to achieve this effect? How can I make sure that the text fits appropriately within the skewed panel?

You can view the design sketch here.

Thank you in advance for your assistance!

I recently came across the shape-outside property, but I struggled to understand how to apply it in reverse.

This is what I have implemented so far:

* {
  margin: 0;
  box-sizing: border-box;
}

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card {
  background-color: teal;
  transform: skew(-20deg);
  width: 70%;
}

.content {
  padding: 1rem 3rem;
  width: 50%;
  background-color: yellowgreen;
}

.content>* {
  transform: skew(20deg);
}
<body>
  <div class="card">
    <div class="content">
      <h2 class="card-title">cool title</h2>
      <p class="card-desc">Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed totam praesentium nisi quibusdam explicabo error officia veritatis ut facere nostrum, repellat iusto optio deserunt qui laboriosam maiores vel? Vel quis optio, nulla error totam explicabo
        ipsam neque eos non magni!</p>
    </div>
  </div>
</body>

Answer №1

When it comes to creating unique shapes, I always rely on clip-path. By manipulating the numbers, you can achieve the perfect fit for your design.

* {
  margin: 0;
  box-sizing: border-box;
}

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card {
  background-image: url(https://placehold.co/600x400/EEE/31343C);
  background-position: center;
  transform: skew(-20deg);
  width: 70%;
}

.content {
  padding: 1rem 3rem;
  width: 60%;
  background-color: yellowgreen;
  clip-path: polygon(0% 0%, 75% 0%, 100% 42%, 75% 100%, 0% 100%);
}

.content>* {
  transform: skew(20deg);
}

.card-desc {
  padding: 1rem;
}
<div class="card">
  <div class="content">
    <h2 class="card-title">cool title</h2>
    <p class="card-desc">Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed totam praesentium nisi quibusdam explicabo error officia veritatis ut facere nostrum, repellat iusto optio deserunt qui laboriosam maiores vel? Vel quis optio, nulla error totam explicabo
      ipsam neque eos non magni!</p>
  </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

Ensuring HTML closing tags are aligned with their corresponding opening tags in Intellij

Are you trying to set up the HTML code style in IntelliJ? Would you like the closing tag to align with the open tag? Take a look at this sample code: <div> <p>Test</p></div> When I use the auto format feature (ctr+alt+L), I e ...

Using ngFor to render elements in several table rows

Looking for a solution to display a Python list using Angular in multiple rows instead of a single table row. The current setup is showing more than 200 objects in a single row which is not ideal. List=[1,2,3,4,5, .......100} This is the HTML currently b ...

Tips for creating a consistent header and footer across an HTML CSS web application

My previous projects involved using ASP.NET MVC and utilizing @Html.Partial("_header") to incorporate common static HTML across different pages. However, my current project is a pure HTML CSS and JS web app with no server-side technology. The la ...

Having trouble with the Javascript denial of submit functionality?

I'm dealing with an issue in my code where form submission is not being denied even when the input validation function returns false. I can't figure out what's causing this problem. <script> function validateName(x){ // Validati ...

What is the best method for deleting siblings from the DOM structure?

Here is some code that currently functions: a.parentNode.removeChild(a); But now, I also want to remove the previous sibling of this child element. How can I modify the code to achieve this? Is there any documentation on MDN that can help me with this ...

Tips for implementing both an onChange and onSubmit event for a MUI TextField

I'm currently working with React and MUI and have created a form like the following: const handleUserInput = (event) => { set_user_input(event) } const handleSubmitForm = () => { if (user_input == 'help'){ ...

Is my code incorrect, or is JQUERY failing to load correctly?

I'm currently experimenting with jQuery methods for ajax in order to create a dropdown menu. Below is the jQuery code I am using: JAVASCRIPT: <SCRIPT> $("select[name='carid']").on("change", function() { $.post( ...

Tips for preventing text from breaking onto a new line in Safari

I have cforms plugin installed on a WordPress page. Interestingly, the word "required" in Russian appears to consist of two words as per the translation office. While it displays correctly in Firefox, in Safari it breaks and aligns to the bottom left of ...

What could be causing my SVG to overlap with its parent div?

I am currently working with the following HTML and CSS: <div class="LABEL_MAIN"> <div class="LABEL_BOX"> <div class="OP_LABEL"> bro </div> </div ...

Choosing multiple images by clicking on their alternative text with jQuery

I am currently working on a project that involves clicking on a thumbnail to enlarge the image and display its name (alt) below it. I have made progress, but there seems to be an issue where only one image is displayed no matter which thumbnail I click on. ...

What is the best method to update the content of a bootstrap-5 popover using only pure JavaScript?

Having trouble changing the content of a Bootstrap popover using vanilla JavaScript? The code seems to be updating, but the changes are not reflecting on the site. Any suggestions or alternative methods would be greatly appreciated! Maybe there's a di ...

Creating a perfectly centered button with Bootstrap

Just diving into the world of bootstrap and jquery while working on a school project. Bootstrap is being used to ensure responsiveness in my application. Facing an issue where the buttons are aligning at the top of their respective columns instead of in th ...

Generate spacing between rows of content in HTML or CSS without affecting the spacing between lines of text

In my R Markdown document in R, I want to replace the header labeled "Preface" with grey lines for visual indication. Here's the code snippet I've tried: :::{#preface} <p> Text </p> ::: However, there seems to be no margin at the beg ...

How to place text on top of a thumbnail in Bootstrap using HTML

I've come across similar questions here, but none of the suggested solutions have worked for me. (I attempted making the image a background as recommended on how to display text over an image in Bootstrap 3.1, but it didn't seem to be effective) ...

What is the proper way to eliminate the port from a URL so that the images sourced from the XAMPP database can function correctly?

I am a beginner in Angular and I am facing an issue with Angular and XAMPP. I am attempting to load images from mySQL database where I stored their destinations. The problem is that Angular is trying to access that destination through this link: https://i ...

Limit access to a page only to designated users

Having a challenge creating a secure page for band members to access their individual band pages. In the band table, each band has four columns labeled $bandm1, $bandm2, $bandm3, and $bandm4. I attempted to create a script that extracted the session user ...

Managing the attention on a switch button

I'm struggling to maintain focus on the toggle button after it's been clicked. Currently, when I press the button, the focus jumps to the top of the page. I can't figure out what I'm doing wrong. Below is the code snippet: HTML <b ...

The Impact of Navbar Size across Different Screen Sizes

Looking to create a responsive navbar for my website, but struggling with button alignment on smaller screens. Any tips on keeping all navbar elements in line across different screen sizes? <!--Navigation with Button --> <?php if(session_status ...

Why use getElementById(id) to obtain an element in JavaScript when it already exists in the JS?

Recently, I have observed that a reference to an HTML element with an id can be easily accessed in JavaScript by using a variable named after that id (jsbin). What is the reason for this behavior? Why do we need to use getElementById(id) when we could sim ...

Is it time to go back to the parent selector using the ampersand symbol?

I recently started using Less for writing CSS, and it has definitely been a time-saver for me. However, I have encountered a small issue with my code: <a href="#" class="btn-black-bg btn-right-skew">largest fight gym in Australia</a> Less .b ...