How can I "unskew" the background image?

Asked

Viewed 64 times

2

Good morning, I am no expert on this and I am tired of looking for a solution to counter the skew given to the main container. Basically all the solutions that I have been able to understand so far do not solve.

The elements on top of the image I managed through css to make the skew Transform contrary to the main container and everything was ok, but I can not do the same to the background image that is being called in control (since this does not have a direct path, it has a relationship with folders to which it will fetch this image).

ASP.NET

divBedroomContainer.Attributes.Add("style", "background-image: url(" + trimmedFolder + trimmedBedroom + ".jpg)");

CSS

.Bedrooms {
    -webkit-backface-visibility: hidden;
    -webkit-transform: skewY(-2.7deg);
    transform: skewY(-2.7deg);
    outline: 1px solid transparent;
}
.BedroomContainer {
    float: left;
    width: 33.3334%;
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
    height: 400px;
    text-align: center;
    overflow: hidden;
}

inserir a descrição da imagem aqui

  • Hello Mojo good morning, welcome to Stackoverflow. Post the css code of the part that has had difficulties, if I can help I will certainly help, if not the other one that could help you. I recommend a read on tour to understand a little more how things work around here.

  • Hello Marconi, thanks for the help, I will consult as soon as I can. .

1 answer

0

According to a solution I found in the American Stack, you could use the background image in a pseudo-element and appropriate the transform-origin to solve your problem.

I don’t have full access to your code, but I think you can work on that idea:

.Bedrooms {
    -webkit-backface-visibility: hidden;
    transform: skewY(-2.7deg);
    -ms-transform: skewY(-2.7deg);
    -webkit-transform: skewY(-2.7deg);
    outline: 1px solid transparent;

/* novos estilos */
    position: relative;
    overflow: hidden;
    -webkit-transform-origin: top left;
    -ms-transform-origin: top left;
    transform-origin: top left;
}

.Bedrooms::before {
    content: "";
    transform: skewX(2.7deg); 
    -ms-transform: skewX(2.7deg); /* IE 9 */
    -webkit-transform: skewX(2.7deg); /* Safari e Chrome */
    background-image: url('#suafoto'); 
    background-repeat: no-repeat; 
    background-position: top left; 

    position: absolute;
    -webkit-transform-origin: top left;
    -ms-transform-origin: top left;
    transform-origin: top left;
    width: 1000%; /* algo gigante */
    height: 1000%; /* algo gigante */
}

Good luck there!

  • Thank you so much. I’m going to try... I’m not a designer, so I still have some difficulty making myself understood. But I’m taking the first steps, I’m going to talk to Veloper from here (who hasn’t been able to find a solution yet) to see if he can help me with this option. Thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.