I'm having difficulty in constraining a transparent overlay & text to the height of a background image. I tried media queries to detect portrait/landscape modes but it doesn't work well when there is a large amount of text to display.
How can I constraint the height of the transparent overlay & the text to the height of the native image (even as it's resized) while still allowing the overlay & text to be scrollable within the image height?
Here's my attempt with media queries to detect orientation. It works well except when there is a large amount of text: http://jsfiddle.net/9ky7xfmd/1/
body {
background-image: url("http://www.gracotechgrupa.hr/img/site/header_homes/icon/zastita-metalnih-dijelova.jpg");
background-color: black;
width: 100%;
height: auto;
display: block;
background-repeat:no-repeat;
overflow-y: auto;
overflow-x: hidden;
}
@media all and (orientation:portrait) {
/* Styles for Portrait screen */
.headline {
display: block;
color: blue;
-webkit-box-shadow: inset 0px 0px 300px 28px rgba(255,255,255,0.77);
-moz-box-shadow: inset 0px 0px 300px 28px rgba(255,255,255,0.77);
box-shadow: inset 0px 0px 300px 28px rgba(255,255,255,0.77);
background: rgba(255,255,255,0.73);
padding-top: 0.7%;
padding-bottom: 1%;
padding-left: 3%;
padding-right: 3%;
height: 20%;
position: absolute;
margin-left: 25%;
margin-right: 25%;
top: 12.5%;
max-width: 45%;
font-size: 36px; /* Some tweener fallback that doesn't look awful */
font-size: 2.25vmin; /* This was originally 1.33vw & 1.718vmin */
opacity:1;
z-index: 2;
}
}
@media all and (orientation:landscape) {
/* Styles for Landscape screen */
.headline {
display: block;
color: blue;
-webkit-box-shadow: inset 0px 0px 300px 28px rgba(255,255,255,0.77);
-moz-box-shadow: inset 0px 0px 300px 28px rgba(255,255,255,0.77);
box-shadow: inset 0px 0px 300px 28px rgba(255,255,255,0.77);
background: rgba(255,255,255,0.73);
padding-top: 0.7%;
padding-bottom: 1%;
padding-left: 3%;
padding-right: 3%;
height: auto;
position: absolute;
margin-left: 25%;
margin-right: 25%;
top: 12.5%;
max-width: 45%;
font-size: 36px; /* Some tweener fallback that doesn't look awful */
font-size: 2.25vmin; /* This was originally 1.33vw & 1.718vmin */
opacity:1;
z-index: 2;
}
}