I have been wanting to gain more control over my images on various screen sizes for quite some time now. Recently, I discovered the <picture>
tag in HTML5.
Currently, I am using Bootstrap 3. However, I'm not sure if it is effective to combine Bootstrap and the <picture>
tag. So far, I haven't noticed any significant changes in the test code I created.
<!DOCTYPE html>
<html lang="en>
<head>
<title>TEMPLATE</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
</style>
<body>
<div class="container-fluid">
<!-- Test row 1 -->
<div class="row">
<div class="col-sm-12">
<picture>
<source media="(min-width: 991px)" srcset="http://vouzalis.dk/1024.jpg">
<source media="(min-width: 768px)" srcset="http://vouzalis.dk/991.jpg">
<source media="(min-width: 650px)" srcset="http://vouzalis.dk/768.jpg">
<source media="(min-width: 380px)" srcset="http://vouzalis.dk/380.jpg">
<img src="http://vouzalis.dk/1024.jpg" alt="Test picture" style="width:auto;">
</picture>
</div>
</div>
<!-- Test row 2 -->
<div class="row">
<div class="col-sm-6">
<picture>
<source media="(min-width: 991px)" srcset="http://vouzalis.dk/1024.jpg">
<source media="(min-width: 768px)" srcset="http://vouzalis.dk/991.jpg">
<source media="(min-width: 650px)" srcset="http://vouzalis.dk/768.jpg">
<source media="(min-width: 380px)" srcset="http://vouzalis.dk/380.jpg">
<img src="http://vouzalis.dk/1024.jpg" alt="Test picture" style="width:auto;">
</picture>
</div>
<div class="col-sm-6">
<picture>
<source media="(min-width: 991px)" srcset="http://vouzalis.dk/1024.jpg">
<source media="(min-width: 768px)" srcset="http://vouzalis.dk/991.jpg">
<source media="(min-width: 650px)" srcset="http://vouzalis.dk/768.jpg">
<source media="(min-width: 380px)" srcset="http://vouzalis.dk/380.jpg">
<img src="http://vouzalis.dk/1024.jpg" alt="Test picture" style="width:auto;">
</picture>
</div>
</div>
</div>
</body>
</html>