CSS: Crafting a unique image layout with scissor-cut design

This design uses a PNG image created in Photoshop:

When it comes to images:

Notice how the shape resembles a trapezium with one perpendicular side and another tilted.

How can we achieve this layout using HTML/CSS, so that any image placed inside this div is always displayed within the trapezium, creating a sleek user interface.

What is the process for creating this shape using HTML/CSS? Code following the accepted solution:

<div class="scissor"><img src="1.png" style="width:200px"></div>

and the corresponding CSS:

.scissor{       
    width: 300px;
    height: 150px;
    background: #FF6100;
    position: relative;
}
.scissor:after{
    content: '';
    position: absolute; top: 100%; left: 0;
    width: 0;
    height: 0;
    border-top: 100px solid #000; 
    border-right: 300px solid transparent;  
    display: block; 

}
span{
    display: inline-block;
    width: 80px;
    height: 80px;
    border: 10px solid #fff;
    border-radius: 50%;
    position: absolute; top: 40%; left: 50%;
    z-index: 1;
    transform: translateX(-50%);
}

Answer №1

One way to achieve this is by using pseudo-elements like :before or :after

div{       
    width: 300px;
    height: 300px;
    background: #FF6100 url('http://www.hybworks.co.uk/wp-content/uploads/2015/05/los-angeles-auto-repair-300x300.jpg') no-repeat 0 0;
    position: relative;
}
div:after{
    content: '';
    position: absolute; bottom: 0px; left: 0;
    width: 0;
    height: 0;
    border-top: 150px solid transparent; 
    border-right: 300px solid #fff;  
    display: block; 
}
span{
    display: inline-block;
    width: 120px;
    height: 120px;
    text-align: center;
    line-height: 120px;
    font-size: 60px;
    font-family: 'segoe ui';
    color: #fff;
    border: 10px solid #fff;
    border-radius: 50%;
    position: absolute; top: 10%; left: 50%;
    z-index: 1;
    transform: translateX(-50%);
}
<div>
    <span>D</span>
</div>

Another method would be to utilize svg

<svg width="300" height="200">
  <polyline points="10, 10 300, 10 300, 100 10, 200 10, 100 10, 10" stroke-width="1" stroke="rgb(255,97,0)" fill="rgb(255,97,0)">
</svg>

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

Implementing a Timer on a Bootstrap Progress Bar Using JavaScript

I am currently working on a timer with a progress bar. The timer itself is functioning properly, but I am facing an issue with syncing the progress bar with the timer. I am utilizing the bootstrap progress bar for this project. If I remove the 'bar&ap ...

What is the best way to determine the click position on a square-shaped element?

Is there a way to retrieve the precise position of a square element when it is clicked on? ...

Once setTimeout runs for the first time, it does not work again

I have a piece of JavaScript code that I want to make all Bootstrap alerts disappear after 1 second. It seems to work the first time, but if I add more alerts they remain on the screen. What could be causing this issue? $(document).ready(function () { func ...

Unable to choose the div element with id ":1"

Just starting out with web development, and I have a div element with the following attributes: <div class="" id=":1" role="treeitem" aria-selected="false" aria-expanded="false" aria-level="1" aria-labelledby=":1.label" aria-setsize="10" aria-posinset= ...

Tips for maintaining the fixed size of a table header and preventing it from resizing in width

My goal was to create a table using divs with fixed headers while scrolling vertically. However, I encountered an issue where the header width seemed to shrink and became misaligned with the rows. Even setting the width to 100% did not resolve this probl ...

Mysterious Charcoal Colored Button Background on Mobile Exclusively using Bootstrap

I am facing an issue with the navigation bar on my website. The navigation bar code is as follows: <nav class="text-center"> <button class="btn nav-button color-house" type="button"><%= link_to "House", home_house_path, class: "co ...

What is the process for extracting the value of a checkbox generated through JavaScript?

I recently came across a helpful post on Stack Overflow that provided sample code demonstrating how to display multiple list of checkboxes dynamically on a dropdown list. The function in the code was exactly what I needed for my webpage. However, I encount ...

What is the best method to eliminate the .invisible div entirely from your website?

I want to hide a select tag and only display it when necessary. To achieve this, I tried using the .invisible class from Bootstrap, but the issue is that even when hidden, it still takes up space. <div class="row invisible"> <div class="fo ...

What is the best way to capture the click event when a child <td> element

Looking to retrieve the content within the <th> tag of the selected <td>. Refer to this fiddle for more information: http://jsfiddle.net/zrccq447/ The challenge lies in handling <th> elements with colspan 2 or 3. Here is the current cod ...

The outcome of the Python web crawling did not meet our expectations

After using Selenium to scrape web data, I encountered an issue where it only displayed 96 out of 346 products instead of the expected 346. Does anyone have suggestions on how to fix this problem? The crawling code is placed right after the loop for clicki ...

Picking out text areas enclosed by div elements

It seems like I find myself coming back here quite frequently to ask for help, but once again I am stuck. I am trying to select a textarea and enable editing in another textarea, which works fine with textboxes but not with textareas. Every time I click on ...

Keeping content in the middle of the page

When working with a div tag, I encountered a challenge. <div id="length"></div> My goal is to center the contents of the div while also decreasing its width to hold a number. #length{ background:black; color:white; border:3px solid gr ...

Problem encountered when trying to apply background opacity to custom colors using Tailwind CSS and shadcn/ui

While using Tailwind CSS along with the shadcn/ui library for styling buttons, I have encountered an unexpected behavior. The issue arises when trying to add background opacity to a custom color defined in globals.css using HSL values such as: --primary: 3 ...

What could be causing appendChild to malfunction?

I'm having an issue trying to create three elements (parent and one child) where the third element, an <a> tag, is not appending to modalChild even though it's being created correctly. modal = document.createElem ...

Tips for implementing a Dialog Box within a Card Action Button Group

I'm currently exploring the option of incorporating a Dialog box as a button within a Button Group, which is then nested inside a CardActions component in Material UI. Previously, I had success with using regular Buttons instead of a Dialog, where th ...

Tips for implementing a jQuery mouseleave function for multiple div elements sharing the same id

I am facing an issue with my website where multiple divs share the same id. I need to implement a mouseleave function for all of these divs that have this specific id. Within my $(document).ready function, I currently have the following code... $('#m ...

What is the process for altering fonts in a Chrome OS application?

After extensive research on the Internet, I have been unable to find clear instructions on how to modify the text font in a Chrome OS application. Most search results pertain to adjusting the font for the OS user rather than the developer of the app. My i ...

Trouble encountered when retrieving information from object following GET request?

Incorporating a weather API into my Angular application has been quite interesting. Here is a glimpse of the response from the API, available at this link. The data retrieval process involves a function like so: getTempByName(name) { return t ...

Is there a way to determine which label in the Material UI default theme affects the default border color, specifically excluding the focus or hover border?

I am currently using the 'createTheme' function to personalize the theme of my TextField input component in Material UI. To implement the desired changes, I am referring to the default theme for Material UI on https://mui.com/customization/defau ...

Pass multiple JSON objects to Angular and render them in an HTML template

Hey there! I'm looking for assistance with integrating a JSON object containing product data into an Angular HTML file. Although I've managed to make it work in the console (check out the image below), I'm unsure how to display this informat ...