Is it possible to clip a side of a DIV with CSS like so?

css clip-path border
clip-path background-color
css clip-path tutorial
css clip-path border-radius
css polygon background
clip-path: polygon explained
css clip-path not working in ie
css shapes

I have a parent and a child div with ids and dimensions as described in the following diagram:

<div id="clip"> 
  <div id="page"> 
     <!-- Content/Images here -->
  </div>
</div>

The dimensions of the parent and child divs are like so:

#clip {
  height: 1000px;
  width: 1414px;
}

#page {
  height: 1000px;
  width: 707px; 
}

Now I want to skew a side off from the child div at an angle ø and clip the right side of the div, like so:

Is it possible to do so with CSS alone?

Constraints: Cannot use the triangular border hack, the content inside the #page child div cannot be skewed, and the less hack-ey the solution, the better it is for everything. I was hoping this could be done with just CSS3 transformations but I couldn't find a way so far.

Answer by @ksav is close but it is still using obscuration technique with a pseudo :before element with absolute position. It doesn't let me disappear the clipped part of div#page so that it can look something like this:


You can use -webkit-clip-path

#clip {
  height: 1000px;
  width: 1414px;
  background-color: yellow;
}

#page {
  height: 1000px;
  width: 707px; 
  background-color: blue;
  color: white;
  -webkit-clip-path: polygon(0 0, 40% 0, 29% 100%, 0% 100%);
} 

Here is an example: https://codepen.io/rollinglex/pen/ZMNvjY

I found this site to be vey useful: https://bennettfeely.com/clippy/

regarding using js and css, this article should help: https://eager.io/blog/communicating-between-javascript-and-css-with-css-variables/

javascript, Now I want to skew a side off from the child div at an angle ø and clip the right side of the div , like so: clipped page. Is it possible to do so with  I'm looking to "cut" the top left corner of a div, like if you had folded the corner of a page down. I'd like to do it in pure CSS, are there any methods? If the parent element has a solid color background, you can use pseudo-elements to create the effect: The upcoming border-corner-shape is exactly what you're looking for.


div{
  width:50%;
  height:100%;
  position: absolute;
  border: 1px solid black;
}
#parent{
  background: #fff333;
}
#child{
  background: #aaaccc;
  left: 30%;
  transform: skewX(-8deg);
}
<div id="parent">

</div>
<div id="child">
  
</div>

Clipping and Masking in CSS, So the final result will be an element that fades in from left to right. The first presence of clipping in CSS (other than overflow: hidden; trickery) was to make all sides the same, or 2 values (vert/horz), or 3 values (top/horz/bottom). Here's an example two ways. You can also link up an entire SVG file as the mask, like: While transform: skewX(20deg) will successfully rotate the two vertical sides of a box container (like div, span, a, etc.) by 20 degrees without affecting the horizontal ones, is it possible -- using only CSS -- to slant only ONE side this way? (The answer is probably no, based on all my findings, I'm just seeking confirmation.)


.content {
  background: grey;
  position: relative;
 height: 1000px;
  width: 707px; 
}

.content:before {
  background: rgba(255, 255, 255, 0.8);
  position: absolute;
  height: 100%;
  width: 110%;
  transform: skewX(-5deg) translateX(10%);
  transform-origin: bottom left;
  content:'';
}
<div class="content">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras imperdiet congue aliquam. Etiam efficitur lectus id nulla iaculis dapibus. Phasellus nec nisl bibendum, hendrerit diam at, consequat est. In posuere lorem eget felis venenatis elementum.
    Ut vestibulum a nulla commodo pharetra. Cras accumsan dui a libero faucibus rutrum. Integer sed nunc accumsan, convallis lectus venenatis, iaculis arcu. Pellentesque tincidunt purus eu pulvinar tempus. Nam aliquet orci vel sapien condimentum pharetra.
    In rhoncus vehicula metus, vitae euismod mauris consequat sit amet. Praesent suscipit quam libero, eget semper neque aliquet faucibus.</p>
</div>

Clipping Content Using the overflow CSS Property, Learn how to use the overflow CSS property to keep your normal and absolutely the result of content getting clipped inside the container Notice what your example looks like now: content In the example you saw here, the width and height of our div was fixed to 350 pixels and 200 pixels respectively. Using css transforms on the other hand would mean you'd have to have your shape divs in the background, then layer the actual text over them in another element to that the text isn't skewed as well. Again, browser support isn't guaranteed.


clip, The clip CSS property defines what portion of an element is visible. Note: Where possible, authors are encouraged to use the newer clip-path property instead. If any side's value is auto , the element is clipped to that side's inside border edge. If you'd like to contribute to the data, please check out  Clipping. Think about <clipPath> in SVG (or clip-path in CSS) as a way to cut a shape out of another shape. There’s no concept of opacity, or alpha channel, to gray area here. Parts of the element with a clipping path applied are literally visible or not visible. Clipping just uses the geometry of the shape.


background-clip, The background-clip CSS property sets whether an element's background extends underneath its border box, padding box, or content box. This can be done using svg clip-path. Advantages: Work with a regular div; No hacky borders to create shapes; Do not apply any rotation so that you can easily do it on non uniform background; Does not add any div element through CSS so that you can still work with the regular div background (in case you have code modifying it for example!)


CSS clip property, The rectangle is specified as four coordinates, all from the top-left corner of the element to be clipped. Note: The clip property does not work if "overflow:visible". The clip CSS property defines what portion of an element is visible. The clip property applies only to absolutely positioned elements, that is elements with position:absolute or position:fixed.