I see that you marked the question with responsive-design , so I thought I could offer a solution that does not require Javascript, and can only be done using CSS.
Knowing that when switching between landscape and portrait modes, two different screen sizes are available, you can use the media query to display and hide the overlay:
HTML:
<div id="content"> <p>Integer velit nulla, condimentum vitae risus ut, rhoncus vulputate quam. Fusce lacus elit, accumsan eu dolor vel, scelerisque pretium turpis. Vivamus ac lectus vitae enim lacinia fringilla vel id tellus. Curabitur pharetra tortor eget risus ornare scelerisque. Morbi tempus et felis vitae venenatis. Suspendisse vitae ultrices est, nec sagittis arcu.</p> </div>
CSS
#rotate { display: none; } @media screen and (max-width: 300px) { #rotate { background-color: rgba(0,0,0,0.5); display: block; height: 100%; position: absolute; top: 0; width: 100%; } }
All this is checking the available width, and if it is 300 pixels or less, it displays the content that is overlapping. If the available width is greater than 300 pixels, it will hide the content. You can adjust this value for different widths of the mobile device to check if it is in portrait or landscape mode.
You can check this on jsfiddle by moving the vertical bar in the middle so that the preview window is larger and smaller: http://jsfiddle.net/wv6Vp/
cchana
source share