Слайдшоу на CSS3
Красивое слайдшоу на чистом CSS с различными эффектами.
Как использовать:
1. Html код
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<div class="block image1"> <div class="layer"></div> <div class="p-container"> <p class="img-p"> Description 1 </p> </div> </div> <div class="block image2"> <div class="layer"></div> <div class="p-container"> <p class="img-p"> Description 2 </p> </div> </div> <div class="block image3"> <div class="layer"></div> <div class="p-container"> <p class="img-p"> Description 3 </p> </div> </div> |
2. Код CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
.block { width: 10%; height: 300px; display: inline-block; background-color: #E83F6F; cursor: pointer; position: relative; -webkit-transition: width .5s ease-in-out, background-color .5s ease-in-out; -moz-transition: width .5s ease-in-out, background-color .5s ease-in-out; -ms-transition: width .5s ease-in-out, background-color .5s ease-in-out; -o-transition: width .5s ease-in-out, background-color .5s ease-in-out; transition: width .5s ease-in-out, background-color .5s ease-in-out; text-align: center; } .block:hover { background-color: #2274A5; width: 30%; -webkit-transition: width .5s ease-in-out, background-color .5s ease-in-out; -moz-transition: width .5s ease-in-out, background-color .5s ease-in-out; -ms-transition: width .5s ease-in-out, background-color .5s ease-in-out; -o-transition: width .5s ease-in-out, background-color .5s ease-in-out; transition: width .5s ease-in-out, background-color .5s ease-in-out; } .block:hover .img-p { opacity: 1; -webkit-transition: opacity .5s .51s ease-in-out; -moz-transition: opacity .5s .51s ease-in-out; -ms-transition: opacity .5s .51s ease-in-out; -o-transition: opacity .5s .51s ease-in-out; transition: opacity .5s .51s ease-in-out; } .block:hover .layer { opacity: .5; -webkit-transition: opacity .5s ease-in-out; -moz-transition: opacity .5s ease-in-out; -ms-transition: opacity .5s ease-in-out; -o-transition: opacity .5s ease-in-out; transition: opacity .5s ease-in-out; } .layer { position: absolute; left: 0; top: 0; bottom: 0; right: 0; background-color: #000; width: 100%; height: 100%; opacity: 0; } .img-p { position: absolute; font-size: 16px; opacity: 0; color: #FFF; text-align: left; line-height: 1.6em; } .p-container { width: 80%; position: relative; top: 35%; margin-left: 5%; } .image1 { background-image: url(1.jpg); -webkit-background-size: cover; -o-background-size: cover; background-size: cover; background-repeat: no-repeat; background-position: center center; } .image2 { background-image: url(2.jpg); -webkit-background-size: cover; -o-background-size: cover; background-size: cover; background-repeat: no-repeat; background-position: center center; } .image3 { background-image: url(3.jpg); -webkit-background-size: cover; -o-background-size: cover; background-size: cover; background-repeat: no-repeat; background-position: center center; } @media (max-width: 768px) { .block { width: 100%; height: 200px; -webkit-transition: height .5s ease-in-out; -moz-transition: height .5s ease-in-out; -ms-transition: height .5s ease-in-out; -o-transition: height .5s ease-in-out; transition: height .5s ease-in-out; } .block:hover { width: 100%; height: 400px; -webkit-transition: height .5s ease-in-out; -moz-transition: height .5s ease-in-out; -ms-transition: height .5s ease-in-out; -o-transition: height .5s ease-in-out; transition: height .5s ease-in-out; } } @media (min-width: 768px) { .block { width: 15%; } } @media (min-width: 992px) { .block { width: 10%; } } |