Шестиугольная рамка для картинки на CSS

19.11.2020

Пример того, как сделать шестиугольную рамку для фотографий на чистом CSS.

pic1

 
.hexagon {
    overflow: hidden;
    visibility: hidden;
    transform: rotate(120deg);
    cursor: pointer;
    
    display: inline-block;
}
 
.hexagon-in1 {
    overflow: hidden;
    width: 100%;
    height: 100%;
    transform: rotate(-60deg);
}
 
.hexagon-in2 {
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-position: 50%;
    background-image: url(http://placekitten.com/241/242);
    visibility: visible;
    transform: rotate(-60deg);
}
 
.hexagon2 {
    width: 200px;
    height: 400px;
    margin-top: -80px;
}

.row2 {
    margin-left: 100px;
    margin-top: -140px;
}

 
    <div class="row1">
        <div class="hexagon hexagon2">
            <div class="hexagon-in1">
                <div class="hexagon-in2"></div>
            </div>
        </div>
        <div class="hexagon hexagon2">
            <div class="hexagon-in1">
                <div class="hexagon-in2"></div>
            </div>
        </div>
        <div class="hexagon hexagon2">
            <div class="hexagon-in1">
                <div class="hexagon-in2"></div>
            </div>
        </div>
    </div>
    <div class="row2">
        <div class="hexagon hexagon2">
            <div class="hexagon-in1">
                <div class="hexagon-in2"></div>
            </div>
        </div>
        <div class="hexagon hexagon2">
            <div class="hexagon-in1">
                <div class="hexagon-in2"></div>
            </div>
        </div>
        <div class="hexagon hexagon2">
            <div class="hexagon-in1">
                <div class="hexagon-in2"></div>
            </div>
        </div>
    </div>


Категории: CSS
Пометки: Hexagon на CSS
Яндекс.Метрика