-
Notifications
You must be signed in to change notification settings - Fork 0
/
img-carousel.css
85 lines (73 loc) · 2.24 KB
/
img-carousel.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* have attempted to write carousel stylesheet in BEM-consistent fashion */
.slider {
padding: 20px 0;
position: relative; /* set relative so descendants with position: absolute refer to overall container */
height: 80%;
width: 80%;
margin: 10px auto;
}
.slider__shell {
position: relative;
overflow: hidden; /* stop images spilling out of container */
width: 100%; /* make shell fill parent container */
height: 100%;
padding: 0;
border: 1px solid black;
background: rgb(0, 0, 0, 0.25); /* set grey background in case images smaller than container */
}
.slider__button {
position: absolute; /* buttons will be positioned relative to shell */
font-size: 4em; /* style the font awesome arrows */
color: white;
background-color: transparent; /* lose the <button> look */
border: 0;
height: 100%; /* make buttons fill container vertically */
width: 10%;
top: 50%; /* put button (almost) at vertical centre of slider */
transform: translateY(-50%); /* move buttons up by half their own height to correct placement */
z-index: 99; /* make sure buttons are on top of everything (except page nav/portfolio bars) */
}
.slider__button--left {
left: 0;
}
.slider__button--right {
right: 0;
}
.slider__list {
list-style: none; /* remove bullet points */
padding: 0;
margin: 0;
}
.slider__list-item {
/* don't think any styling necessary here */
}
.slider__img {
object-fit: cover; /* keep original image size/aspect ratio */
width: 100%;
height: 100%;
}
/* this modifier will be applied to whichever image is currently being shown */
.slider__img--active {
z-index: 90; /* on top - but not on top of the buttons! */
}
.slider__nav {
padding: 10px 0;
height: 20px;
width: 100%;
display: flex; /* use flexbox to automagic nav-btn placement */
justify-content: center;
}
.slider__nav-btn {
background-color: black;
width: 30px;
height: 30px;
z-index: 99;
border: 0; /* lose the <button> look again */
border-radius: 50%; /* make buttons circular */
opacity: 0.3; /* show which button is pressed by opacity */
margin: 0 5px; /* separate the buttons out horizontally */
}
/* this modifier can be swapped between buttons to indicate which image is being viewed */
.slider__nav-btn--active {
opacity: 0.8;
}