I figured out how to implement this task on a single CSS. This solution has its advantages.
Pros:
- Fewer use of resources with quick picture changes
- Smoother animation
- This is pompous cool :)
Minuses:
- Large amount of code
- Implementation difficulty
- Sophisticated size calculations
- There is no flexibility (for new blocks, you need to redo the calculations, and this is paragraph 3 )
- All items and calculations must be specified manually.
Example:
.nav { display: flex; position: relative; width: 100%; justify-content: center; } .nav__item { display: block; position: relative; width: 102px; height: 400px; margin: 10px; background-color: transparent; transform: skewX(-10deg); z-index: 2; } .nav__list { display: flex; position: absolute; left: 0; width:100%; justify-content: center; } .nav__item-bg { display: block; position: relative; width: 102px; height: 400px; margin: 10px; background-color: black; transform: skewX(-10deg); z-index: 1; overflow: hidden; } .nav__item-img { display: block; position: absolute; left: -35px; top: 0; width: calc(100% + 70px); height: 100%; background-size: calc(400% - (35px * 4)) 100%; transform: skewX(10deg); opacity: 0; transition: all 0.3s; } .nav__item-bg:nth-child(1) .nav__item-img { background-position: 0%; } .nav__item-bg:nth-child(2) .nav__item-img { background-position: calc(-100% + 35px); } .nav__item-bg:nth-child(3) .nav__item-img { background-position: calc(-200% + 90px); } .nav__item-bg:nth-child(4) .nav__item-img { background-position: calc(-300% + 135px); } .nav__item-img:nth-child(1) {background-image: url(http://s00.yaplakal.com/pics/pics_original/4/6/8/8310864.jpg)} .nav__item-img:nth-child(2) {background-image: url(http://img1.liveinternet.ru/images/attach/c/6/93/550/93550371_MiosgKjpRqE.jpg)} .nav__item-img:nth-child(3) {background-image: url(http://bm.img.com.ua/nxs/img/prikol/images/large/9/3/309339_889006.jpg)} .nav__item-img:nth-child(4) {background-image: url(http://www.zooclub.ru/skat/img.php?w=700&h=700&img=./attach/7328.jpg)} .nav__item-bg:nth-child(1) .nav__item-img:nth-child(1) {opacity: 1} .nav__item-bg:nth-child(2) .nav__item-img:nth-child(2) {opacity: 1} .nav__item-bg:nth-child(3) .nav__item-img:nth-child(3) {opacity: 1} .nav__item-bg:nth-child(4) .nav__item-img:nth-child(4) {opacity: 1} .nav__item:hover ~ .nav__list > .nav__item-bg .nav__item-img {opacity: 0} .nav__item:nth-child(1):hover ~ .nav__list > .nav__item-bg .nav__item-img:nth-child(1) {opacity: 1} .nav__item:nth-child(2):hover ~ .nav__list > .nav__item-bg .nav__item-img:nth-child(2) {opacity: 1} .nav__item:nth-child(3):hover ~ .nav__list > .nav__item-bg .nav__item-img:nth-child(3) {opacity: 1} .nav__item:nth-child(4):hover ~ .nav__list > .nav__item-bg .nav__item-img:nth-child(4) {opacity: 1} /* ΠΠ½ΠΈΠΌΠ°ΡΠΈΠΈ */ .nav__item-bg:nth-child(2n+2), .nav__item:nth-child(2n+2) { animation: size__type0 10s infinite; } .nav__item-bg:nth-child(2n+1), .nav__item:nth-child(2n+1){ animation: size__type1 10s infinite; } @keyframes size__type0 { from { transform: scale(0.95) skewX(-10deg); } 50% { transform: scale(1) skewX(-10deg); } to { transform: scale(0.95) skewX(-10deg); } } @keyframes size__type1 { from { transform: scale(1) skewX(-10deg); } 50% { transform: scale(0.95) skewX(-10deg); } to { transform: scale(1) skewX(-10deg); } }
<div class="nav"> <!--<ΠΡΠ½ΠΊΡΡ>--> <a href="#" class="nav__item"></a> <a href="#" class="nav__item"></a> <a href="#" class="nav__item"></a> <a href="#" class="nav__item"></a> <!--<Π€ΠΎΠ½Ρ ΠΏΡΠ½ΠΊΡΠΎΠ²>--> <div class="nav__list"> <div class="nav__item-bg"> <div class="nav__item-img"></div> <div class="nav__item-img"></div> <div class="nav__item-img"></div> <div class="nav__item-img"></div> </div> <div class="nav__item-bg"> <div class="nav__item-img"></div> <div class="nav__item-img"></div> <div class="nav__item-img"></div> <div class="nav__item-img"></div> </div> <div class="nav__item-bg"> <div class="nav__item-img"></div> <div class="nav__item-img"></div> <div class="nav__item-img"></div> <div class="nav__item-img"></div> </div> <div class="nav__item-bg"> <div class="nav__item-img"></div> <div class="nav__item-img"></div> <div class="nav__item-img"></div> <div class="nav__item-img"></div> </div> </div> </div>
In this example, I did the inclination, as the author of the question in the example. There is another version with the preservation of the proportions of the background.
Version No. 1 (without preserving background aspect ratio): jsfiddle-1hpps872
Version number 2 (preserving background aspect ratio): jsfiddle-1hpps872-1
Version number 3 (without tilt): jsfiddle-1hpps872-2