Creating a folded-corner effect in CSS with a clear background - here's how!

Can anyone assist me? I am trying to change the folded-corner to be transparent instead of a solid color. Please refer to the image below for guidance.

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

I have attempted to modify these codes:

.back-ground
{
    background-image: url('http://pencil.my/assets/img/dashboard/bg.png');
    background-repeat: repeat;
    overflow-x: hidden;
}
.note {
    position: relative;
    width: 30px;
    padding: 1em 1.5em;
    margin: 2em auto;
    color: #fff;
    background: #97C02F;
    overflow: hidden;
    border-radius: 4px;
}

.note:before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    border-width: 0 16px 16px 0;
    border-style: solid;
    border-color: #fff #fff #658E15 #658E15;
    background: #658E15;
    display: block;
    width: 0;
    -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
    -moz-box-shadow: 0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
    box-shadow: 0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
}
<div class="back-ground">
 <div class="note">
    Sample note
 </div>
</div>

Answer №1

Although I may be a little late to answer this question, after conducting some research and exploring various solutions, I have found one that works well for me on a particular website.

    body {
      background-color: #234232
    }

    .box {
      width: 50%;
      height: 40%;
      margin: auto;
    }

    .fold-corner-card {
      margin: 2em;
      padding: 2em;
    }

    .fold-corner-card {
      background:
        -webkit-linear-gradient(225deg, transparent 50%, #C9CCD4 50%),
        -webkit-linear-gradient(45deg, #FFF, #FFF),
        -webkit-linear-gradient(135deg, #FFF, #FFF),
        -webkit-linear-gradient(225deg, transparent 25px, #FFF 10px);
      background:
        -moz-linear-gradient(225deg, transparent 50%, #C9CCD4 50%),
        -moz-linear-gradient(45deg, #FFF, #FFF),
        -moz-linear-gradient(135deg, #FFF, #FFF),
        -moz-linear-gradient(225deg, transparent 25px, #FFF 10px);
      background:
        -o-linear-gradient(225deg, transparent 50%, #C9CCD4 50%),
        -o-linear-gradient(45deg, #FFF, #FFF),
        -o-linear-gradient(135deg, #FFF, #FFF),
        -o-linear-gradient(225deg, transparent 25px, #FFF 10px);
      background:
        linear-gradient(225deg, transparent 50%, #C9CCD4 50%),
        linear-gradient(45deg, #FFF, #FFF),
        linear-gradient(135deg, #FFF, #FFF),
        linear-gradient(225deg, transparent 25px, #FFF 10px);
    }

    .fold-corner-card {
      -webkit-background-size: 35px 35px, 0 0, 0 0, 100% 100%;
      -moz-background-size: 35px 35px, 0 0, 0 0, 100% 100%;
      background-size: 35px 35px, 0 0, 0 0, 100% 100%;
      background-position: 100% 0, 0 0, 100% 100%, 100% 0;
      background-repeat: no-repeat;
    }
<div class="box">
  <div class="fold-corner-card" style="position: relative;">
    <h1>Lorem</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec viverra nisi dolor, at venenatis nisl viverra sed. Donec arcu felis, fermentum nec sapien vitae, gravida fringilla sapien. Nunc bibendum semper tristique. Curabitur non tempus augue. Vestibulum ut sapien lacus. Sed laoreet molestie est dignissim venenatis.</p>
  </div>
</div>

Answer №2

You could achieve a similar effect by creating a triangular shape using the CSS `::before` pseudo-element and the `border-color` trick. Rotate the triangle using the `transform` property and position it at the top of the page along with the `::after` element:

body {
  padding: 2em;
}

.paper {
  height: 100%;
  min-height: 400px;
  background: #fff;
  position: relative;
}

.paper::before,
.paper::after {
  content: "";
  position: absolute;
  display: block;
}

.paper::before {
  top: -59px;
  border: 30px white solid;
  border-top-color: transparent;
  border-left-color: transparent;
  right: 0;
  box-shadow: 3px 3px 4px rgba(0, 0, 0, 0.5);
  transform: rotate(88deg);
  z-index: 2;
  border-radius: 0% 0% 10%;
}

.paper::after {
  background: white;
  position: absolute;
  height: 57px;
  width: calc(100% - 60px);
  top: -57px;
}

.paper .content {
  padding: 0 2.5em;
  position: relative;
  top: -1em;
  z-index: 1;
  margin-top: 50px;
}


/*This is for the diagonal strip pattern on the background only */

body {
  background-color: gray;
  background-image: repeating-linear-gradient(135deg, transparent, transparent 35px, rgba(255, 255, 255, .5) 35px, rgba(255, 255, 255, .5) 70px);
}
<div class="paper">
  <div class="content">
    This is the content of the paper
  </div>
</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

Struggling to make a basic JavaScript prompt function as expected

<html> <title>UniqueTitle</title> <head> <link rel="stylesheet" type="text/css" href="style.css" > <script type="text/javascript"> function modifyDates() { var dates = pr ...

Adding a block between two other blocks on a mobile device using Bootstrap 4

I am trying to achieve a specific layout on both desktop and mobile devices. On desktop, I want the layout to be structured as follows: [1][2] [3][2] The requirement is for column 2 to be the same height as columns 1 and 3 on desktop screens. For the mo ...

The progress indicator fails to activate during the first step

As a beginner in coding, I wanted to incorporate a progress bar on my website. However, I encountered an issue where when I try to make step 1 "active", it's actually step 2 that becomes active, and the same pattern continues for subsequent steps. ...

Toggle Divs with jQuery (Rotate images depending on link)

I am currently using the following code to toggle the visibility of div elements. http://jsfiddle.net/XwN2L/3120/ In addition, I would like to have a unique image sprite for each link when it is selected. I attempted to assign individual IDs to each link ...

js include exclude switch a category

Although this question has been asked before, I have a query on completely removing an "id" from an element. Let's consider the following scenario: <div id="page"> some content here </div> I want to eliminate the "id" attribute from the ...

Identifying CSS div tags in CakePHP with unique class names

After running cake bake, a test installation was created resulting in the Product Controller and its associated views such as index.cpt, add.cpt, edit.ctp, etc. Upon inspecting the CSS file linked to these views, I noticed two specific divisions: action an ...

Ensure Navbar elements remain on a single line

I need my Bootstrap Navbar elements to remain on a single line regardless of the screen width. Although I have searched for a solution to this issue numerous times and tried different approaches, none have proven effective in my case. Below is the code s ...

There is an issue with XMLHttpRequest loading http://*********. The requested resource does not have the necessary 'Access-Control-Allow-Origin' header

Just getting started with node, javascript, and other related technologies. I encountered an Access-control-allow-origin error while attempting to execute a GET request using XMLHttpRequest. Despite searching extensively for a solution, nothing seems to be ...

Exploring ways to animate a conditionally displayed component when the state changes using a combination of javascript and css

I am encountering a scenario where I have a react component with a specific part that is rendered conditionally. Upon clicking on a visible element within the component (button), the state changes triggering the display of the hidden parts. However, inst ...

Mobile site experiencing owl.carousel responsiveness issues after refreshing the page

I am currently working on a website located at . On the homepage, right after the slider, there is a carousel of three info boxes. However, in mobile view (developer mode), after a hard refresh or viewing the link on an actual mobile device, it displays a ...

What could be the reason behind the malfunctioning of my media query in the

I am trying to connect an external stylesheet to my React component in order to apply different styles based on screen width. Specifically, when the screen width is less than 300px, I want the logo to have a height of 100vh. However, it seems that the medi ...

Determining the window height using jQuery when overflow is set to hidden

I've built a full screen web application that I don't want to scroll, so I used this code: $("body").css("overflow", "hidden"); However, after adding a resize listener: $(window).resize(function(){ console.log("Inner height: " + $(window). ...

Ways to tackle my code's linked dropdown issue without the use of extensions

When I selected the Id Province, I couldn't select the Id City. How can I fix this issue? Controller code snippet to address this: View code snippet for the same: ...

rendering google charts using jade template

I am facing an issue while trying to display a google annotated chart on my jade project. I managed to successfully load a pie chart, but I am having trouble rendering a chart that requires the container element size to be explicitly defined. You can find ...

Elevated CSS: Convert submenu to vertical dropdown layout rather than horizontal

My website features a superfish menu here, and I am seeking a way for the submenu to drop down vertically. Currently, I can achieve this by applying the following CSS: .sf-menu.sf-style-white.sf-navbar li ul { width: 150px; left: 100px; } However, th ...

New ways to style Links in NextJs 13

I am relatively new to Next.js and I am attempting to create a menu with a hover effect using the following code: import Link from 'next/link'; const MenuItem = ({ href, label }) => ( <Link href={href} className="menu-item"> ...

Is there a way to customize the CSS ul menu specifically for the JavaScript autocomplete feature?

I have created a search page with autocomplete for the first textbox, but I noticed that the ul/li CSS classes used for styling the main menu are impacting the JavaScript list. How can I override the menu styling to display a regular list format? Being a ...

Tips for including a verification symbol next to your username

How can I implement a verification badge next to a user's username on a website using jQuery, JavaScript, PHP, HTML, and CSS? Currently, I am using isset($user[verification]) to display the badge, but I believe this approach is not optimal as it requi ...

Using Slick Slider and Bootstrap CSS to display text on top of images

Currently, I am utilizing the slick slider from and I want to overlay text on top of the image. I tried using bootstrap carousel-caption, which works well with any image. However, with slick slider, it seems like the text is not at the highest level as I ...

What is the best way to modify the selection text background with CSS?

Does anyone know the method for modifying the selection text background in CSS? Many modern websites opt for a personalized background color instead of the traditional blue? ...