Creating a parallelogram-shaped card using CSS and Bootstrap

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

Is there a way to create a similar card using CSS or Bootstrap?

Answer №1

If you want to excel, it's best to showcase your own work rather than resorting to simply copying and pasting answers.

The example provided below does not consider responsive design and utilizes bootstrap-4.

You can use this as a guide to understand various classes like ml-3, shadow by referring to Bootstrap Documentation

<!DOCTYPE html>
<html lang="en">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />

  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dab8b5b5aea9aea8bbaa9aeef4ecf4eb">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous" />

  <title>Hello, world!</title>
</head>
<style>
  .diagonal-left {
    width: 100px;
    height: 100px;
    background-color: #deadee;
    transform: skewX(30deg);
    transform-origin: top;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .diagonal {
    width: 350px;
    height: 100px;
    background-color: #319b9e;
    transform: skewX(30deg);
    transform-origin: top;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .diagonal>span {
    transform: skewX(-30deg);
    color: white;
  }
</style>

<body>
  <div class="ml-3 row">
    <div class="diagonal-left shadow"></div>
    <div class="diagonal shadow"><span>Title<br>123</span></div>
  </div>

  </div>

  <!-- Optional JavaScript; choose one of the two! -->

  <!-- Option 1: jQuery and Bootstrap Bundle (includes Popper) -->
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91fbe0e4f4e3e8d1a2bfa4bfa0">[email protected]</a>/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="abc9c4c4dfd8dfd9cadbeb9f859d859a">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>

  <!-- Option 2: Separate Popper and Bootstrap JS -->
  <!--
    <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d071c18081f142d5e4358435c">[email protected]</a>/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d5d425d5d485f03475e6d1c031c1b031c">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c1a3aeaeb5b2b5b3a0b181f5eff7eff0">[email protected]</a>/dist/js/bootstrap.min.js" integrity="sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2" crossorigin="anonymous"></script>
    -->
</body>

</html>

Answer №2

If you want to create a parallelogram shape using CSS, you can achieve this easily by applying the transform:skew(); property. Here's an example of how you can do it:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.parallelogram {
    width: 100px;
    height: 50px;
    transform: skew(20deg);
    background: #555;
}
</style>
</head>
<body>

<h2>Parallelogram CSS</h2>
<div class="parallelogram"></div>

</body>
</html> 

This CSS code snippet will create a parallelogram shape with specified dimensions and skew angle. Feel free to adjust the values to suit your design requirements.

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

Tips for customizing the appearance of Angular Material select drop down overlay

In my project, there is an angular component named currency-selector with its dedicated css file defining the styling as shown below: .currency-select { position: absolute; top: 5px; right: 80px; z-index: 1000000; color: #DD642A; f ...

Is there a way to create a marker that changes color when hovering over the text directly below it?

Hi everyone, I hope you're all doing well. Currently, if you hover over the marker, it changes color. However, I want this effect to apply when hovering over the text below as well. Is there a way to create a connection between these two div elements? ...

Angular 4 issue: Changing the value in the HTML 5 slider does not trigger the onchange/input event

Below is the html 5 slider along with a button <button type="button" class="btn btn-default zhaw-ict-icon zhaw-icon-hinzufugen zoom-in" (click)="zoomIn()"></button> <input class="btn zoom" type="range" min="1" max="300" [value]="currentZoom ...

Translating language in jquery date selector

Is there a way to combine language translation with changeMonth and changeYear options in jQuery datepicker? I have tried the following code: $(this).datepicker($.datepicker.regional['fr']); And for ChangeYear: $( this ).datepicker({ cha ...

Guide to vertically centering Font Awesome icons inside a circular div

Is there a way to perfectly center align font awesome icons vertically? I have tried using the line-height property when text is present, and even setting the line-height equal to the height of the div. Attempts with display:inline-block and vertical-alig ...

Is it possible to manipulate the content inside a div tag using JavaScript in HTML?

What is the most efficient way to dynamically adjust a data offset value within an HTML tag using JavaScript? For example: <div class="box" data-offset="2s"></div> I am looking to update the value within the data-offset attribute based on s ...

How can I incorporate a string variable into an f-string in Python for printing?

Looking to display the user variable from a Python script in an HTML document? Here's a method to achieve this. my_python.py user = "myname" with open("../../html/forms/output.html") as output: print(output.readlines()) outpu ...

Prevent the table cell width from expanding beyond the content size

Is there a way to achieve this layout without relying on Javascript? Imagine having a <table> with an unknown width in the first column. The overall <table> width is set to 100% to allow other columns to resize accordingly, but is it possible ...

jQuery UI button not receiving proper styling

Having an issue with my javascript function that inserts a form when a button is clicked. There's another button at the bottom of the form added by the function, but it's not inheriting the ui css even if I add the ui-button class. Any assistance ...

Using Javascript to Change Background Color on Button Click

The button press does not result in a change of the background color. What could be causing this issue? var body = document.getElementsByTagName("body"); var bgbutton = doucument.getElementById("bgchange"); bgbutton.onclick = function() { body.style.b ...

I'm having trouble getting the data to parse correctly in ajax. Can anyone explain why it's not working?

I have implemented a system where an excel file is uploaded using AJAX, and information about the success or failure of the upload is sent from the upload page to the PHP page using json_encode. However, I am facing an issue with accessing this data indivi ...

Constantly scrolling screen in android Webview

When working with an Android web view, I encountered a bug related to infinite scrolling. Interestingly, removing the routerLink in certain pages resolved the issue, but not consistently across all cases. Is there a way to address this bug from the Android ...

Discovering the color of a locator (Button/Label) through a CSS locator in Selenium: What's the method?

I have a set of automation scripts in place that handle the downloading and saving of files from a server. These scripts also involve moving the downloaded files from the downloads folder to a user-specific location. When this process is complete, the co ...

What method can be used to obtain a parallel vector on a plane that has been struck by an intersecting ray?

Issue at hand: https://i.sstatic.net/H5g5M.jpg Given parameters: intersect, n, p. With p representing a random point in the space, and N as the normal of the plane. Desired result: w Approach attempted in my shader code: "vec3 n = normalize(faceNormal ...

Tips for preserving the content of a text field within the text field area

I have an HTML table with 3 fields, one of which is editable. The data for two columns is obtained as JSON - the fields are itemName and itemCode. The third column, Quantity, is manually created with a default value of 0. There is also a dropdown called ...

Can the "clear:right" property impact elements that are floated to the left?

Consider the following scenario: <div class="right">Box right 1</div> <div class="right">Box right 2</div> <div class="left">Box left</div> <p>... lengthy content ...</p> and this CSS code: .right { float ...

What is the best way to make my navbar adjust seamlessly to accommodate the largest element?

Currently, I'm facing an issue where my logo is not fitting properly inside my navbar and it's "falling out." You can see the problem here: https://i.sstatic.net/l4T1B.png Here is the relevant code: HTML: <nav class="container-fluid navbar ...

increasing the margin around a heading inside a container with existing padding

I'm currently struggling to apply padding to the header of this container. For some reason, I can't seem to add any padding to the left or right. The image below illustrates the current appearance. Here's the code snippet: <?php $feed = ...

Create an interactive zone on the map

Is there a method to click only within the triangle region without causing any impact on the surrounding areas? I attempted to generate a triangular div using `clip-path`, but unfortunately, it is not compatible with Internet Explorer. Despite thorough r ...

Utilize AngularJS to compare and eliminate duplicate elements between two lists

Two lists are causing me trouble: List1 = ['option1','option2','option3','option4','option5','option6','option7']; List2 = ['option3', 'option4', 'option7&ap ...