`Problem with the layout of the form on the website`

Experiencing some challenges with the container design for a job sheet project. As a beginner, I have been learning on the fly and following online tutorials to create functional forms. However, this particular form is not rendering correctly when viewed on mobile devices like iPhone and Samsung.

The screen seems to be cutting off important sections at the top, making it difficult to access crucial information. Examples include the inability to view the top of the page on a Samsung Galaxy device or scroll up completely on an iPhone XR.

I attempted to adjust the positioning of the container by setting a 'top' style to 80%, which partially solved the issue but still left the bottom portion obscured. Experimenting with the 'bottom' property only worsened the problem. Tweaking various styles within the container did not yield any positive results either.

Changing the body styling, switching between percentage and pixel width/height measurements, adjusting overflow settings, and trying different combinations of dimensions did not resolve the truncation problem. The struggle continues to ensure the form displays correctly on all devices.

Answer №1

Your code currently uses a mix of centering methods, including flexbox and absolute positioning on body and .container. The absolute positioning with specific left/top/transform values in .container can lead to content overflowing the window at smaller screen sizes and is unnecessary given the flex settings applied to body. Remove the following lines from .container:

transform: translate(-50%,-50%);
position: absolute;
left: 50%;
top: 80%;

Here's the updated snippet without those unnecessary settings:

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');
* {
  padding: 0;
  box-sizing:border-box;
  font-family: 'Poppins', sans-serif;
}

body{
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    background: #ececec;
}
.container{
    background-color: #ffffff;
    min-width: 80%;
    overflow: auto;
    max-height:min-content;
    height:auto;
    padding: 3%;
    border-radius: 1%;
    box-shadow: 20px 30px 25px rgba(0,0,0,0.15);
}

.container .form {
    margin-top: 30px;
}

.form .input-box {
    width: 100%;
    margin-top: 2%;
}

.input-box label {
    color: #333;
}

.form :where(.input-box input, .select-box,) {
    position: relative;
    height: 50px;
    width: 100%;
    outline:none;
    font-size: 1rem;
    color: #707070;
    margin-top: px;
    border: 2px solid #ddd;
    border-radius: 1px;
    padding: 0 15px;
}

h1{
    font-size: 30px;
    text-align: center;
    color: #1c093c;
}

p{
    position: relative;
    margin: auto;
    width: 100%;
    text-align: center;
    color: #606060;
    font-size: 14px;
    font-weight: 400;
}
form{
    width: 100%;
    position: relative;
    margin: 30px auto 0 auto;
}
.row{
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px,1fr));
    grid-gap: 20px 30px;
    margin-bottom: 20px;
}
label{
    color: #1c093c;
    font-size: 14px;
}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap');
* {
    padding: 0;
    margin: 0;
    font-family: 'Poppins', sans-serif;
}

.flex-row {
    display: flex;
}

.wrapper {
    border: 1px solid #4b00ff;
    border-right: 0;
}

canvas#signature-pad {
    background: #fff;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

button#clear {
    height: 100%;
    background: #4b00ff;
    border: 1px solid transparent;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

button#clear span {
    transform: rotate(90deg);
    display: block;
}


textarea,
input{
    width: 100%;
    font-weight: 400;
    padding: 8px 10px;
    border-radius: 5px;
    border: 1.2px solid #c4cae0;
    margin-top: 5px;
}


textarea{
    resize: none;
}
textarea:focus,
input:focus{
    outline: none;
    border-color: #6f6df4;
}

button{
    border: none;
    padding: 10px 20px;
    background: linear-gradient(
        130deg,
        #6f6df4,
        #4c46f5
    );
    color: #ffffff;
    border-radius: 3px;
}

@media screen and (max-width: 500px) {
    .form .column {
      flex-wrap: wrap;
    }
  
    /*trying to style the button to be wrapped */
    .upload .up {
      flex-wrap: wrap;
    }
  }
<!DOCTYPE html>
<html lang="en">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Responsive Form</title>
    <!--Google Font-->
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap" rel="stylesheet">
    <!--Stylesheet-->
    <link rel="stylesheet" href="style.css">
    <!--Signaure pad link-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/signature_pad/4.1.7/signature_pad.umd.min.js"></script>
</head>

<body>
    
    <section class="container">
        <h1>Site Report Sheet</h1>
        <form action="#" class="form">

            <div class="row">
                <div class="column">
                    <label for="issue">Client details</label>
                    <textarea id="issue" placeholder="" rows="3"></textarea>
                </div>
            </div>

            <div class="row">
                <div class="column">
                    <label for="issue">Site Name & Address</label>
                    <textarea id="issue" placeholder="" rows="3"></textarea>
                </div>
            </div>


            <div class="row">
                <div class="column">
                    <label for="number">WIS Number</label>
                    <input type="text" id="number" placeholder="">
                </div>

                <div class="input-box">
                    <label>Date</label>
                    <input type="date" required/>
                </div>
            </div>

            <div class="row">
                <div class="column">
                    <label for="issue"></label>
                    <textarea id="issue" placeholder="Type here" rows="3"></textarea>
                </div>
            </div>

            <h4>THE ABOVE IS CERTIFIED CORRECT AND SYSTEM HAS BEEN LEFT IN <u>WORKING ORDER</u></h4> <br>

            <div class="row">
                <div class="column">
                    <label for="name">Name</label>
                    <input type="text" id="name" placeholder="">
                </div>

                <!--Signature pad-->

                <div class="flex-row">
                    <div class="wrapper">
                        <canvas id="signature-pad" width="400" height="200"></canvas>
                    </div>
                    <div class="clear-btn">
                        <button id="clear"><span> Clear </span></button>
                    </div>
                </div>

                <div class="row">
                    <div class="column">
                        <label for="number">On behalf of</label>
                        <input type="text" id="number" placeholder="">
                    </div>
                </div>

                <div class="column">
                    <label for="ename">Engineers Name</label>
                    <input type="text" id="ename" placeholder="">
                </div>


                <div class="column">
                    <label for="ename">Engineers Name</label>
                    <input type="text" id="ename" placeholder="">
                </div>



            </div>





        </form>
    </section>
    </div>
</body>

</html>

Lastly, applying a 20% margin to all elements via the * selector is not recommended. I have removed it from the provided code above.

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

What is the best way to organize and position numerous images and text elements within a flex container?

Currently learning the ropes of web development and working on a practice project. My goal is to utilize flexbox in order to achieve a layout similar to this design. Here's what I have so far: .flex-container { display: flex; align-items: cente ...

Reposition the element at the bottom of its parent element

I am facing an issue with the HTML structure in my application: <div class="work-item"> <div class="image-container"> </div> <div class="text-container"> </div> </div ...

Issue with MUI Grid item not functioning properly when using overflowY: "auto"

I am encountering an issue while using MUI with React. I have a <Paper> element wrapping a <Grid> with 3 children elements. The problem arises when I set the overflowY property of the bottom grid item to "auto" - instead of showing the scroll b ...

What is the best way to align the navbar items at the center in Bootstrap when mx-auto is not working?

<nav class="navbar navbar-expand-sm navbar-light"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls ...

The Enchanted URL Folder Name

Spent two painstaking hours dealing with this issue. It's incredibly frustrating. Struggling to load css files in PHP pages when the URL contains a folder named "adsq" Comparing two identical pages, only differing in the folder name: One works perf ...

Can you guide me on implementing an onclick event using HTML, CSS, and JavaScript?

I am looking for a way to change the CSS codes of the blog1popup class when the image is clicked. I already know how to do this using hover, but I need help making it happen on click instead. The element I want to use as the button; <div class=&quo ...

Creating a grid cell that spans the entire grid width

Snippet of CSS Code: .wrapper { display: grid; position: relative; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 25vh; width: 100%; } .prova { border: 1px solid; } .wrapper div:nth-child(2) { grid-column: 3; grid-row: 2 / 4; ...

Using WebDriver Selenium to choose an element within a table following another element

The webpage features a user details table with a functionality to delete users. To remove a user, I must select the row based on the username and then click the "Delete" button. The structure of the HTML table is as follows: <table id="tblUsersGrid" ce ...

The system encountered an issue with the CSS code, indicating "Invalid CSS after "...inear-gradient(": expected selector, was "{"

While attempting to compile my sass code, I encountered the following error message regarding a syntax issue: /* { "status": 1, "file": "C:/Users/faido/Desktop/Productivity/sass css/project/sass/main.sass", "line": 36, "column": 9, "mes ...

Unable to execute a JavaScript function when triggered from an HTML form

This is the code for a text conversion tool in HTML: <html> <head> <title> Text Conversion Tool </title> <script type="text/javascript"> function testResults(form) { var str = form.stringn.value; var strArray = str.split(" ...

Transparent CSS Table Styling

Can you create a CSS effect where all content inside a table becomes transparent on hover? For example: <table><tr><td> AN IMAGE </td> <td> SOME TEXT </td></tr></table> So if either the image or the text ar ...

Guide to modifying the behavior of a dynamic dropdown menu

Jquery: $('body').on('change', '.combo', function() { var selectedValue = $(this).val(); if ($(this).find('option').size() > 2) { var newComboBox = $(this).clone(); var thisComboBoxIndex ...

Utilizing jQuery to Calculate Tab Scores

Last week, my teacher and I collaborated on a fun game called rEAndom game (). The game is created using javascript, jQuery, and HTML5. One interesting feature of the game is that when you press the TAB key, a div displaying the score appears. You can chec ...

Create a div element within the parent window of the iFrame

I'm trying to figure out how I can click a button within an iFrame that contains the following code: <td class="id-center"> <div class="bs-example"> <a id="comments" href="comments.php?id=$id" name="commen ...

Is the "add" feature malfunctioning?

My code is experiencing an issue where the URL and ID are not being passed correctly from one function to another. When I click on a link that contains the add() function, it fails to capture the URL and ID. <a href="#" style="color:#FFF;" onclick="add ...

Updating content with jQuery based on radio button selection

Looking for assistance with a simple jQuery code that will display different content when different radio buttons are clicked. Check out the code here. This is the HTML code: <label class="radio inline"> <input id="up_radio" type="radio" n ...

Passing references using a personalized component

So, I've encountered this issue with my code: import MuiDialog from "@mui/material/Dialog"; import { styled } from "@mui/material/styles"; const TheDialog = styled((DialogProps) => ( <MuiDialog {...DialogProps} /> ))(( ...

Display the div if the input field is left blank

Is there a way to display the div element with id="showDiv" only if the input field with id="textfield" is empty? <form action=""> <fieldset> <input type="text" id="textfield" value=""> </fieldset> </form> <div id="sh ...

Automatically numbering text boxes upon pressing the enter key

Is there a way to automatically number textboxes when I type "1" and hit enter in one of them? For example, if I have 3 textboxes and I type "1" in the first one, can the other textboxes be numbered as 2 and 3 accordingly? <input type="text&qu ...

CSS styling for the dropdown list in the content/option section

Can someone help me with a simple question I've been researching for hours without success? I'm trying to figure out how to style the content/option/popup of a dropdownlist on the right side of the 'open button' like in this screenshot ...