div+css实现旅游目的地图文卡片左右列表滚动效果代码
代码语言:html
所属分类:布局界面
代码描述:div+css实现旅游目的地图文卡片左右列表滚动效果代码
代码标签: div css 旅游 目的地 图文 卡片 左右 列表 滚动
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { /* Base colors */ --primary-color: #e67e22; --secondary-color: #d35400; --card-bg: #ffffff; --card-text: #333333; --card-shadow: rgba(0, 0, 0, 0.15); --active-card-shadow: rgba(230, 126, 34, 0.4); --carousel-bg: #fffaf5; /* Destination-specific colors */ --kyoto-color: #c0392b; --kyoto-color-hover: #a93226; --santorini-color: #2980b9; --santorini-color-hover: #2471a3; --banff-color: #27ae60; --banff-color-hover: #229954; --bali-color: #d35400; --bali-color-hover: #ba4a00; --marrakech-color: #8e44ad; --marrakech-color-hover: #7d3c98; --machupicchu-color: #16a085; --machupicchu-color-hover: #138d75; } * { margin: 0; padding: 0; box-sizing: border-box; } body { margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #e67e22 0%, #8e44ad 100%); display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; color: var(--card-text); padding: 2rem 1rem; } .title { color: #fff9f0; text-align: center; margin-bottom: 2rem; font-size: 2.2rem; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); font-weight: 800; } .subtitle { color: #fff9f0; text-align: center; margin-top: -1rem; margin-bottom: 2rem; font-size: 1.1rem; } .carousel-container { position: relative; width: 100%; max-width: 1200px; } /* Carousel */ .carousel { display: flex; gap: 20px; width: 100%; max-width: 90vw; background-color: var(--carousel-bg); border-radius: 12px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15); padding: 20px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; /* Hide scrollbar for Firefox */ scroll-behavior: smooth; -webkit-overflow-scrolling: touch; position: relative; } .carousel::-webkit-scrollbar { display: none; } /* Updated navigation buttons */ .nav-button { position: absolute; top: 50%; transform: translateY(-50%); background-color: var(--primary-color); color: white; border: none; border-radius: 50%; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); transition: all 0.3s ease; font-size: 1.5rem; z-index: 10; opacity: 1; } .prev-btn { left: -25px; /* Position outside the carousel */ } .next-btn { right: -25px; /* Position outside the carousel */ } .nav-button:hover { background-color: var(--secondary-color); transform: translateY(-50%) scale(1.1); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4); } /* Card styling */ .card { flex: 0 0 auto; width: 300px; min-height: 520px; display: flex; flex-direction: column; background-color: var(--card-bg); border-radius: 12px; padding: 0; box-shadow: 0 4px 12px var(--card-shadow); transition: all 0.3s ease; scroll-snap-align: center; position: relative; } .card-image { width: 100%; height: 180px; object-fit: cover; object-position: center; border-top-left-radius: 12px; border-top-right-radius: 12px; display: block; background-color: #f0f0f0; } .card-badge { position: absolute; top: 12px; right: 12px; padding:.........完整代码请登录后点击上方下载按钮下载查看
网友评论0