How can I make the image "normal" in a slanted div?


Wiski

So I want to make a diamond with an image, but the image is distorted. I am going to make it level (normal) and fill with diamonds.

code I wrote .

.diamond {
  width: 300px;
  height: 300px;
  border: 3px solid white;
  outline: 2px solid black;
  outline-offset: 20px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(67.5deg) skewX(45deg) scaleY(0.70711);
  overflow: hidden;
}

.diamond-image {
  background-image: url("https://images7.alphacoders.com/108/1082408.png");
  background-size: cover;
  position: absolute;
  height: 100%;
  width: 140%;
  top: 0px;
  left: 0px;
  transform-origin: top bottom;
}

html{
    height: 100%;
}

body{
    background: rgb(224,215,215);
    background: radial-gradient(circle, rgba(224,215,215,1) 0%, rgba(144,144,144,1) 100%);
}
<div class="diamond">
  <div class="diamond-image"></div>
</div>

Accompanying Afif

Reversing transformations can be complicated. Without the conversion, I would have built it differently.

You can simply control the shape by adjusting the width/height and CSS variables

html{
  min-height: 100%;
  background: radial-gradient(circle, rgba(224,215,215,1) 0%, rgba(144,144,144,1) 100%);
}

.box {
  --d:15px; /* gap between border and outline*/
  --b1:3px; /* width of outline (black)*/
  --b2:3px; /* width of border  (white) */

  --g1:transparent calc(48% - var(--d) - var(--b1) - var(--b2)) ,
       #fff        calc(49% - var(--d) - var(--b1) - var(--b2)) calc(49% - var(--b1)),
       #000        calc(50% - var(--b1));
  
  --g2:#fff       calc(48.5% - var(--d) - var(--b1) - var(--b2)) calc(48.5% - var(--d) - var(--b1)),
      transparent calc(49% - var(--d) - var(--b1)) calc(49% - var(--b1)),
      #fff        calc(49.5% - var(--b1)) 49.5%,
      transparent 50%;
  width:200px;
  height:400px;
  display:inline-block;
  vertical-align:top;
  background: 
    linear-gradient(to top    right,var(--g1)) top right    / 50% 50%,
    linear-gradient(to top    left ,var(--g1)) top left     / 50% 50%,
    linear-gradient(to bottom right,var(--g1)) bottom right / 50% 50%,
    linear-gradient(to bottom left ,var(--g1)) bottom left  / 50% 50%,
    url(https://picsum.photos/id/1074/800/800) center/cover;
  background-repeat:no-repeat;
  
  -webkit-mask: 
    linear-gradient(to top    right,var(--g2)) top right,
    linear-gradient(to top    left ,var(--g2)) top left,
    linear-gradient(to bottom right,var(--g2)) bottom right,
    linear-gradient(to bottom left ,var(--g2)) bottom left;
  -webkit-mask-size:50% 50%;
  -webkit-mask-repeat:no-repeat;
  mask: 
    linear-gradient(to top    right,var(--g2)) top right,
    linear-gradient(to top    left ,var(--g2)) top left,
    linear-gradient(to bottom right,var(--g2)) bottom right,
    linear-gradient(to bottom left ,var(--g2)) bottom left;
  mask-size:50% 50%;
  mask-repeat:no-repeat;
}
<div class="box"></div>
<div class="box" style="width:300px;--b1:5px;--d:20px"></div>
<div class="box" style="height:200px;--b2:5px;--d:5px"></div>

CSS slanted image inside slanted container (diamond shape)

Related


How can I make the image "normal" in a slanted div?

Wiski So I want to make a diamond with an image, but the image is distorted. I am going to make it level (normal) and fill with diamonds. code I wrote . .diamond { width: 300px; height: 300px; border: 3px solid white; outline: 2px solid black; outlin

How can I make the image "normal" in a slanted div?

Wiski So I want to make a diamond with an image, but the image is distorted. I am going to make it level (normal) and fill with diamonds. code I wrote . .diamond { width: 300px; height: 300px; border: 3px solid white; outline: 2px solid black; outlin

How can I make the image "normal" in a slanted div?

Wiski So I want to make a diamond with an image, but the image is distorted. I am going to make it level (normal) and fill with diamonds. code I wrote . .diamond { width: 300px; height: 300px; border: 3px solid white; outline: 2px solid black; outlin

How can I make the image "normal" in a slanted div?

Wiski So I want to make a diamond with an image, but the image is distorted. I am going to make it level (normal) and fill with diamonds. code I wrote . .diamond { width: 300px; height: 300px; border: 3px solid white; outline: 2px solid black; outlin

How can I make the image "normal" in a slanted div?

Wiski So I want to make a diamond with an image, but the image is distorted. I am going to make it level (normal) and fill with diamonds. code I wrote . .diamond { width: 300px; height: 300px; border: 3px solid white; outline: 2px solid black; outlin

Make image inside slanted div normal

Muhammad As in the question below. I'm trying to make content, in this case it's an image inside a div that should be skewed. In other words, the div should be skewed and the image inside should not be skewed. I am using: -ms-transform: skew(-15deg, 0deg); -we

How can I dock the slanted div to the above div?

random dude I'm trying to add a div to another div so that its top border doesn't move when it is tilted. HTML code: <div class="Container"> <div class="Main"> </div> <div class="Shadow"></div> </div> CSS code: .Shadow { height:70px; wid

How can I make my vscode fonts slanted like sublime?

Qiwei Wang I'm using the same font (Consolas) in VScode and sublime . But it doesn't look the same in the same place: Here is my sublime setup: { "auto_complete_selector": "source,text", "color_scheme": "Packages/Material Theme/schemes/Material-Theme-D

How can I create a slanted slanted header text next to it?

Jarcena .image { min-height: 100vh; } .bg-image { background-image: url('https://picsum.photos/1440/900'); background-size: cover; background-position: center; } <!--About Us --> <div class="container-fluid"> <div class="row no-gutter"> <div cla

How can I create a slanted slanted header text next to it?

Jarcena .image { min-height: 100vh; } .bg-image { background-image: url('https://picsum.photos/1440/900'); background-size: cover; background-position: center; } <!--About Us --> <div class="container-fluid"> <div class="row no-gutter"> <div cla

How can I create a slanted slanted header text next to it?

Jarcena .image { min-height: 100vh; } .bg-image { background-image: url('https://picsum.photos/1440/900'); background-size: cover; background-position: center; } <!--About Us --> <div class="container-fluid"> <div class="row no-gutter"> <div cla

How can I create a slanted slanted header text next to it?

Jarcena .image { min-height: 100vh; } .bg-image { background-image: url('https://picsum.photos/1440/900'); background-size: cover; background-position: center; } <!--About Us --> <div class="container-fluid"> <div class="row no-gutter"> <div cla

How can I make my image DIV bigger in a scrollable div?

Paula I have a horizontal scrolling one divthat I have squared divs. I need to make these squares divsbigger, but I can't do it. In the example I provide here, there are 3 squared divs. Every time I add a new one, they get smaller. How can I prevent them from

How can I make the image overlap to the next div below it?

same logan How do you make the image overlap to the next div below it? If you didn't get my description, this is the function I want. Click here This is what I have so far HTML: <p>overflow:hidden</p> <div class="hidden">You can use the overflow property when

How can I make the image take the full size of the DIV?

Paula I've created a custom "product card" for my website, and I want the images to take the full width and height of the parent regardless of the dimensions of the images. I've tried it max-width min-width max-height min-height, but none seem to work. I can't

How can I make a div clickable over the entire background image?

Vignesh Pichamani I added a background image to the parent divdiv width and 100%I redirect when you click on the div (everything works), but I only want to redirect the div when you click from left to right. 100px;For example, here is a fiddle I call a div wit

How can I make a div clickable over the entire background image?

Vignesh Pichamani I added a background image to the parent divdiv width and 100%I redirect when you click on the div (everything works), but I only want to redirect the div when you click from left to right. 100px;For example, here is a fiddle I call a div wit

How can I make the image fill the remaining space inside the div?

Jason I have a <div>window that takes up 60% of the space and it contains two things: narrow header row I want an image that occupies the rest of the div. How to do this with pure CSS (no Javascript)? I've been trying a lot of things with no luck. This is the

How can I make the image take the full size of the DIV?

Paula I've created a custom "product card" for my website, and I want the images to take the full width and height of the parent regardless of the dimensions of the images. I've tried it max-width min-width max-height min-height, but none seem to work. I can't

How can I make the image appear in the container Div?

username In simple terms, I have a javascript code that generates random images when the user clicks a button. It's a blank page with a button and a container div. The problem is that the image appears outside the container, directly before. and I need to cont

How can I make a div clickable over the entire background image?

Vignesh Pichamani I added a background image to the parent divdiv width and 100%I redirect when you click on the div (everything works), but I only want to redirect the div when you click from left to right. 100px;For example, here is a fiddle I call a div wit

How to create a slanted SVG image with slanted text

very cool I am trying to create a slanted image in svg with slanted text as shown in the image below I tried to create the same format but couldn't create the same design as the overall text display, you can also see the columns below attached horizontally dow

Make slanted elements on an image transparent

Benjamin Treadwell I've tried following the guide on Youtube for help and I can get it to work - kinda. I'm trying to place two divs in a section where the top is to place the image and the bottom is to place the text etc. What I want is a slanted razor blade