Element width increases with height

I used CSS : before and : after to create a document that looks like a layout with a div. This is good, but the width increases as the height increases. I tried max-width but to no avail. Any ideas on how this can be prevented.

HTML

<div class="rack"></div><!-- End Rack -->

CSS

.rack {
    width: 70%;
    height: 100%;
    background: #7FAE68;
    margin: -255px 0 100px 0;
    position: relative;
    float: left;
    left: 15%;
    z-index: 9999;
    transform:rotate(1deg);
    -ms-transform:rotate(1deg);
    -webkit-transform:rotate(1deg);
    padding-bottom:50px;
}
 .rack::before {
 content: "";
 background:  #E1BB70;
 position: absolute;
 height: 100%;
 width: 100%;
 z-index: -2;
 transform:rotate(1deg);
 -ms-transform:rotate(1deg);
 -webkit-transform:rotate(1deg);
 float: left;
 left: 0%;
}
 .rack::after {
 content: "";
 background: #E5E8EC;
 position: absolute;
 height: 100%;
 width: 100%;
 z-index: -1;
 transform:rotate(-1deg);
 -ms-transform:rotate(-1deg);
 -webkit-transform:rotate(-1deg);
 border: solid 1px #ddd;
 left: 0%;
}

Before height increase enter image description here

After height increase enter image description here

jsfiddle link

Double content in the violin to witness the problem.

+1
source share
1 answer

Add the following css to each class:

box-sizing:border-box

here is the fiddle: http://jsfiddle.net/npGy8/31/

Hope this helps.

0

Source: https://habr.com/ru/post/1547040/


All Articles