Skip to content

Commit ef1d61b

Browse files
Final (hopefully) version of the responsive title image.
Had to use <picture> element to force media conditions properly.
1 parent 4a5973d commit ef1d61b

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

index.html

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
77
<link href="https://fonts.googleapis.com/css?family=Share+Tech+Mono" rel="stylesheet">
88
<link href="https://fonts.googleapis.com/css?family=Encode+Sans+Expanded" rel="stylesheet">
@@ -35,32 +35,28 @@
3535
</a>
3636
</div>
3737
</nav>
38-
<!--Title image will be set to display:none and used as a background image-->
38+
<!--Title image will be set to display:none and used as a background image on the div below-->
3939
<div class="navigation__content container-fluid" data-image-type="responsive">
40-
<img class="responsive" src="static/images/title_photo/title_glass_building_960x540.jpg"
41-
srcset="static/images/title_photo/title_glass_building_480x270.jpg 480w,
42-
static/images/title_photo/title_glass_building_750x1334.jpg 750w,
40+
<picture>
41+
<source srcset="static/images/title_photo/title_glass_building_480x270.jpg 480w,
4342
static/images/title_photo/title_glass_building_960x540.jpg 960w,
44-
static/images/title_photo/title_glass_building_1080x1920.jpg 1080w,
45-
static/images/title_photo/title_glass_building_1125x2436.jpg 1125w,
46-
static/images/title_photo/title_glass_building_1242x2436.jpg 1242w,
4743
static/images/title_photo/title_glass_building_1334x750.jpg 1334w,
48-
static/images/title_photo/title_glass_building_1442x2562.jpg 1442w,
4944
static/images/title_photo/title_glass_building_1920x1080.jpg 1920w,
5045
static/images/title_photo/title_glass_building_2562x1442.jpg 2562w,
5146
static/images/title_photo/title_glass_building_3840x2160.jpg 3840w"
52-
sizes="(max-width: 480px) and (orientation: landscape) 100vw,
53-
(max-width: 750px) and (orientation: portrait) 100vw,
54-
(max-width: 960px) and (orientation: landscape) 100vw,
55-
(max-width: 1080px) and (orientation: portrait) 100vw,
56-
(max-width: 1125px) and (orientation: portrait) 100vw,
57-
(max-width: 1242px) and (orientation: portrait) 100vw,
58-
(max-width: 1334px) and (orientation: landscape) 100vw,
59-
(max-width: 1442px) and (orientation: portrait) 100vw,
60-
(max-width: 1920px) and (orientation: landscape) 100vw,
61-
(max-width: 2562px) and (orientation: landscape) 100vw,
62-
(min-width: 2563px) and (orientation: landscape) 100vw"
63-
alt="Python Sprints Title Image">
47+
media="(orientation: landscape)"
48+
sizes="100vw">
49+
<source srcset="static/images/title_photo/title_glass_building_750x1334.jpg 750w,
50+
static/images/title_photo/title_glass_building_1080x1920.jpg 1080w,
51+
static/images/title_photo/title_glass_building_1125x2436.jpg 1125w,
52+
static/images/title_photo/title_glass_building_1242x2436.jpg 1242w,
53+
static/images/title_photo/title_glass_building_1442x2562.jpg 1442w,
54+
"
55+
media="(orientation: portrait)"
56+
sizes="100vw">
57+
<img class="responsive" src="static/images/title_photo/title_glass_building_960x540.jpg" alt="Python Sprints Title Image">
58+
</picture>
59+
6460
<div class="row">
6561
<div class="col-md-12">
6662
<h1 class="navigation__title">Python Sprints</h1>

0 commit comments

Comments
 (0)