Chris77, because you do not understand the properties that you are using, you are mixing and matching properties in ways that will not work. The “working pages” that we are writing are complete packages that work properly. They are not “mix-n-match” code. Neither is yours, once we understand exactly what you want.
Please leave your code in the vault. Please evaluate one of OUR working pages and tell us what you like or do not like about its behavior. Not the code, but the way it behaves in the browser.
Did you actually try @coothead’s code in #13?
Did you step through the teaching exercise that I posted in #14?
What was wrong with the behavior of the page whose code I posted in #24?
How wide should your page be in a desktop monitor? How wide should the background image be in that same desktop monitor?
Please describe how you would change the way the page works/behaves so it behaves the way you want it to?
Any of us can write the code if you will give us a clear picuture of what you what it to do and not do.
Use PhotoShop or GIMP to draw pictures if that is easier for you. It might be easier for us if you do.
This, as all of my previous examples, is a stand-alone working page. Copy it to a file and open it in your browser. Then tell us what is wrong with the working page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
<title>image fits fixed height container</title>
<!--
https://www.sitepoint.com/community/t/2-layer-method-for-image-overlays-for-translucent-coloring/235774/5
Chris77
yet another guess from ron
-->
<style media="screen">
body {
background-color:#def;
padding:0;
margin:0;
}
.wrapper {
max-width:960px; /* Sets the max width of the page and the maximum width of the background image. */
margin:0 auto;
}
.element-with-background-image {
padding-top:75%;
background:
linear-gradient(rgba(255, 0, 0, 0.1),rgba(255, 0, 0, 0.6)),
url(https://upload.wikimedia.org/wikipedia/commons/1/1d/Martinique_Beach_%28Salines%29.jpg);
background-size:cover;
background-position:50% 50%;
}
@media screen and (max-width:520px) {
.element-with-background-image {padding-top:402px;}
}
</style>
</head>
<body>
<div class="wrapper">
<div class="element-with-background-image"></div>
</div>
</body>
</html>
If you keep throwing spaghetti at the wall instead of measuring the ingredients, we’ll never come up with a good recipe.