A guide to making a slanted corner edge using CSS

I'm facing a design challenge with the unique path my main site container takes, especially with the angled part in the middle. I've been struggling to find the right approach to implement it.

I'm hoping CSS can help me achieve this, but I'm also willing to explore other options. Despite my extensive research, I haven't come across anything that directly addresses this specific issue.

Answer №1

Check out this link for a cool CSS snippet:

.edge{position:relative;background-color:#cccccc;border:1px solid #ffffff;display:inline-block;}
.edge img{display:block;}
.edge:before{content:'';position:absolute;left:-1px;top:-1px;border-top:50px solid #ffffff;border-right:50px solid transparent;}
.edge:after{content:'';position:absolute;left:-2px;top:-2px;border-top:50px solid white;border-right:50px solid transparent;}

<div class="edge">
    <img src="http://placekitten.com/g/500/300" alt="" />
</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

Issues with CSS arising from conflicts in MUI alert component styling

My experience with Material UI 5.10.11 has been mostly positive, but I have encountered some issues with the MuiAlert component. When setting severity to 'error', it should look like this https://i.sstatic.net/A1KIE.png However, on certain pages ...

Having difficulty adjusting the StartIcon margin within the MUI Button example, unable to override its values

Currently, I am facing an issue with the Button component in Material UI. Specifically, I am working with a Button that contains a StartIcon. Despite trying to modify the default margin provided by the StartIcon CSS, I have been unsuccessful so far. https: ...

Creating a centered floating card within a div that shrinks to fit its contents: A CSS how-to guide

I am facing a challenge with positioning a floating card that needs to be centered over the parent div (which happens to be selectable because it's a map). So far, I have only managed to achieve this by setting a fixed width for the card using the fo ...

Maintaining hover effects even when elements are not in view

I am facing an issue with my absolutely positioned <div> (which serves as a menu) located in the corner of a webpage. The problem arises when I try to animate it on hover, but as soon as the cursor moves beyond the viewport, the hover action stops. I ...

Deleting entries from a selection of items in a list generated from an auto-fill textbox

I have successfully implemented an auto-complete Textbox along with a styled div underneath it. When the client selects an item from the Textbox, it appears in the div after applying CSS styling. Now, I am looking to create an event where clicking on the s ...

Is it possible to obtain the hostname through CSS?

.trPic{ width:640px; height:480px; position:absolute; top:0px; left:0px; width:640px; height:480px; background: url(http://192.168.2.150:8090/?action=stream) no-repeat; border:0px solid #000000; } Is it possible to include a hostname in CSS? For ...

The radio-inline class should be limited to applying on columns with the classes col-lg-*, col-md-*, and col-sm-*, and should not be

I am currently facing a requirement where I need the radio buttons to display vertically on smaller screens (col-xs-*) and horizontally on larger screens (col-lg-, col-md- and col-sm-*). Right now, I am using the radio-inline class to make the radio button ...

Embed a data entry point into an existing picture

Looking for assistance inserting a field within an image for users to enter their email. Can someone provide the HTML code for this? Appreciate your help! ...

Sometimes, IE8 fails to load CSS files properly

This issue is really frustrating me, guys The website displays correctly in Firefox and IE9, but has minor layout problems in Chrome and mobile Safari. When trying to load the page from the server in IE7 or IE8, it's very unreliable. It usually work ...

Increase the size of a collapsible div without affecting the navbar

I have a complex layout consisting of a navbar, a collapsible div, and a table within a container. My goal is to make the collapse div appear when clicking on a row in the table. However, I'm facing an issue where the entire structure of the page brea ...

A web page with a full-width header, content constrained to a set width, logo elements displayed with flexbox, and a footer that

I've been facing challenges in making this website responsive on both desktop and mobile devices. Initially, the header background image wasn't displaying as intended, followed by issues with the flexbox logo elements in the header and the sticky ...

Angular navigation bar dropdown menu is not displaying properly

Check out this Bootstrap Navbar I recently added the same code to my Angular project, but I'm having trouble getting the dropdown to display properly. Take a look at the Stackblitz Demo I need help with two things: Getting the dropdown to show c ...

Flexbox margins (exceeding 100% total width)

Currently collaborating with @c4rlosls and we are facing 2 issues: https://i.sstatic.net/44WcI.jpg If the parent container with class container-fluid has a px-0, it extends beyond 100% width. Additionally, the elements with classes .cont2 a and .cont3 a do ...

Creating an image overlay within HTML text in NSAttributedString with CSS: A step-by-step guide

I am currently working on extracting HTML text that includes a YouTube video. In order to showcase this video, I have implemented a preview image. The original text is as follows: <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ei ...

Hamburger Icon in Bootstrap Navbar-Brand is not aligned as expected

I'm currently working on a website project using Bootstrap and have encountered an issue with the navbar component. When the screen shrinks to the breakpoint I've defined (lg), the alignment of the hamburger icon gets disrupted, as shown below. ...

I'm having trouble grasping the concept of margin collapse in this particular example

It's clear why the margin collapses to 20px in the first example when there's a border on the outer div. However, it is puzzling how the margin collapses to zero in the second example just by removing the border from the outer div. /*First exam ...

What causes html elements to lose their border-radius when they are being dragged?

Why did the element lose its border-radius when I dragged them? It seems like the element is cutting into the background to fill the four corners. Click here to see CSS class for item: .list_item_pic { display: flex; flex-direction: column; justify- ...

What is the best way to apply a datepicker to all textboxes with a specific class using jQuery?

I have enclosed multiple fields within div elements in order to specify them with a datepicker for a better user experience. For example: <div class="need-date" > <label>Appointment Date</label> <input id="id_appointment_date" ty ...

Adjust the cursor to a hand icon when hovering over a row within a table

Can you explain how to make the cursor change to a hand when hovering over a <tr> in a <table>? <table class="sortable" border-style:> <tr> <th class="tname">Name</th><th class="tage">Age</th> < ...

Tips for building a dynamic view using Angular

I am working on a project where I need to dynamically generate multiple horizontal lines using data from a JSON file, similar to the example in the image below. https://i.sstatic.net/MthcU.png Here is my attempt: https://i.sstatic.net/EEy4k.png Component. ...