• I’m trying to add HTML wrappers around a block to create a clipping effect, something like the below. Not sure if this is possible and where the code would go? It has been suggested this might be possible with the block save or block edit functions? Your help would be much appreciated, I’m going grey trying to figure it out!

    <div class="transform-containter">
    <div class="transform-right">
    <div class="transform-left">
    <div class="transform-content">
    <div class="block-container">
    BLOCK CONTENT HERE
    </div>
    </div>
    </div>
    </div>
    </div>

    PS I’m not a developer, I’m pretty good with HTML, CSS and a little PHP, but completely green when it comes to Javascript/React…

Viewing 7 replies - 1 through 7 (of 7 total)
  • Are you using a clip-path to assign to your element?

    example:

    .element{
      clip-path: rect(10px, 20px, 30px, 40px);
    }
    Thread Starter bearandpear

    (@bearandpear)

    No, as I need cross-browser support. SVG also does not work for what I am trying to achieve.

    I am essentially using four divs (maybe a little overkill)—two with rotate css transforms and two containers—to create a trapezoid in which background images/videos will be clipped.

    HTML:

    <div class="transform-containter">
    <div class="transform-right">
    <div class="transform-left">
    <div class="transform-content">
    <div class="block-container">
    BLOCK CONTENT HERE
    </div>
    </div>
    </div>
    </div>
    </div>

    CSS:

    .transform-containter {
    	width: 100%;
    	height: auto;
    	margin-top: 0;
    	overflow-x: hidden;
    	overflow-y: hidden;
    }
    .transform-right {
    	position: relative;
    	width: 110%;
    	height: 100%;
    	top: 0;
    	left: -5%;
    	-webkit-transform: rotate(2deg);
    	-moz-transform: rotate(2deg);
    	-ms-transform: rotate(2deg);
    	-o-transform: rotate(2deg);
    	transform: rotate(2deg);
    	overflow: hidden;
    	margin-top:2.5%;
    }
    .transform-left {
    	position: relative;
    	width: 110%;
    	height: 100%;
    	left: -5%;
    	-webkit-transform: rotate(-4deg);
    	-moz-transform: rotate(-4deg);
    	-ms-transform: rotate(-4deg);
    	-o-transform: rotate(-4deg);
    	transform: rotate(-4deg);
    	overflow: hidden;
    	margin-top: -4%;
    	margin-bottom: 3.5%;
    }
    .transform-content {
    	width: 100%;
    	height: 100%;
    	-webkit-transform: rotate(2deg);
    	-moz-transform: rotate(2deg);
    	-ms-transform: rotate(2deg);
    	-o-transform: rotate(2deg);
    	transform: rotate(2deg);
    	background-color: #cccccc;
    	background-position: center;
    	background-repeat: no-repeat;
    	background-size: cover;
    	margin: 2% 0 -2% 0;
    	padding: 2em 10%;
    }
    Thread Starter bearandpear

    (@bearandpear)

    So I want to be able to add this before the ‘block’:

    <div class="transform-containter">
    <div class="transform-right">
    <div class="transform-left">
    <div class="transform-content">

    And this after:

    </div>
    </div>
    </div>
    </div>

    I remember an article from a couple of years ago. Let me try and find it. See if it will help you.

    ah, I found it. Not sure if it helps you.
    https://css-tricks.com/clipping-masking-css/

    Thread Starter bearandpear

    (@bearandpear)

    Thank you so much for sending this over @serafinnyc, very interesting and comprehensive guide to clipping and masking.

    I have done a fair bit of experimenting with CSS clip-path and SVG clipPath and unfortunately they will not work for what I am trying to achieve. CSS clip-path would be PERFECT, but I need cross-browser support.

    The sightly ‘hacky’ way of using CSS transforms I have suggested above seems to work on all modern browsers, but I just don’t know how to add the extra HTML to a gutenberg block.

    You’re welcome. Chris is very good. He had a great teacher. ;0)

    Fun stuff. Maybe try HTML5 now. LOL Even more fun!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Wrap block ‘div’ in other elements’ is closed to new replies.