Excessive spacing among flex items in mobile layout

Can anyone help me with reducing the space between the flex items in mobile view? I've tried using gap and margin in the flex items but haven't had any success. Here is my code for reference. Thank you!

https://i.sstatic.net/Bf5Va.png

I am trying to decrease the space between the app title, description, and login form specifically on mobile view. It looks fine on desktop view but not on mobile. Thank you!

* {
  box-sizing: border-box;
}

body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  background-color: #181818;
  font-family: 'Poppins', sans-serif;
}

.flexbox-container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

.form-group {
  margin: 10px 0;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px;
  border: 1px solid #dadada;
  border-radius: 6px;
  font-size: 16px;
  outline: none;
  font-family: 'Open Sans', sans-serif;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border: 1px solid #0066cc;
}

button {
  font-size: 15px;
  font-weight: 800;
}

.btn-info {
  border: 1px solid #2157eb;
  background-color: #2157eb;
  color: #fff;
}

.btn-success {
  border: 1px solid #1fa167;
  background-color: #1fa167;
  color: #fff;
}

.btn-link {
  text-decoration: none;
  font-size: 15px;
  font-weight: 400;
  color: #0066cc;
}

hr {
  border: none;
  border-bottom: 1px solid #cfcfcf;
  margin: 15px 0;
}

.index-page-flexcon1 {
  width: 100%;
  height: 100%;
  padding: 20px;
  gap: 40px;
  align-items: center;
  justify-content: space-around;
}

.index-page-flexcon1 .flexbox-item-1 {
  max-width: 380px;
  text-align: center;
}

.index-page-flexcon1 .flexbox-item-1 h1 {
  margin: 0;
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
  background-image: -webkit-linear-gradient(0deg, #3496e6 30%, #a465d9 70%);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.index-page-flexcon1 .flexbox-item-1 p {
  color: #c4c4c4;
}

.index-page-flexcon1 .flexbox-item-2 {
  width: 300px;
  padding: 20px;
  border: 1px solid #f3f3f3;
  border-radius: 6px;
  background-color: #f3f3f3;
  text-align: center;
}

.index-page-flexcon1 .flexbox-item-2 .btn-info {
  width: 100%;
  padding: 10px;
}

.index-page-flexcon1 .flexbox-item-2 .btn-success {
  padding: 8px 16px;
  margin-top: 10px;
  border-radius: 20px;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, interactive-widget=resizes-content">

  <link rel="preload" href="assets/css/style.css?version=<?php echo rand(0, 100); ?>" as="style" onload="this.onload=null; this.rel='stylesheet';">
  <noscript><link rel="stylesheet" href="assets/css/style.css?version=<?php echo rand(0, 100); ?>"></noscript>

  <!-- boxicons link -->
  <link href='https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0d6f6275646e62637e4d3f233c2339">[email protected]</a>/css/boxicons.min.css' rel='stylesheet'>
  <title>WeChitChat</title>
</head>

<body>
  <div class="flexbox-container index-page-flexcon1">
    <div class="flexbox-item-1">
      <h1>WeChitChat</h1>
      <p>
        <span class="icon"><i class='bx bxs-heart'></i></span> Simple,
        <span class="icon"><i class='bx bxs-zap'></i></span> Fast and
        <span class="icon"><i class='bx bxs-check-shield'></i></span> Secured. Stay connected to your friends and family
        <span class="special-text">Anytime, Anywhere.</span>
      </p>
    </div>
    <div class="flexbox-item-2">
      <form action="">
        <div class="form-group">
          <input type="text" name="" id="" placeholder="Username">
        </div>
        <div class="form-group">
          <input type="password" name="" id="" placeholder="Password">
        </div>
        <div class="form-group">
          <button type="submit" class="btn-info">Log In</button>
        </div>
        <div class="form-group">
          <hr>
          <a href="#" class="btn-link">Forgot your password?</a><br/>
          <button type="button" class="btn-success">Register an account</button>
        </div>
      </form>
    </div>
  </div>
</body>

</html>

Answer №1

To achieve this, simply incorporate the align-content attribute (particularly for cases where items need to wrap — a behavior only enabled with the addition of flex-wrap: wrap):

.index-page-flexcon1 {
    flex-wrap: wrap;
    align-content: center;
}

(Alternatively, you can explore options like using align-content: flex-start, among others.)

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

Core MVC - Adjusting Font Size

After setting up an MVC Core App with automatic scaffolding, I am now faced with the challenge of adjusting the font size in my html View. The question is: How can I change the font size in bootstrap.css? There seem to be multiple font sizes available an ...

My webpage layout doesn't quite accommodate my content, so I need to adjust it to be more zoom

Why does the page container load bigger than the html/body container in mobile mode, as shown in the photo? https://i.sstatic.net/fD1N4.png Here is my CSS: html { margin-top: 48px; width: 100%; } body { margin: 0; width: 100%; background: ...

Looking to replace a background image using javascript?

(apologies for any language mistakes) I have multiple divs with a common background image. I assigned them the same class and set the background image using CSS in style.css which worked perfectly fine. Now, I want to change the background image dynamical ...

Is it possible to personalize the Facebook like box appearance?

Is there a way to modify the number of feeds and enable auto scroll feature in a Facebook likebox? I've been experimenting with the code snippet below but have hit a roadblock. <div id="fb-root"></div><script>(function(d, s, id) {va ...

Achieve a multi-column layout on a webpage by ensuring two HTML elements remain on the same line

Trying to tackle this CSS challenge, but it's definitely been a head-scratcher for me. I'm aiming to place two elements on the same line: Textbox Search icon image The search icon should maintain its size regardless of width, while the textbo ...

The @media feature is not functioning properly

I am struggling with getting my media query to function properly on a school project. Despite carefully checking my code, I cannot figure out why it is not making the desired changes when viewed on a mobile device. If anyone has any suggestions or insigh ...

Utilizing JQuery AJAX and PHP for Data Encoding

My webpage is encoded in HTML with the charset ISO-8859-2. All content on the page adheres to this charset and appears correctly. However, I am facing an issue when making an Ajax call to a PHP server. When I send the character á and receive the same valu ...

Troubleshooting a dysfunctional collapsed navbar in React with Bootstrap 5

I am experiencing an issue where the collapsed navbar icon does not expand when clicked on smaller screens. I followed the example provided by bootstrap 5 and made sure to include bootstrap css/js and jquery. class CustomNavBar extends Component { re ...

The combination of jQuery and HTML FormData triggers an error message of "Uncaught TypeError: Illegal invocation."

I have been utilizing a particular script to upload my image files. You can find the script here: http://jsfiddle.net/eHmSr/ $('.uploader input:file').on('change', function() { $this = $(this); $('.alert').remove(); $ ...

Display or conceal buttons based on the overflow height of another div

I want to dynamically show or hide buttons based on the overflow of a navigation list. If the list height overflows, display the buttons; if not, hide them. Using JQuery // This code snippet did not work for me! if($('#nav-list').prop(&apo ...

Modify the appearance of the PrimeReact navigation bar

I am struggling to change the background color of the navbar in my PrimeReact application. I have tried adding CSS styling in various places, but nothing seems to work. All I want is to customize the background color while keeping the default PrimeReact ...

ways to dynamically retrieve input values in PHP

Is there a way to dynamically add and remove data fields, as well as increase and decrease fields dynamically in PHP? I am looking to retrieve the subject value in an array or JSON format using PHP only. https://i.stack.imgur.com/HqDCz.png <div data-ro ...

get direct access to the children of a specific div element

Here is the code snippet in HTML format. <div id="this"> <a href="xxx"> xx</a> <a href="yy"> yy</a> <a href="zzz"> zzz</a> aaa <a href="bbb"> bbb</a> ccc </div> I am look ...

Populate the dropdown menu with data from a JSON file

Recently, I created a custom JSON file and wanted to populate a select>option using this data. However, I encountered an error message saying: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/.../p ...

Various hues blending and intertwining with one another

https://i.stack.imgur.com/zLrNK.png Could someone please clarify what is happening here? I'm attempting to change the background color to dodgerblue, but for some reason, the white background color is still showing through. Below is the code snippet ...

From Button to Picture Button

Having an issue with my dropdown menu. After selecting a location, clicking on the "go" button should direct me to another page. Here is the HTML code for the button: <input type="button" name="button" class="gobutton" onclick="openDir(this.form);"> ...

Issue: An unwanted horizontal scrollbar is generated upon inserting an image into a column using the Bootstrap 4 grid system

As a complete beginner in coding and web development, I'm facing a problem that I need help solving: I attempted to insert an image into the column within my Bootstrap 4 grid layout. However, upon adding the image, a horizontal scrollbar mysteriously ...

Guide on integrating CSS modifications into the iFrame for the Shopify Buy Button

I am trying to customize the styles of the iFrame for my buy button, but I am having trouble finding resources that specifically address these aspects. I do not want to disable the iFrame, just make some modifications to it: .shopify-buy__layout-vertical ...

Implementing dynamic class changes with *ngIf within a child component

Apologies if this question has been addressed before, I found two similar answers here: Question related | Close Solution An Angular Material Sidenav component contains three components. The parent component (highlighted in red) includes tab-like but ...

Overflow error in Rsuite table row cannot be displayed

Please see the image above Take a look at my picture. I am facing a similar issue. I am struggling to display my error tooltip over my table row. Has anyone else encountered this problem before? Any suggestions for me? I have attempted to set the overflow ...