Skip to content

block alignment

garevna edited this page Sep 1, 2019 · 7 revisions

Выравнивание блока по центру экрана

1

<body>
    <div class="box"></div>
</body>
.box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #000;
    color: #fff;
    width: 300px;
    height: 200px;
}

2

<body>
    <div class="box">
        <div class="content"></div>
    </div>
</body>
.box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    width: 300px;
    height: 200px;
}
.box > .content {
    position: absolute;
	background: #000;
    top: 20px;
    bottom: 10px;
    box-sizing: border-box;
    left: -30px;
    width: calc(100% + 60px);
}

.box:before, .box:after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
}
.box:before {
    border-top: 10px solid #f50;
    border-left: 10px solid #f50;
}
.box:after {
    border-bottom: 10px solid #f50;
    border-right: 10px solid #f50;
}

3

~~~css .box { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #fff; width: 300px; height: 200px; transform-style: preserve-3d; transition: 0.5s ease; } .box > .content { position: absolute; background: #000; top: 20px; bottom: 10px; box-sizing: border-box; left: -30px; width: calc(100% + 60px); transition: 0.5s ease; }

.box:before, .box:after { content: ""; position: absolute; width: 100%; height: 100%; } .box:before { border-top: 10px solid #f50; border-left: 10px solid #f50; } .box:after { border-bottom: 10px solid #f50; border-right: 10px solid #f50; }

.box:hover { transform: translate(-50%, -50%) rotateY(-3deg) skew(-20deg); } .box:hover > .content { transform: rotateY(6deg) skew(40deg) translate(-10px); }

© Irina H.Fylyppova 2019



Занятие 1


Занятие 2


Занятие 3


Занятие 4


Занятие 5


Занятие 6


Занятие 7


Занятие 8


Дополнительно

Clone this wiki locally