Dealing with Vertical Alignment in the Center and Landscape Orientation challenge in Bootstrap 4.1

When in landscape orientation, I'm facing an issue with the vertical alignment being centered (card in the middle of the screen), which cuts off various elements like my logo image...

The "problem" lies in the h-100 class of the MAIN tag, as well as the CONTAINER and ROW...

However, I am unsure why this issue occurs specifically in this orientation, considering that I am following the bootstrap documentation. The only solution I can think of is using @media queries, but this might disrupt other resolutions on notebooks and computers...

What steps should I take to address this problem and what is causing it in the first place?

CSS:

html,
body { height: 100%; }

HTML:

<main class="h-100">
    <div class="container h-100">
        <div class="row justify-content-center align-items-center h-100">
            <div class="col-12">
                <div class="card mx-auto d-block shadow-md-large w-md-80 w-lg-50">
                    <div class="card-header bg-transparent border-0 py-md-5">
                        <img src="/img/logo/aliansce_full.svg" alt="Aliansce Shopping Centers" class="CLI img-fluid mx-auto d-block" autocomplete="on" autofocus require>
                    </div>
                    <div class="card-body px-md-5">
                        <form autocomplete="on">
                            <div class="form-group EGLF mt-4 mt-md-0">
                                <input type="text" id="FLUI" class="form-control FI EFLI border-top-0 border-right-0 border-left-0 rounded-0 shadow-none" autocomplete="on" autofocus required>
                                <!-- FLOAT LABEL EFFECT -->
                                <label fo="FLUI" id="FLUL" class="EFL">Usuário</label>
                                <span class="EFHL"></span>
                                <span class="EFBL"></span>
                                <!-- FRONTEND RESPONSE ERROR MESSAGE -->
                                <div id="FBMEU" class="FBMEU ml-1 text-danger"></div>
                            </div>
                            <div class="form-group EGLF mt-4">
                                <input type="password" id="FLUPI" class="form-control FI EFLI border-top-0 border-right-0 border-left-0 rounded-0 shadow-none" min="1" maxlength="10" required>
                                <!-- FLOAT LABEL EFFECT -->
                                <label for="FLUPI" id="FLUPL" class="EFL">Senha</label>
                                <span class="EFHL"></span>
                                <span class="EFBL"></span>
                                <!-- FRONTEND RESPONSE ERROR MESSAGE -->
                                <div id="FBMEUP" class="ml-1 text-danger"></div>
                            </div>
                            <div class="form-group mt-5">
                                <button type="button" id="FBSL" class="btn btn-primary w-esm-100 mb-2 px-lg-5">LOGIN</button>
                                <button type="button" class="btn bg-light w-esm-100 px-lg-5">VOLTAR</button>
                            </div>
                        </form>
                        <!-- BACKEND RESPONSE ERROR MESSAGE -->
                        <div class="text-center text-danger">
                            Usuário ou senha incorretos.
                            <br> Caso esteja com dificuldades, clique em "Precisa de Ajuda?".
                        </div> 
                    </div>
                    <div class="card-footer bg-white border-0">
                        <button type="button" class="btn btn-link mx-auto d-block">Precisa de Ajuda?</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>

https://i.sstatic.net/U2isO.png https://i.sstatic.net/kVv4x.png

Answer №1

If you're looking to center the card along both axes, this solution may be what you need.


Using grid layout here seems unnecessary since there is only one card. It's best not to alter the display property of the card.


Apply these classes to the main element:
  • d-flex
  • flex-column changes the direction while ensuring content maintains its default properties like width.
  • With a column direction, use justify-content-center for vertical alignment in the center or align-items-center if preferred.

Add a new d-flex element and apply justify-content-center to horizontally align its content.
Introduce another block element with w-md-80 w-lg-50 classes.

https://codepen.io/anon/pen/jQQrog

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

Correctly specified document type declaration... unique attributes and unconventional markup languages

While I have a strong appreciation for web standards and have authored pages in strict XHTML 1.0, the ever-evolving nature of the web has led me to explore XML, DOM capabilities, and custom attributes. Despite the lack of universal browser support, I find ...

Transform JSON array containing identical key-value pairs

My array is structured as follows: [ { "time": "2017-09-14 02:44 AM", "artist": "Sam", "message": "message 1", "days": 0 }, { "time": "2017-09-14 02:44 AM", " ...

Embedding a CSS file into a PHP class

I've encountered a little issue that I can't seem to solve on my own. I've put together a "webengine" using multiple classes. The primary class responsible for obtaining a theme's internals is called "Logic". This Logic class contain ...

Clicking randomly on the page to conduct test trials

Currently, I am seeking a way to ensure that my web page is flawless, specifically in terms of broken paths. Given that my website will utilize a touch screen interface, it is crucial to test the entire page thoroughly. While I have limited experience in a ...

The margin of the parent container is influencing the margin of the child element

Purple Working on displaying a rectangle shape in a browser using divs in my React project. Everything works fine, but when I add margin to the parent base and then draw the boxes, there's some space between the mouse cursor and the actual box. The ...

Styling with CSS in a React component

I am trying to display a row of buttons instead of columns on my webpage. I have used display:flex but it is still showing as a column. What I want is for each button to display the first character of its name underneath it, with all buttons lined up next ...

Aligning images in rows using Bootstrap

I've been working on aligning my images side-by-side using Bootstrap. Despite trying various grid sizes and other tweaks, I can't seem to prevent them from stacking vertically. Here is the code snippet that's causing the issue: <!-- CS Se ...

I am having difficulty with the fadeIn animation not working as expected in my situation

http://jsfiddle.net/9w0v62fa/1/ Instead of using opacity 0 and 1 in two different places, which I find redundant, I attempted to utilize the CSS animate property. However, I couldn't get it to work. Here is my code: .btn{ background:blue; pa ...

Utilizing Vuejs to initiate a GET request using a method

Currently, I am working on enhancing the functionality of a GET request in Vue. My goal is to attach the request sending action to the form's submit button and also include a parameter from a text field within the form. HTML <html> <head> ...

Spread out a div across a container's width

Currently, I am struggling to modify my css and html in order to have a div expand horizontally into a scrollable div. However, all I seem to get is the content stacking once the width limit is reached. Take a look at this fiddle for reference. The absol ...

What is the method to determine the size of a numbered list?

Currently transitioning from jQuery to plain JavaScript. Previously used this in jQuery: var list = $('.list li'), listLength = list.length; Now attempting to achieve the same with JavaScript, but encountering issues: var list = documen ...

Is there a method in Bootstrap 4 to create a table row that can be clicked on?

Is there a way to make the rows in a table clickable when using the 'table-hover' class in B4? <table class="table table-hover"> <thead> <tr> <th>#</th> <th>First Name</th> <th ...

show small previews of pictures stored in a JavaScript array by using a for-loop

Currently stuck on a university project where I've set up an array of images like this: var testdata = [ { "imageID": 17, "uploadedDate": "2020-07-31 03:56:56.243139", "filepathOriginal": &qu ...

The problem of a child div extending beyond the boundaries of its parent div

I am searching for a layout similar to this, click here. Here is the basic HTML code I have: #mainContent { margin:0; width:100%; height:600px; padding: 0 0 30px 0; } #mainContent #sidebar { /* sidebar inside # ...

Images featuring a drop-down menu

I'm having trouble separating the two photos on this page. When I hover over one, the other also fades in. Additionally, the text box is overlapping the first photo. My goal is to have a total of 6 photos on the page, each with a dropdown list contain ...

What is the best way to adjust font size based on div size?

Imagine a div with fixed dimensions that contains text content. If the text is too long, it overflows and "explodes" the div. On the other hand, if the text is too short, the div looks empty. I think the solution would be to adjust the font size dynamical ...

Exploring Javascript's potential with for loops and arrays

Looking to create a webpage with the following features: (generate question)...this will be a button ? x 1 = ( ) ? x 2 = ( ) ... ? x 9 = ( ) (check answer)...this will also be a button The user starts by selecting a number after clicking th ...

Control input for filtering and searching using Bootstrap

My goal is to create a search and filter user input field. I found an example on an old bootstrap page that showcases exactly what I need, but I'm facing some issues with displaying the results. Here's the Bootstrap example page. The search bar ...

What could be causing the event listener to not be triggered?

I'm having an issue with a simple code that is supposed to display an alert box when a hyperlink is clicked, but it's not working. I believe the script is not being called. Can someone help me figure out what's wrong? Here is the HTML code: ...

Utilizing SendGrid Java to send dynamic HTML templates via email

Currently, I am utilizing SendGrid in Java to send an email that contains HTML. Within the HTML content are dynamic elements that are requested from the frontend. On the frontend side, there is a text field with spaces and newlines (\n). When I pass t ...