Можно ли этот эффект получить на css?
Можно ли не применяя clip-path css получить такой же эффект как в этом svg ?
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewbox='0 0 640 480'
preserveAspectRatio="none" >
<defs>
<mask id="mask">
<rect fill="#555552" width="640px" height="480px" />
<g style="fill:white;">
<rect x="20px" y="20px" width="100px" height="100px" />
<rect x="140px" y="20px" width="100px" height="100px" />
<rect x="260px" y="20px" width="100px" height="100px" />
<rect x="20px" y="140px" width="100px" height="100px" />
<rect x="140px" y="140px" width="100px" height="100px" />
<rect x="260px" y="140px" width="100px" height="100px" />
<rect x="20px" y="260px" width="100px" height="100px" />
<rect x="140px" y="260px" width="100px" height="100px" />
<rect x="260px" y="260px" width="100px" height="100px" />
</g>
</mask>
</defs>
<g>
<rect fill="#000" width="640px" height="480px" />
<image xlink:href="//i.stack.imgur.com/7fqK5.jpg"
width="640px"
height="480px"
style="mask:url(#mask);"/>
</g>
</svg>
Ответы (5 шт):
Автор решения: Firsov36
→ Ссылка
Что-то вроде такого:
.pomidori {
background-image:
url('https://i.artfile.ru/1600x1200_343377_[www.ArtFile.ru].jpg'),
repeating-linear-gradient(0deg,
rgba(0,0,0,.5) 0px, rgba(0,0,0,.5) 10px,
white 10px, white 40px
),
repeating-linear-gradient(-90deg,
rgba(0,0,0,.5) 0px, rgba(0,0,0,.5) 10px,
white 10px, white 40px
);
background-size: auto 100%;
background-position:0 0, 5px 5px;
background-blend-mode: multiply;
width: 400px;
height: 350px;
}
<div class="pomidori">
</div>
Автор решения: Stranger in the Q
→ Ссылка
opacity + linear-gradient:
body {
height: 100vh;
background: url(https://i.stack.imgur.com/7fqK5.jpg) no-repeat;
margin:0;
}
div {
height: 200vh;
--lines:
#000 24px, #0000 26px,
#0000 99px, #000 101px,
#000 124px, #0000 126px,
#0000 199px, #000 201px,
#000 224px, #0000 226px,
#0000 299px, #000 301px;
background: linear-gradient( var(--lines)),
linear-gradient(to right, var(--lines));
opacity:0.7;
}
<div>
Автор решения: NeedHate
→ Ссылка
Подход скорее на css трюк похож, но, думаю, из этого можно кое-что и вытянуть:
* {
box-sizing: border-box;
}
html, body {
height: 100%;
}
body {
background-image: url("https://www.thewowstyle.com/wp-content/uploads/2015/07/natural-landscape.jpg");
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
display: -webkit-box;
display: flex;
-webkit-box-align: center;
align-items: center;
}
body:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.wrapper {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 2rem;
align-content: center;
-webkit-box-pack: center;
justify-content: center;
position: relative;
max-width: 1000px;
width: 100%;
margin: 0 auto;
}
.item {
background-image: url("https://www.thewowstyle.com/wp-content/uploads/2015/07/natural-landscape.jpg");
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 200px;
position: relative;
z-index: 1;
}
<div class="wrapper">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
Автор решения: Sevastopol'
→ Ссылка
Решение на чистом CSS без применения clip-path
Плюс бонусом возможность передвигать элементы
$(".mask__1,.mask__2,.mask__3,.mask__4,.mask__5,.mask__6,.mask__7,.mask__8,.mask__9").draggable({containment: "parent"});
* {margin: 0; padding: 0;}
body,html {width: 100%; height: 100%; min-height: 380px;}
.mask__1,.mask__2,.mask__3,.mask__4,.mask__5,.mask__6,.mask__7,.mask__8,.mask__9 {position: absolute; overflow: hidden; width: 100px; height: 100px;}.mask__1 {top: 20px; left: 20px;}.mask__2 {top: 20px; left: 140px;}.mask__3 {top: 20px; left: 260px;}.mask__4 {top: 140px; left: 20px;}.mask__5 {top: 140px; left: 140px;}.mask__6 {top: 140px; left: 260px;}.mask__7 {top: 260px; left: 20px;}.mask__8 {top: 260px; left: 140px;}.mask__9 {top: 260px; left: 260px;}
.mask__1:before,.mask__2:before,.mask__3:before,.mask__4:before,.mask__5:before,.mask__6:before,.mask__7:before,.mask__8:before,.mask__9:before {content: ""; display: block; position: absolute; overflow: hidden; top: 0; left: 0; width: 100%; height: 100%; min-height: 380px; z-index: 1; filter: none; cursor: move; background-image: url(https://s1.1zoom.me/b5050/913/400993-sepik_1920x1200.jpg); background-attachment: fixed !Important; background-repeat: no-repeat; background-size: 100%;}
.masked {position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; min-height: 380px; background-image: url(https://s1.1zoom.me/b5050/913/400993-sepik_1920x1200.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: 100%; filter: brightness(20%);}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="mask__1"></div><div class="mask__2"></div><div class="mask__3"></div><div class="mask__4"></div><div class="mask__5"></div><div class="mask__6"></div><div class="mask__7"></div><div class="mask__8"></div><div class="mask__9"></div>
<div class="masked"></div>
Автор решения: OPTIMUS PRIME
→ Ссылка
Резиновая таблица с полупрозрачными бордерами) border-collapse: collapse на месте стыков создавал темные квадратики, поэтому вместо него использован border-spacing: 0;
Толщина бордеров и количество клеток настраивается через дата-атрибуты.
let wrappers = document.querySelectorAll('.js-table-grid-wrap');
wrappers.forEach(function(wrap) {
wrap.insertAdjacentHTML('beforeEnd', createTableGrid(wrap));
/***/
function createTableGrid(wrap) {
let borderWidth = +wrap.dataset.halfStroke;
let cells = +wrap.dataset.cells || 5;
let rows = +wrap.dataset.rows || 5;
let style = `style="border-width: ${borderWidth}px;"`;
return (
`<table ${style}>` +
("<tr>" +
`<td ${style}></td>`.repeat(cells) +
"</tr>").repeat(rows) +
`</table>`
);
}
});
.js-table-grid-wrap {
position: relative;
display: inline-block;
line-height: 0;
overflow: hidden; /* Если сильно сожмут и пиксельные бордеры окажутся толще дырок */
width: 50%;
--border-color: rgba(0, 0, 0, 0.5);
}
.js-table-grid-wrap table {
height: 100%;
width: 100%;
border-spacing: 0;
border-style: solid;
border-color: var(--border-color);
position: absolute;
top: 0;
left: 0;
}
.js-table-grid-wrap td {
border-style: solid;
border-color: var(--border-color);
padding: 0;
line-height: 0;
}
.js-table-grid-wrap img {
width: 100%;
height: 300px;
}
<div class="js-table-grid-wrap" data-cells="5" data-rows="5" data-half-stroke="12"><img src="http://i.stack.imgur.com/7fqK5.jpg"></div>
P.s. на самом деле тоже сделал бы на repeating-linear-gradient, но он уже предлагался)