The media query I have used only includes the CSS elements whereas the photo is contained in the HTML elements, and it is the HTML elements I want changed when the screen width reaches 800px.
So can those HTML elements be changed by CSS or Javascript? If the HTML elements can not be changed, then page redirection should solve that issue.
UPDATE
As a matter of interest, if I have this coding:-
<style type="text/css"> .images { position: absolute; height: 77%; width: 39%; right: 2.5%; bottom: 6.8%; top: 16%; background-color: #98FF98; } </style>
<div class="images"></div>
The background of the images displays as expected, whereas if I delete the 2nd line HTML coding it does not display.
On the other hand if I add this coding, which does not include the 2nd line HTML coding:-
<style>@media screen and (max-width:800px) { .images { position: absolute; height: 47%; width: 96%; left: 2%; top: 16%; background-color: #98FF98; } }</style>
The background of the images displays as normal on a wide screen, and also displays repositioned on a narrow screen. Im saying this because in that scenario CSS picks up the HTML elements.
So if CSS can pick up the HTML elements in that scenario, why can it not pick up these elements? Or maybe it can and I need to be shown.
<div class="pha"><img alt="Photo" src = "/img/soda.jpg" style="width:285%;" ></div>
UPDATE
The media query I have used only includes the CSS coding
<style>@media screen and (max-width:800px) { .images { position: absolute; height: 47%; width: 96%; left: 2%; top: 16%; background-color: #98FF98; } }</style>
Does not include
<div class="images"></div>
or
<div class="pha"><img alt="Photo" src = "/img/soda.jpg" style="width:285%;" ></div>
whereas the photo is contained in the HTML div coding as above.
And it is the HTML div coding I want changed from
<style type="text/css"> .pha { position: absolute; width: 6%; right: 8.2%; top: 18.5%; } </style>
<div class="pha"><img alt="Photo" src = "/img/soda.jpg" style="width:160%;" ></div>
to this
<style type="text/css"> .pha { position: absolute; width: 6%; left: 7.2%; top: 17%; } </style>
<div class="pha"><img alt="Photo" src = "/img/soda.jpg" style="width:285%;" ></div>
when the screen width reaches 800px.
I can get the top lines (style) to change but not the bottom lines (div).
UPDATE
This is the coding for the background and the photo on wide screen. When the screen is narrowed the background repositions the way I want but the photo remains in the original position and is too small.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<style type="text/css"> .images { position: absolute; height: 77%; width: 39%; right: 2.5%; bottom: 6.8%; top: 16%; background-color: #98FF98; } </style>
<div class="images"></div> <!--If this line is deleted the background does not appear-->
<style>@media screen and (max-width:800px) { .images { position: absolute; height: 47%; width: 96%; left: 2%; top: 16%; background-color: #98FF98; } }</style> <!--This line works good when screen is narrowed-->
<div class="images"></div> <!--This line does nothing and doesnt need to be there-->
<style type="text/css"> .pha { position: absolute; width: 6%; right: 8.2%; top: 18.5%; } </style>
<div class="pha"><img alt="Photo" src = "/img/soda.jpg" style="width:160%;" ></div>
<style>@media screen and (max-width:800px) { .pha { position: absolute; width: 6%; left: 7.2%; top: 17%; } }</style>
<div class="pha"><img alt="Photo" src = "/img/soda.jpg" style="width:285%;" ></div> <!--This line does not reposition the photo when the screen is narrowed-->
</body>
</html>
This is the coding for the background and the photo on a narrow screen. Which is how I want the coding above to look like when the screen is narrowed.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<style type="text/css"> .images { position: absolute; height: 77%; width: 39%; right: 2.5%; bottom: 6.8%; top: 16%; background-color: #98FF98; } </style>
<div class="images"></div>
<style type="text/css"> .phb { position: absolute; width: 6%; left: 7.2%; top: 17%; } </style>
<div class="phb"><img alt="Photo" src = "/img/soda.jpg" style="width:285%;" ></div>
</body>
</html>