Files
phaten-audio/assets/stylesheets/carousel.css

180 lines
3.5 KiB
CSS
Raw Normal View History

2025-05-14 15:25:41 +08:00
/* 轮播图容器 - 添加固定高度 */
.image-carousel {
position: relative;
max-width: 800px;
height: 250px; /* 设置固定高度,您可以根据需要修改这个值 */
margin: 0 auto;
overflow: hidden;
background-color: #f5f5f5; /* 可选:添加背景色以便于区分图片与容器 */
}
/* 幻灯片 */
.carousel-slide {
display: none;
width: 100%;
height: 100%; /* 确保幻灯片占满容器高度 */
text-align: center; /* 图片居中显示 */
}
/* 幻灯片图片 - 使用object-fit实现等比例缩放 */
.carousel-slide img {
max-width: 100%;
max-height: 100%;
width: auto; /* 自动宽度 */
height: auto; /* 自动高度 */
object-fit: contain; /* 关键使用contain确保图片完整显示 */
display: block;
margin: 0 auto; /* 水平居中 */
position: relative;
top: 50%; /* 结合下面的transform实现垂直居中 */
transform: translateY(-50%);
}
/* 导航按钮 - 保持不变 */
.carousel-prev,
.carousel-next {
position: absolute;
top: 50%;
transform: translateY(-50%);
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
cursor: pointer;
background-color: rgba(0, 0, 0, 0.5);
border: none;
border-radius: 50%;
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
transition: background-color 0.3s;
}
.carousel-prev:hover,
.carousel-next:hover {
background-color: rgba(0, 0, 0, 0.8);
}
.carousel-prev {
left: 10px;
}
.carousel-next {
right: 10px;
}
/* 圆点指示器 - 保持不变 */
.carousel-dots {
text-align: center;
margin-top: 10px;
}
.carousel-dot {
display: inline-block;
width: 10px;
height: 10px;
margin: 0 5px;
background-color: #bbb;
border-radius: 50%;
cursor: pointer;
transition: background-color 0.3s;
}
.carousel-dot.active {
background-color: #717171;
}
/* 图片说明 - 调整位置确保在图片下方显示 */
.carousel-caption {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.7);
color: white;
padding: 10px;
text-align: center;
}
/* 下面是您已有的其他样式,保持不变 */
/* Image alignment classes */
.align-left {
float: left;
margin-right: 15px;
margin-bottom: 10px;
}
.align-center {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.align-right {
float: right;
margin-left: 15px;
margin-bottom: 10px;
}
/* 图片尺寸控制类 */
.img-fixed {
max-width: 100%; /* 默认响应式 */
height: auto;
}
/* 小尺寸图片 */
.img-small {
max-width: 200px;
max-height: 150px;
}
/* 小尺寸图片-固定高度 */
.img-small-height-fix {
width: auto;
max-width: 100%;
height: 150px; /* 修改为更合理的高度值 */
}
/* 小尺寸图片-固定宽度 */
.img-small-width-fix {
width: 200px; /* 修改为更合理的宽度值 */
height: auto;
max-height: 100%;
}
/* 中等尺寸图片 */
.img-medium {
max-width: 400px;
max-height: 300px;
}
/* 大尺寸图片 */
.img-large {
max-width: 800px;
max-height: 600px;
}
/* 文字环绕左侧图片 */
.img-float-left {
float: left;
margin-right: 15px;
margin-bottom: 10px;
}
/* 文字环绕右侧图片 */
.img-float-right {
float: right;
margin-left: 15px;
margin-bottom: 10px;
}
/* Clear floats after images */
.clearfix::after {
content: "";
clear: both;
display: table;
}