carousel.css 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. * {
  2. margin: 0;
  3. padding: 0;
  4. }
  5. @media screen and (max-width: 768px) and (min-width: 200px) {
  6. div img{
  7. max-width: 100%;
  8. }
  9. .carousel a {
  10. list-style: none;
  11. }
  12. .carousel li {
  13. list-style: none;
  14. display: flex;
  15. width: 100%;
  16. justify-content: center;
  17. align-items: center;
  18. }
  19. .carousel {
  20. width: 100%;
  21. }
  22. .carousel .content {
  23. height: 300px;
  24. margin: 0 auto 0;
  25. position: relative;
  26. }
  27. .carousel #item {
  28. width: 100%;
  29. height: 100%;
  30. }
  31. .carousel .item {
  32. width: 100%;
  33. position: absolute;
  34. opacity: 0;
  35. transition: all 1s;
  36. overflow: hidden;
  37. }
  38. .carousel .item.active {
  39. opacity: 1;
  40. }
  41. .carousel img {
  42. /*width: 100%;*/
  43. height: 300px;
  44. }
  45. .carousel #btn-left {
  46. width: 30px;
  47. height: 69px;
  48. font-size: 30px;
  49. color: white;
  50. box-shadow: white 0 0 5px;
  51. background-color: rgba(0, 0, 0, 0.65);
  52. line-height: 69px;
  53. padding-left: 5px;
  54. z-index: 10; /*始终显示在图片的上层*/
  55. position: absolute;
  56. left: 40px;
  57. top: 50%;
  58. transform: translateY(-60%); /*使按钮向上偏移居中对齐*/
  59. cursor: pointer;
  60. user-select: none;
  61. border-radius: 8px;
  62. transition: opacity 0.3s ease-in-out, background-color 0.3s ease-in-out;
  63. }
  64. #btn-left:hover {
  65. background-color: rgba(0, 0, 0, 0.65);
  66. }
  67. .carousel #btn-right {
  68. border-radius: 8px;
  69. user-select: none;
  70. width: 26px;
  71. height: 69px;
  72. font-size: 30px;
  73. color: white;
  74. box-shadow: white 0 0 5px;
  75. background-color: rgba(0, 0, 0, 0.65);
  76. line-height: 69px;
  77. padding-left: 5px;
  78. z-index: 10;
  79. position: absolute;
  80. right: 40px;
  81. top: 50%;
  82. cursor: pointer;
  83. transform: translateY(-60%);
  84. transition: opacity 0.3s ease-in-out, background-color 0.3s ease-in-out;
  85. }
  86. .carousel #circle {
  87. height: 20px;
  88. display: flex;
  89. position: absolute;
  90. bottom: 5px;
  91. left: calc(50% - 50px);
  92. align-items: center;
  93. padding-bottom: 1px;
  94. border-radius: 10px;
  95. }
  96. .carousel .circle {
  97. width: 10px;
  98. height: 10px;
  99. border-radius: 10px;
  100. /*border: 2px solid white;*/
  101. background: rgba(0, 0, 0, 0.4);
  102. box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  103. cursor: pointer;
  104. margin: 5px;
  105. }
  106. .carousel .white {
  107. background-color: #FFFFFF;
  108. }
  109. }
  110. @media all and (min-width: 768px) {
  111. .carousel a {
  112. list-style: none;
  113. }
  114. .carousel li {
  115. list-style: none;
  116. display: flex;
  117. width: 100%;
  118. justify-content: center;
  119. align-items: center;
  120. }
  121. .carousel {
  122. width: 100%;
  123. }
  124. .carousel .content {
  125. height: 300px;
  126. margin: 0 auto 0;
  127. position: relative;
  128. }
  129. .carousel #item {
  130. width: 100%;
  131. height: 100%;
  132. }
  133. .carousel .item {
  134. width: 100%;
  135. position: absolute;
  136. opacity: 0;
  137. transition: all 1s;
  138. overflow: hidden;
  139. }
  140. .carousel .item.active {
  141. opacity: 1;
  142. }
  143. .carousel img {
  144. /*width: 100%;*/
  145. height: 300px;
  146. }
  147. .carousel #btn-left {
  148. width: 30px;
  149. height: 69px;
  150. font-size: 30px;
  151. color: white;
  152. background-color: rgba(0, 0, 0, 0.4);
  153. line-height: 69px;
  154. padding-left: 5px;
  155. z-index: 10; /*始终显示在图片的上层*/
  156. position: absolute;
  157. left: 40px;
  158. top: 50%;
  159. transform: translateY(-60%); /*使按钮向上偏移居中对齐*/
  160. cursor: pointer;
  161. opacity: 0; /*平时隐藏*/
  162. user-select: none;
  163. border-radius: 8px;
  164. transition: opacity 0.3s ease-in-out, background-color 0.3s ease-in-out;
  165. }
  166. .carousel:hover #btn-left {
  167. /*鼠标滑入,显示图标*/
  168. opacity: 1;
  169. }
  170. #btn-left:hover {
  171. background-color: rgba(0, 0, 0, 0.65);
  172. }
  173. .carousel #btn-right {
  174. border-radius: 8px;
  175. user-select: none;
  176. width: 26px;
  177. height: 69px;
  178. font-size: 30px;
  179. color: white;
  180. background-color: rgba(0, 0, 0, 0.4);
  181. line-height: 69px;
  182. padding-left: 5px;
  183. z-index: 10;
  184. position: absolute;
  185. right: 40px;
  186. top: 50%;
  187. cursor: pointer;
  188. opacity: 0;
  189. transform: translateY(-60%);
  190. transition: opacity 0.3s ease-in-out, background-color 0.3s ease-in-out;
  191. }
  192. .carousel:hover #btn-right {
  193. opacity: 1;
  194. }
  195. #btn-right:hover {
  196. background-color: rgba(0, 0, 0, 0.65);
  197. }
  198. .carousel #circle {
  199. height: 20px;
  200. display: flex;
  201. position: absolute;
  202. bottom: 5px;
  203. left: calc(50% - 50px);
  204. align-items: center;
  205. padding-bottom: 1px;
  206. border-radius: 10px;
  207. }
  208. .carousel .circle {
  209. width: 10px;
  210. height: 10px;
  211. border-radius: 10px;
  212. /*border: 2px solid white;*/
  213. background: rgba(0, 0, 0, 0.4);
  214. box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  215. cursor: pointer;
  216. margin: 5px;
  217. }
  218. .carousel .white {
  219. background-color: #FFFFFF;
  220. }
  221. }