diff --git a/app/components/AutoCarousel.tsx b/app/components/AutoCarousel.tsx index 8403c76..01a32b1 100644 --- a/app/components/AutoCarousel.tsx +++ b/app/components/AutoCarousel.tsx @@ -23,19 +23,19 @@ const imageUrls = [ export function AutoCarouselDemo() { return (
- {/* 左右渐隐遮罩 */} + {/* 相对定位 宽度100% 水平居中 隐藏溢出 */}
- + {/* 绝对定位 上下与父对齐 水平左对齐 背景渐变从左 从黑70%到透明 */} - {/* 悬停放大容器 */} + {/* 基宽 中屏 大屏 防止收缩 相对定位 + 内边距 过渡500ms 鼠标悬停时放大1.05倍 鼠标手型 + 隐藏溢出 移除边框 中等阴影 + 弹性布局 正方形 垂直居中 水平居中 内边距0 相对 + */}
{ setCurrent(api.selectedScrollSnap()); }); - }, [api]); + }, [api]);//当api改变时,执行此函数 水平居中 循环 自动播放 回传状态 return (
@@ -54,7 +53,7 @@ export function CarouselDemo() {
@@ -79,7 +78,6 @@ export function CarouselDemo() { className={`h-2 w-2 rounded-full transition-colors ${ index === current ? "bg-black" : "bg-black/50" }`} - aria-label={`Go to slide ${index + 1}`} /> ))}
diff --git a/app/components/body/ImageGridSection.tsx b/app/components/body/ImageGridSection.tsx index 6625297..813ca63 100644 --- a/app/components/body/ImageGridSection.tsx +++ b/app/components/body/ImageGridSection.tsx @@ -1,6 +1,6 @@ import { CarouselDemo } from "@/components/Carousel"; const ImageGridSection = () => { - // 替换为你自己的图片路径 + const elements = [ "/images/carousel-1.jpg", , diff --git a/app/routes/news.tsx b/app/routes/news.tsx index c7e1696..4a3a154 100755 --- a/app/routes/news.tsx +++ b/app/routes/news.tsx @@ -8,6 +8,7 @@ import NewsList from "@/components/list/NewsList"; import ImageGridSection from "@/components/body/ImageGridSection"; import { CarouselDemo } from "@/components/Carousel"; import GrassrootsDynamics from "@/components/body/GrassrootsDynamics"; +import { AutoCarouselDemo } from "@/components/AutoCarousel"; export function meta( ) { return [ { title: "New React Router App" }, @@ -24,8 +25,10 @@ export default function Home() { - + + +
); }