Tips for shortening your webpage for better mobile viewing

Looking to optimize my Login screen for mobile responsiveness. I am working on a project in ROR, so I have an html.erb file for the view:

<body class="app flex-row align-items-center">
<div class="container">
  <div class="row ">
    <div class="col-md-8">
      <div class="card-group login-margin">
        <div class="card p-4">
          <div class="card-body">
            <h1>Login</h1>
            <p class="text-muted">Sign In to your account</p>
            <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>

              <div class="input-group mb-3">
                <div class="input-group-prepend">
                  <span class="input-group-text">
                    <i class="icon-user"></i>
                  </span>
                </div>
                <%= f.text_field :email, required: false, placeholder: 'Email', class: 'form-control', type: 'text'  %>
              </div>

              <div class="input-group mb-4">
                <div class="input-group-prepend">
                  <span class="input-group-text">
                    <i class="icon-lock"></i>
                  </span>
                </div>
                <%= f.text_field :password, required: false, placeholder: 'Password', class: 'form-control', type: 'password'  %>
              </div>

              <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>

              <div class="row">
                <div class="col-6">
                  <%= f.button :submit, "Login", :class => 'mt-4 btn btn-md btn-primary' %>
                </div>
                <div class="col-6 text-right forget-link-margin">
                  <%= render "devise/shared/links" %>
                </div>
              </div>
            <% end %>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Seeking to optimize the layout by reducing overall length and making the card more prominent and centered to enhance its appearance on mobile devices.

UPDATE: For further inspection of the page, feel free to visit this link.

Answer №1

To create a responsive layout using the bootstrap grid system, you need to define column classes for different device sizes:

+--------------+---------------+--------------+
|    device    | device sizes  | column class |
+--------------+---------------+--------------+
| Extra_small  | [< 576px]     | : col-       |
| Small        | [≥ 576px]     | : col-sm-    |
| Medium       | [≥ 768px]     | : col-md-    |
| Large        | [≥ 992px]     | : col-lg-    |
| Extra_large  | [≥ 1200px]    | : col-xl-    |
+--------------+---------------+--------------+

For comprehensive information about implementing a responsive grid system using Bootstrap, refer to the official documentation.
To make an element full width on mobile devices, assign the class col-sm-12.

Answer №2

Include the d-flex class in the body element

<body class="app flex-row align-items-center d-flex">

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

Keep an ear out for upcoming occasions once the transition has been completed

I am looking to create a smooth transition effect that will push the main content downwards when the Twitter Bootstrap collapse menu is activated using the toggle button. However, I have noticed an issue where if I quickly double click the toggle button, ...

Tips for displaying an array and iterating through its children in Angular 7

I am currently working on extracting the parent and its children to an array in order to display them using ngFor. However, I am encountering an issue where the children are not being displayed during the ngFor. I have a service that retrieves data from a ...

Using jQuery to create a captivating Parallax Effect on your website's background image

Hey there! I have a div with the class 'section' that serves as a key element on my website. It has a background image set using the following CSS: .section-one { width: 100vw; height: 100vh; background-image: url(images/outside-shot ...

identify external components based on their internal identifiers

Can we target an external element based on its descendant elements? This question arises from the need to apply one stylesheet to two different dynamic pages within the same wrapper. Page 1 <div id="api"> <div class="a"></div> </div ...

When a button is undersized, the click event may not register

In my angular application, I have developed a directive for a tinyMCE editor. Upon setup, I have implemented two handlers: one for the blur event to hide the toolbar and another for the click event to show it. Additionally, I have created another directive ...

Missing HTML escape sequences following conversion to a string

The Android test was successfully run using the following code: public static void test() { String text="<html>" + "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\" /> ...

A function that handles HTTP request and response

In order to decrypt data, I need to retrieve the encrypted response by hitting a specific URL and then use that encrypted data along with a key to decrypt it. Initially, I attempted to fetch the data response using POSTMAN, but all I got back was a series ...

Swap out the HTML button element for text once the form is submitted

On the main page, I have a button that opens a modal when clicked. Inside the modal, there is a form with a submit button that closes the modal and returns to the main page. After closing the modal, I want to change the HTML button on the main page to plai ...

Guide to setting a background image on a div when hovering using jQuery

I'm having trouble adding a background image to this specific div element: <div class="logo-main"></div> Here is the script I've been using, but it doesn't seem to be working as expected: <script type='text/javascript& ...

Form is protected from XSS attacks

Here's a basic form that I'm attempting to exploit with XSS using Chrome. <?php echo $_GET['comment']; ?> <script>alert('from HTML')</script> <form method="GET" action=""> Name: <input t ...

CSS: Caption text below image remains on same line

I am struggling with positioning a div that contains an image and a caption. My goal is to make the caption break into a new line when it reaches 95% of the width of the image. Despite my efforts, I can't seem to achieve this. The text always pushes ...

Switching Over to Burger Menu

I created a burger menu using HTML, CSS, and jQuery that switches from a full-width menu to a burger menu. However, I'm facing an issue with toggling the dropdown when the menu collapses. Here's my code: <!DOCTYPE html> <html> < ...

Styling the day items of an AngularJS datepicker

I am interested in implementing the datepicker feature from http://angular-ui.github.io/bootstrap/#/datepicker. In addition, suppose I have a list of events for a specific date, like 12th January. Would it be possible to change the color of that particul ...

Is there a method in AngularJS to automatically set app.comment to null if the point is not equal to 1 using front end logic?

Can we verify on the front end in AngularJS if app.point !=1 and app.comment==null? <td> <input type="number" max="5" min="1" ng-init="app.point=5" data-ng-model="app.point"> </td> < ...

Is it possible to convert (HTML and CSS3 generated content for paged media) into a PDF format?

Would it be possible to convert a HTML document styled with CSS3 Generated Content for Paged Media into a PDF format? If such an application does not exist, what alternatives can I consider as the foundation for developing a converter? Thank you ...

Using javascript to dynamically change text color depending on the selected item

I am currently working on a website for a snow cone stand and I want to incorporate an interactive feature using JavaScript. Specifically, I would like to color code the flavor list based on the actual fruit color. The flavor list is already structured i ...

Is there a way to run both PHP and HTML code using the eval function?

Is it possible to execute HTML and PHP simultaneously using the eval function? eval ("<center> this is some html </center>"); The above code does not yield the desired output, so I am considering changing it to: echo ("<center> this is ...

I require the ability to access a reference parameter with a dynamically changing name within a Vue template

<div v-for="x in 4" :class="(images[x] === null) ? 'not-removable' : 'removable'" class="img-container"> <input style="display: none" type="file" ...

Compatibility Problem with Form Inputs in Internet Explorer 7 when Using a jQuery Datepicker

I've encountered a frustrating issue with my Reservations area (jquery ui datepicker) on the site I'm currently working on. When viewed in IE7, the datepicker is broken and displayed on separate lines. If you'd like to check it out yourself ...

Insert some padding above and below every line of text that is centered

I am looking to achieve a specific layout for my website. https://i.stack.imgur.com/dKT52.jpg Here is what I have attempted: <h2>Make search awesome using Open Source</h2> .banner .section_title h2 { font-family: "Oswald", Arial, sans- ...