The div element is not resizing properly when the phone is in landscape mode

I have set a background photo to take up 100% of the height.

However, when I view the site on a mobile phone in landscape mode using Chrome or Firefox, the background image does not fill the entire space.

In desktop and portrait mobile modes, everything looks fine. The issue only occurs in landscape mode.

I want the content to adjust to the viewport in landscape mode. How can I achieve this?

https://i.sstatic.net/aLQhS.png MOBILE: PORTRAIT MODE, NO ISSUES.

https://i.sstatic.net/YzSd0.png MOBILE: LANDSCAPE MODE, Content overflows main div.

Please open the Snippet in the browser console or use a cell simulator in landscape mode to see the problem.

body, html {
  height:100%;
  padding:0;
  margin:0;

}
.block {
  height: 100%;
  width: 100%;
  text-align: center;
  background: black;

}

.block:before {
  content: '';
  display: inline-block;
  height: 100%; 
  vertical-align: middle;      
}

.centered {
  margin-top: 10%;
  display: inline-block;
  vertical-align: middle;
  max-width: 500px; 
  background: white;
}

.img-responsive {
  display: block;
  max-width: 100%;
  height: auto;
}
<div class="block">
     
    <div class="centered">
    
    <img src="https://upload.wikimedia.org/wikipedia/commons/6/6f/HP_logo_630x630.png" class="img-responsive" id="img_logo">
 <p style="color: black"> <a style="font-size:35px;"> xxxxxx</a> <br><br>text text <br> address <br>  </p>      
   </div>
  </div> 

I attempted to remove .block:before and added:

@media(orientation: landscape){
  .background-image {
    min-height: 200%;
  }
}

However, this change affected both mobile and desktop modes. I specifically need it to work only on mobile devices.

Answer №1

I can't guarantee that this is the exact solution you need, but you might want to experiment with replacing "height" with "min-height" inside the ".box" CSS selector.

.box {
  min-height: 100%;
  width: 100%;
  text-align: center;
  background: blue;
}

By making this adjustment, the blue background of the .box container will stretch to cover the entire section.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for handling transparent areas during a hover event

Is there a way to make only the rhombus image respond to hover events? I want to exclude the transparent area, as shown in this picture. <img src='http://s30.postimg.org/xpd6gwla9/1_Copy.jpg' id="first"> #first:hover { -moz-box-shadow ...

Enabling the use of special characters when submitting a form

Currently, I am in the process of developing a contact form for a website. My main objective is to enable users to input non-Latin characters such as é or 車. However, I have encountered some challenges regarding where I should implement this feature. On ...

I need assistance from someone knowledgeable in HTML and CSS. I am trying to create a div that dynamically increases its width until it reaches a specific

Seeking assistance to create a dynamic div that continuously expands its width until it reaches a maximum of 540px. It should start at 75px. Below is the HTML and CSS code I've attempted: .Loading-Screen { background-color: black; color: alicebl ...

Trigger a jQuery function upon clicking a button

I am attempting to create a jQuery function that can be called independently, and then trigger the function when a click event occurs. Below is the code I have put together: HTML: <input type="text" class="form-control email_input" name='email&ap ...

Jquery adds a fun, wobbly effect to animations

I'm experiencing an issue with the animation I've implemented causing some slight shaking and wobbling of the text and certain elements which is affecting the overall look. You can view a live example of this behavior here: This problem specific ...

When the header is given a fixed position, the modal becomes unattainable

I am currently working on developing my personal news website called News Pews. This is my third project, and I have encountered an issue that was not present in my previous projects. The problem arises when I apply position: fixed; top:0; to the header c ...

Guide on using JavaScript to implement the universal CSS selector

One technique I frequently employ is using the CSS universal selector to reset the dimensions in my HTML document: * { border: 0; margin: 0; padding: 0; } I wonder if a similar approach can be achieved with JavaScript as well? When it come ...

Particles.js fails to persist as I scroll down the HTML page

After creating a website page, I incorporated Particles.js for the background. However, when I scroll down, the particles seem to be confined to the initial corner of the screen and do not continue downward. Here are my current particle settings: #particl ...

How to keep the Bootstrap column in place while making it fixed

I'm struggling to make the second column (yellow part) stay fixed in position. I've tried using CSS position:fixed, but the column keeps shifting to the left. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/cs ...

Contact form repair completed - Messages successfully delivered

I am facing an issue with the contact form on my HTML landing page. Currently, when you click the 'Submit' button, it redirects to a new PHP page displaying 'Success'. Is there a way to make it so that upon clicking 'Submit' a ...

Transmitting live video to rtmp using the client's web browser

Is it feasible to stream video from a client browser to an RTMP server without using Flash? I am searching for an alternative solution. https://github.com/ahyswang/actionscript-publisher I found this to be effective, but it relies on Flash. Do I need to ...

Troubleshooting: Bootstrap 5 Alert not Displaying on Website

I'm experiencing an issue trying to display a bootstrap alert in my HTML code. Here is the code I'm using: <div class="alert alert-success alert-dismissible fade show" role="alert"> text & ...

Tips on managing multiple form data using ajax for php backend

<input type="text" value="2021-05-01" class="date" name="date"> <input type="text" value="10:00" class="starttime" name="starttime"> ...

Did I accidentally overlook a tag for this stylish stripe mesh Gradient design?

I've been attempting to replicate the striped animated Gradient mesh using whatamesh.vercel.app. I've set up the JS file, inserted all the gist code into it, and placed everything in the correct locations, but unfortunately, it's not functio ...

Adjusting the layout of tables for an accordion design

I am facing an issue with displaying the accordion in a table layout. When I expand them, the arrangement gets disrupted. To see the table layout for the accordion, you can check it here. <div ng-controller="AccordionDemoCtrl"> <label class="che ...

The jQuery statements are not properly executing the if and else conditions

i'm currently assessing the condition using this particular code. jQuery(document).ready(function($){ $('#uitkering_funds').hide(); $('#uitkering_funds_hoofd').hide(); $('#partner_uitkering').hide(); $('#par ...

The innerHTML inside Angular components appears scrambled, with only the final innerHTML rendering correctly

When working on my Angular project (version 8), I encountered an issue where a list of static HTML content retrieved from a database is not rendering correctly in the parent HTML. Strangely, only the last div with innerHTML is being rendered correctly, whi ...

Additional white sheet included with TCPDF

I have been working with TCPDF to convert PHP-generated pages from MySQL queries. Each record is contained within a div and uses the style "page-break-after:always". However, I am encountering an issue where an extra blank page appears at the end of the PD ...

What is the process for linking a specific HTML file to a URL?

After preparing all my HTML, CSS, and JS files for upload to a server (I am using cPanel which I have experience with), I found myself wondering how to assign a specific HTML file to a custom link, such as "devwebdevelopment.com/about" I am looking to cre ...

Guide on linking an id with a trigger function in HTML and JavaScript

In the snippet below, I aim to create a responsive feature based on user input of 'mute' and 'muteon'. Whenever one of these is entered into the textbox, it will change the color of linked elements with the IDs "text" and "text1" to red ...