I'm looking to arrange the elements in a similar layout as shown in the picture, but I'm unsure of how to do so

https://i.sstatic.net/ku01T.png i'm trying to arrange the elements inside the #gameInpBox similar to the image below

body{
  margin: 0px;
  font-family: 'Signika Negative', sans-serif;
  background-color: #252525;
  color: #f8f9fa;
}



.dim {
  
  background: rgba(0,0,0, 0.6);
  height: 100%;
  position: fixed;
  width: 100%;
  z-index: 30;
  display: block;
}

#gameInpBox{
  z-index: 31;
  height: 40vh;
  width: 50vw;
  position: absolute;
  top: 50%;
  left: 50%;
  background-color: #adb5bd;
  box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;
  transform: translate(-50%, -50%);
  border-radius: 15px;
}

.form{
  
}

label{
  text-align: left;
}

input{
  width: 10vw;
}

select{
  width: 8vw;
}

#Add{
  backface-visibility: hidden;
  
  font-family: 'Signika Negative', sans-serif;
  border: 0;
  border-radius: .375rem;
  box-sizing: border-box;
  color: black;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
  font-size: 2vh;

  letter-spacing: -.01em;
  line-height: 1.3;
  /* padding: 1rem 1.25rem; */
  position: absolute;
  text-align: center;
  text-decoration: none;
  transform: translateZ(0) scale(1);
  transition: transform .2s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  width: 10vw;
  height: 5vh;
  right: 2%;
  bottom: 1vh;
  box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}



#cancel{
  backface-visibility: hidden;
  
  font-family: 'Signika Negative', sans-serif;
  border: 0;
  border-radius: .375rem;
  box-sizing: border-box;
  color: black;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
  font-size: 2vh;

  letter-spacing: -.01em;
  line-height: 1.3;
  /* padding: 1rem 1.25rem; */
  position: absolute;
  text-align: center;
  text-decoration: none;
  transform: translateZ(0) scale(1);
  transition: transform .2s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  width: 10vw;
  height: 5vh;
  right: 24%;
  bottom: 1vh;
  box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}



#close{
  background: none;
  border: none;
  font-size: 25px;
  position: absolute;
  right: 5px;
  cursor: pointer;
  color: #252525;
}
<!DOCTYPE html>
<html lang="en">
<head>

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Fira+Mono&family=Signika+Negative:wght@300&display=swap" rel="stylesheet">
    <style>
    @import url('https://fonts.googleapis.com/css2?family=Fira+Mono&family=Signika+Negative:wght@300&display=swap');
    </style>

    <meta charset="UTF-8">
    <link rel="stylesheet" href="styles.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Overwatch Tracker</title>
</head>
<body>
    <div class="dim" id="dim">
        <div id="gameInpBox">
            <button id="close">✖</button>
            <div id="inps">
                <form class="form">
                    <label for="dmg">Damage delt:</label><input type="text" id="dmgSEL" name="dmg">
                    <label for="heal">Healing done:</label><input type="text" id="healSEL" name="heal"><br>
                    <label for="resault">Resault:</label><select name="resault" id="resaultSEL">
                        <option value="Win">Win</option>
                        <option value="Draw">Draw</option>
                        <option value="Loss">Loss</option>                        
                    </select>
                    <label for="role">Role:</label><select name="role" id="roleSEL">
                        <option value="DPS">DPS</option>
                        <option value="Support">Support</option>
                        <option value="Tank">Tank</option>                        
                    </select>
                    <label for="map">Map:</label><select name="map" id="mapSEL">
                        <option value="Illios">Illios</option>
                        <option value="Kings-row">Kings row</option>
                        <option value="NQS">NQS</option>                        
                    </select>
                    
                </form>
                <button id="cancel">Cancel</button>
                <button id="Add">Add</button>
            </div>
        </div>
    </div>
  
    
    <script src="scripts.js"></script>
</body>
</html>

Answer №1

After reviewing your code, it seems like you can achieve the desired layout by setting the display property to flex and the flex-direction to column for your "form" class. This will ensure that everything flows from top to bottom.

.form {
    display: flex;
    flex-direction: column;
}

To align your label and input elements on the same line, you can use float or wrap each in a div with a flex display for more flexibility in positioning. Setting a width on your .form div and using justify-content: space-between will help position the label to the left and the input field to the right, similar to what is shown in your wireframe.

.form-wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: space-between;
}
<div class="form-wrapper">
  <label for="dmg">Damage delt:</label>
  <input type="text" id="dmgSEL" name="dmg">
</div>

Great suggestion, best of luck with your project!

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

Sorting custom strings in Javascript with special characters like dash (-) and underscore (_)

I am attempting to create a custom sorting method with the following order: special character ( - first, _ last) digit alphabets For instance, when sorting the array below var words = ['MBC-PEP-1', 'MBC-PEP01', 'MBC-PEP91&apo ...

Can you explain the purpose of this function on Google PlusOne?

Within the code snippet below: (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByT ...

The jQuery Validate Plugin only validates emails when the user moves away from the input field

Resolved: Upon inspecting my version of jquery-validate.js, I discovered that it was missing the onkeyup handler. Despite using version 1.12 Opre, which should have had this functionality according to its Github history from 2013, it seemed like there may ...

What is the best way to hide the select arrow in an input-group using Bootstrap 4?

Is there a way to get rid of the unsightly double arrow in the select element? I have tried various solutions I found online, but none seem to be effective. <div class="form-group"> <label for="date">Date</label> <d ...

Getting started with TypeScript in combination with Node.js, Express, and MongoDB

I'm a beginner in working with TypeScript, Node.js, Express, and MongoDB. I need guidance on the end-to-end flow for these technologies. Can someone please suggest steps or provide links for a step-by-step process? What is the procedure to compile/r ...

Issue: Module 'curl' is not located at Function.Module._resolveFilename (module.js:489:15)

After installing node.js using the Windows installer, I noticed that the folder structure created was C:\Program Files\nodejs\node_modules\npm\node_modules. It seems like all the module folders are in the last node_modules director ...

Causes for the display of the text within the alt attribute

Recently, I attempted to view an HTML page in text browsers and noticed that the alt attribute value of the img tag was visible. I decided to omit the alt attribute and instead utilized CSS: .headerImg:after, .headerImg::after { conte ...

Accessing variables in subfunctions proves challenging for Node.js

Here is a function I've been working on to calculate the total price for a checkout process. However, when I console.log() the variable before it is returned, I get 0. But if I log the variable inside the findOne() function, I get the correct value. ...

Utilize JavaScript to mimic the submission of a form with a function call

Using jQuery, we have the ability to mimic form submission: <form id="form1" method="post"> <input name="key1" value="value1" /> <input name="key2" value="value2" /> </form> By making an AJAX function call: $.post('& ...

Output each uploaded file using jQuery's console.log function

My AJAX upload form is set up and working, but when multiple files are selected they all upload at once. I want to create a separate div for each file to show the progress individually. However, when I try to test the number of files using this code snippe ...

"Bootstrap4 - Troubleshooting the Issue of Multiple Carousels Not Function

I attempted to incorporate 2 Bootstrap 4 carousels onto a single page, but encountered issues with the functionality. I utilized this code on my page, however, the last element in the carousel does not cycle correctly. There is a delay of 3 transactions be ...

vue-router incorrectly updates parameters upon reload

One question I have is related to routing in Vue.js: // routes.js { path: '/posts', name: 'Posts', component: PostsView }, { path: '/post/:post_id', name: 'PostRead', component: PostReadView, }, { pat ...

Tool to stop automatic logouts on websites

In the web application where I work, users are automatically logged out after a period of inactivity. Unfortunately, I am unable to control this feature. The code responsible for logging the user out is as follows: var windoc = window.document; var timeou ...

A guide on detecting overflow in a React functional component

I am in search of a way to determine if a div contains overflowing text and display a "show more" link if it does. While researching, I came across an insightful Stack Overflow answer on checking for overflow in a div. The answer suggests implementing a fu ...

How to create a PHP MySQL weekly calendar with pagination for Monday to Friday events in 7 days?

Looking for the best approach to create a "7 day calendar" in the form of an HTML table with columns for "Name, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday". Each row in the table will display data from a database, including the pers ...

Utilizing an EJS template within an express.js application to extract and assign data to a variable

Is there a way to transfer data from my node.js (express) app directly to a variable within the <script> tag on the page? On the server-side, I have the following code: let tmp = JSON.stringify(await f(i)); console.log(tmp); //correct data [{"i ...

What is the proper way to integrate three.js (a third-party library) into the view controller of an SAPUI5 application

Seeking a Solution Is there a way to integrate the three.js library into SAPUI5 in order to access it using THREE as the root variable in my main view controller? I attempted to create a directory named libs within my project folder and include it in the ...

Various settings in JQuery UI Slider

Does anyone know how to customize the steps in a jQuery UI slider? I want to set specific values as steps, like 0, 1200, 2000, 2200, and 3000. Any suggestions on how to achieve this? const rangeSliderInit = () => { const valueArray = [0, 400, 1000, 1 ...

The HTML form submission button fails to submit the form and instead just refreshes the page

I'm struggling to get the save button working on my Chrome Extension settings page. The .click() event doesn't seem to be activating at all. I've included my code below. Should I use the commented out button instead (see below)? HTML <! ...

The "flickering" effect of the div is like a dance, moving gracefully between fade outs and

I am encountering a similar issue as described in this thread: same problem (fiddle: original fiddle). However, I am still learning JavaScript and struggling to apply the solution provided because my HTML code is slightly different. Can someone please assi ...