CSS card with border and a cut-out in the top-right corner

Looking to create a div with a gray border that is 20px thick all around. I also want a cut out in the top right corner of the div, with the rest of the borders matching the thickness. The cut out should be transparent.

Here is my attempt:

http://jsfiddle.net/tybourque/2bZAW/5959/

.card-cutout:before {
    content: '';
    position: absolute;
    top: -20px;
    right: -80px;
    border-top: 80px solid transparent;
    border-left: 80px solid #828282;
    width: 0;
    z-index: 10;
}
.card-cutout:after {
    content: '';
    position: absolute;
    top: 0px;
    right: -62px;
    border-top: 65px solid transparent;
    border-left: 62px solid white;
    width: 0;
    z-index: 11;
}

Any suggestions on an easier way to achieve this look? https://i.sstatic.net/doz1u.png

Answer №1

To achieve this effect, you can utilize a :before pseudo-element along with gradient styles:

body {
  background-color: #f5f5f5;
}

section {
  background-color: #fff;
  border: 10px solid #ccc;
  height: 200px;
  margin: 20px auto;
  position: relative;
  width: 80%;
}

section:before {
  background: linear-gradient(135deg, #fff 40%, #ccc 40%, #ccc 60%, #f5f5f5 61%);
  content: "";
  display: block;
  height: 100px;
  position: absolute;
  right: -10px;
  top: -10px;
  width: 100px;
}
<section></section>

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

Emails are failing to send when information is entered, instead sending a blank email when the page is

My contact form has server side validation in place to ensure that required fields are filled out. However, I'm facing an issue where if a user fails to enter information into a required field and presses the send button, no email is sent. On the othe ...

What is the best way to align text and images for list items on the same line?

HTML:- ul { list-style-image: url(https://i.sstatic.net/yGSp1.png); } <ul> <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reprehenderit, consequatur?</li> <li>Lorem ipsum dolor sit amet, consectetur adipisici ...

Leveraging the browser's built-in validation error messages in Angular for HTML forms

Is there a way to incorporate browser's native HTML validation error messages into Angular applications? https://i.sstatic.net/J0em4.png What I am looking for is the ability to leverage the built-in error messages when working with reactive forms li ...

Leveraging reframe.js to enhance the functionality of HTML5 video playback

I'm struggling with using the reframe.js plugin on a page that includes HTML5 embedded video. When I try to use my own video file from the same folder, it doesn't work as expected. While everything seems to be working in terms of the page loadin ...

How to retrieve the value of a selected item in primeng using p-dropdown and angular

Encountering an issue when trying to send the selected item value while iterating over an array of strings like: "BMW", "FERRARI", "AUDI", "BENTLY" Here is the structure of my HTML: <p-dropdown optionLabel="type" [options]="cars" formControlName="name" ...

Tips for creating proper spacing between text and adjacent boxes in CSS/HTML

I am currently working on a registration form and facing an issue with the spacing. The space between each credential and its corresponding input box appears irregular, which is not desired. I have tried using the <pre> tag to format the code, but th ...

Using a carousel component in Bootstrap

Just starting out with this, trying to customize Bootstrap to change slides automatically. I followed the documentation at https://getbootstrap.com/docs/4.3/components/carousel/ but for some reason, the slides aren't changing on an interval, even thou ...

What is the method to adjust line spacing of hyperlinks in JavaFX?

I am setting up a vbox and inserting hyperlinks into it. Hyperlink clickableString; clickableString = new Hyperlink(); clickableString.setStyle("-fx-text-fill: black;-fx-padding: 0; -fx-line-spacing: 0em;"); //setting the hyperlink color to black. clicka ...

Utilize CSS in your HTML using Express framework

I am attempting to link a css stylesheet to my basic html webpage. I am utilizing parse.com hosting for dynamic webpages that utilize express. There are numerous responses to this question, but none of them have proven successful in my case. I am trying ...

Python and Selenium are a powerful combination, but sometimes you may encounter the error message "Element cannot be clicked at point (x,y)

I'm trying to automate the selection of a checkbox on a webpage using Selenium and Python with this line of code: self.driver.find_element_by_id('lg_1166').click() Unfortunately, I'm encountering an error message: Message: Element < ...

Guide to populating a dropdown list using an array in TypeScript

I'm working on a project where I have a dropdown menu in my HTML file and an array of objects in my TypeScript file that I am fetching from an API. What is the best approach for populating the dropdown with the data from the array? ...

Update the value of an ASP textbox using JQuery, and ensure that the .Text property accurately reflects the new value

After searching extensively, I still haven't been able to find a solution to my problem. I am facing an issue with updating a readonly Textbox in ASP.NET using JQuery after selecting radio buttons. The value displays correctly and everything seems to ...

Implement jQuery plugin selectively in AngularJS on particular pages

Struggling with Angular JS and trying to integrate the Liquid Slider jQuery Plugin. While I find Angular JS intriguing, I still have a lot to learn before fully utilizing it. Any assistance would be greatly appreciated. The objective: Implementing the Liq ...

Display input field in AngularJS when radio button is selected

My JavaScript array looks like this: $scope.quantityMachines = [ { 'snippet' : 'One' }, { 'snippet' : 'Two' }, { 'snippet' : 'Three or more', 'extraField' : true }, { ' ...

What is the best way to constrain the ratio of a full-width image display?

I am in need of a solution for displaying an image at full width inside a frame with a 16:9 aspect ratio. The image needs to be centered within the frame and adjust responsively when resizing the screen. My preference is to achieve this using just CSS. ...

Section CSS for Full Page Styling

Embarking on my first freelance project to create a website, I have some expertise in html/css, Ruby Rails, and Bootstrap. However, there is one aspect that I can't seem to figure out. How do I make specific sections of the page occupy the entire brow ...

Restore checkbox to default setting

Is it possible to reset checkboxes in a form back to their initial status using javascript, PHP, jQuery, or any other method? Here is the code I am currently using: <form method="POST> <input type="text" name="name" id="name" value="default val ...

Employing Selenium for extracting the id_str element

Currently, I am utilizing the Selenium library in python to scrape content from a twitter search results page: https://twitter.com/search?q=twinkie&src=typd&lang=en The Selenium library provides several functions to help identify the desired conte ...

Is there a light font that cannot be replicated?

I attempted to replicate the font style used in this website's menu, but after implementing it into my WordPress CSS theme, the text still appears bold. Is there a particular technique I can use to achieve the lighter version of the font? I have loade ...

Navigation bar with a full-page slider

I am trying to incorporate my bootstrap nav bar into a full-width slider, similar to the layout in this example. https://i.sstatic.net/LE9wP.jpg This is the full width slider http://codepen.io/grovesdm/pen/MazqzQ Currently, I have positioned the nav ba ...