Displaying items using the flex property can cause the top resize feature to be unreachable

My issue revolves around the display of input errors, which are causing the top section to become inaccessible. I am looking for a solution that will align the content both vertically and horizontally in the center. The challenge arises when the card contains varying numbers of inputs, as it may or may not need to be centered.

To address this problem, I have experimented with different CSS properties such as removing 'align-items: center;' and trying 'margin: auto;', but so far none have provided a satisfactory solution.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  flex-flow: wrap;
  align-items: center;
  justify-content: center;
  background: url(../img/bg.png) center no-repeat;
}

.card {
  z-index: 10;
  position: absolute;
  height: max-content;
  width: 30%;
  border-radius: 42px;
  display: flex;
  flex-direction: column;
  background-color: #cecece;
}

.container {
  padding-left: 80px;
  padding-right: 80px;
}

input {
  margin-top: 50px;
  margin-bottom: 50px;
}

The issue with the accessibility of input 1 is depicted in the image shared here. When the 'card' expands, the top portion becomes unreachable due to the presence of errors at the top and bottom margins.

Answer №1

It seems like this is the solution you've been searching for. I have made some adjustments to the code and now it is functioning properly, even when the page is displayed in a smaller size and the child elements input are not overflowing.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url(../img/bg.png) center no-repeat;
}

.card {
  z-index: 10;
  position: absolute;
  height: max-content;
  width: 40%;
  border-radius: 42px;
  display: flex;
  flex-direction: column;
  background-color: #cecece;
}

.container {
  display: flex;
  justify-content: space-around;
  flex-direction: column;
  position: relative;
  padding: 10px;
}

input {
  margin-top: 50px;
  margin-bottom: 50px;
}
<!DOCTYPE html>
<html lang="pt-br">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
  <div class="card">
    <div class="container">
      <input type="text" name="" id="" placeholder="test 1">
      <input type="text" name="" id="" placeholder="test 2">
      <input type="text" name="" id="" placeholder="test 3">
      <input type="text" name="" id="" placeholder="test 4">
      <input type="text" name="" id="" placeholder="test 5">
      <input type="text" name="" id="" placeholder="test 6">
      <input type="text" name="" id="" placeholder="test 7">
      <input type="text" name="" id="" placeholder="test 8">
    </div>
  </div>
</body>

</html>

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

Rmarkdown, displaying tables without revealing the underlying latex code in the final output

I've encountered a problem with my rmarkdown code - the table output is not displaying and appears blank. I'm stumped on how to fix this issue. title: "Title" output: html_document: default pdf_document: default header-includes: - & ...

How can I efficiently verify page references using tools like CSS, JavaScript, and more?

I have Firebug (my team lacks Firefox) and the IE developer toolbar (IE7), but I'm struggling to easily validate if the referenced files in a page are loading. I see Javascript errors, but they don't lead me directly to the exact file in the hier ...

Is there a way to display a secondary header once the page is scrolled down 60 pixels?

.nav-header2{ background: purple; display: flex; justify-content: center; align-items: center; } .header2-container{ width: 68vw; height: 60px; padding: 0 2vh; border: 1px solid red; ...

Implementing a Radial Cursor with a Custom Background Image in JavaScript

I am attempting to implement a radial cursor on a website that features a background image. Currently, I am facing two main issues: The radial cursor works in Chrome but not in Firefox. When using Firefox, I encounter a parsing error related to the "bac ...

Utilize html5 to drag and drop numerous items effortlessly

Recently, I created a basic HTML5 drag and drop feature using JavaScript. However, I encountered an issue. function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("text", ev.target.id); } function drop(ev) { ...

Setting a variable equal to user input

When using a jQuery script, the elements for the details are dynamically created inside a jQuery function. However, there seems to be an issue with assigning the value from the variable "startLocation" to the input "detail_startLocation[]". Only the firs ...

Utilizing nested HTML within an HTML tag

Recently, I've been exploring the concept of nested HTML in Bootstrap. While following a tutorial on using Popovers, I encountered the following code; <button id="btn3" type="button" class="btn btn-primary show" ...

Prevent a function from executing using ClearTimeout()

Looking for a way to control the progress of my progress bar using two buttons. Here's the code snippet: <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0 /jquery.min.js"></scr ...

Vue is actively eliminating a background image through the use of the style attribute

There appears to be an issue where Vue is removing both the style attribute and the background image from this tag. <section style="background: url(images/banners/profiles/profile-banner-1.png);" class="profile-banner flex items-end md:items-end md:j ...

Finding HTML tag with a particular attribute in Swift

Is there a way to extract specific attribute tags from an HTML link? Currently, I am using the following code to retrieve the page content using SwiftSoup: // Checking if MyLink is working guard let myURL = URL(string: MyLink) else { ...

Modifying the border of images in a Weebly gallery

I'm having trouble changing the gallery image borders on Weebly. The client prefers using Weebly for easy backend editing once the design is in place, so I need to work within these parameters. Usually, I can make most code edits easily...but this iss ...

Fancybox is experiencing some technical difficulties

Can anyone help me troubleshoot why my fancybox code isn't working properly after adding the script below to the body? Any thoughts on what might be causing this issue? $(document).ready(function() { $("a#example4").fancybox({ 'opa ...

What is the reason this JavaScript code functions properly within a <script> tag but not when placed in a separate .js

After researching various image sliders online, I came across this specific one. It worked perfectly fine when I included the JavaScript directly in a script tag within the HTML file. However, as soon as I tried to link it via a .js file, the slider stoppe ...

The ng-include feature seems to be malfunctioning

After building a basic web page using AngularJs, I ran into an issue when attempting to integrate header.htm into index.html - nothing was displaying in the browser. index.html <html> <script src="https://ajax.googleapis.com/ajax/libs/angul ...

Designing a nested box layout with bootstrap HTML/CSS styling

Can anyone provide guidance on how to create a HTML/CSS layout similar to the image below? I am specifically struggling with designing the silver "Add corkscrew" box, a white box beneath it, and then another silver box nested within. Any suggestions on ho ...

Ensuring the next tab is not accessible until all fields in the current tab are filled

I am working on a form with a series of questions displayed one at a time, like a slide show. I need help with preventing the user from moving to the next set of questions if there is an empty field in the current set. Below is the script I am using to nav ...

Modifying the cursor presentation in the Atom editor

Hey there, I'm curious if there is a method to customize the caret style in Atom similar to how it's done in Sublime Text 3. In Sublime Text 3, you can change the caret style using this JSON setting: "caret_style": "phase" Is there a comparable ...

pictures showcased in a grid that dance and sway

Hey everyone, I wanted to ask about images on a website that have a unique effect when you hover over them. On the site follow your feet website, there is a grid section of destinations and when you move your mouse over a destination, it suddenly expands a ...

Creating trails by following the cursor's movement in KineticJS

Currently, I am working on a drawing application using KineticJS. While I have successfully used it to draw shapes and straight lines by following the method outlined in KineticJS - Drawing Lines with Mouse, I now need to draw a line along the mouse's ...

Transitioning images while hovering over a different element

Need some inspiration for a school project? I'm stuck on how to create a smooth image fade effect in CSS when hovering over another element (like an anchor link) on the same page. I've been attempting to use the :target and not(:target) selector ...