carousel.css 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. * {
  2. margin: 0;
  3. padding: 0;
  4. }
  5. .carousel a {
  6. list-style: none;
  7. }
  8. .carousel li {
  9. list-style: none;
  10. display: flex;
  11. width: 100%;
  12. justify-content: center;
  13. align-items: center;
  14. }
  15. .carousel {
  16. width: 100%;
  17. }
  18. .carousel .content {
  19. height: 300px;
  20. margin: 0 auto 0;
  21. position: relative;
  22. }
  23. .carousel #item {
  24. width: 100%;
  25. height: 100%;
  26. }
  27. .carousel .item {
  28. width: 100%;
  29. position: absolute;
  30. opacity: 0;
  31. transition: all 1s;
  32. overflow: hidden;
  33. }
  34. .carousel .item.active {
  35. opacity: 1;
  36. }
  37. .carousel img {
  38. /*width: 100%;*/
  39. height: 300px;
  40. }
  41. .carousel #btn-left {
  42. width: 30px;
  43. height: 69px;
  44. font-size: 30px;
  45. color: white;
  46. background-color: rgba(0, 0, 0, 0.4);
  47. line-height: 69px;
  48. padding-left: 5px;
  49. z-index: 10; /*始终显示在图片的上层*/
  50. position: absolute;
  51. left: 40px;
  52. top: 50%;
  53. transform: translateY(-60%); /*使按钮向上偏移居中对齐*/
  54. cursor: pointer;
  55. opacity: 0; /*平时隐藏*/
  56. user-select: none;
  57. border-radius: 8px;
  58. transition: opacity 0.3s ease-in-out,background-color 0.3s ease-in-out;
  59. }
  60. .carousel:hover #btn-left {
  61. /*鼠标滑入,显示图标*/
  62. opacity: 1;
  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. background-color: rgba(0, 0, 0, 0.4);
  75. line-height: 69px;
  76. padding-left: 5px;
  77. z-index: 10;
  78. position: absolute;
  79. right: 40px;
  80. top: 50%;
  81. cursor: pointer;
  82. opacity: 0;
  83. transform: translateY(-60%);
  84. transition: opacity 0.3s ease-in-out,background-color 0.3s ease-in-out;
  85. }
  86. .carousel:hover #btn-right {
  87. opacity: 1;
  88. }
  89. #btn-right:hover {
  90. background-color: rgba(0, 0, 0, 0.65);
  91. }
  92. .carousel #circle {
  93. height: 20px;
  94. display: flex;
  95. position: absolute;
  96. bottom: 5px;
  97. left: calc(50% - 50px);
  98. align-items: center;
  99. padding-bottom: 1px;
  100. border-radius: 10px;
  101. }
  102. .carousel .circle {
  103. width: 10px;
  104. height: 10px;
  105. border-radius: 10px;
  106. /*border: 2px solid white;*/
  107. background: rgba(0, 0, 0, 0.4);
  108. box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  109. cursor: pointer;
  110. margin: 5px;
  111. }
  112. .carousel .white {
  113. background-color: #FFFFFF;
  114. }