What is the process for creating two columns with an input box beneath them?

I am facing a challenge with my code. I am struggling to create the desired design where there are two columns and below them an input box that will be displayed when a button is pressed. The design I am aiming for can be viewed here: enter image description here Below is the HTML code I currently have:

<!DOCTYPE html>
    <html>
    <head>
    <!--<link rel="stylesheet" type="text/css" href="raboti.css">-->
    <h1>Calculator</h1>
    
    <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">-->
    <link rel="stylesheet" type="text/css" href="withbootstat.css">
    </head>
    <body>
    
    <div class="row">
    <div class="dropDown" style="background-color: #efefef;">
    <h2>Number of Employees:</h2>
    <select id="mySelect">
    <option value="1">1-10</option>
    <option value="2">11-30</option>
    <option value="3">31-80</option>
    <option value="4">81-150</option>
    <option value="5">151-300</option>
    <option value="6">300+</option>
    </select>
     
    </div>
    
    <div class="dropDown" id="monthCost" style="background-color: #efefef;">
    <h2>Monthly Cost($):</h2> <input type="text" id="ourSum">
    </div>
    </div>
    
    <div class="row1">
    <div class="sum" id="finalSum">
    The cost with us will be: <input class="hide type="text" id="result" >
    <br><button type="button" onclick="sum()">Calculate</button>
    
    </div>
    </div>
    
    </body>
    </html>
This snippet was obtained from W3Schools for creating two columns. And here is my CSS code:

* {
        box-sizing: border-box;
    }
    .dropDown {
        float: left;
        width: 50%;
        padding: 10px;
        height: 300px; /* Should be removed. Only for demonstration */

    }
    .row:after {
        content: "";
        display: table;
        clear: both;
    }
    @media screen and (max-width:600px) {
        .dropDown {
            width: 100%;
        }
    }
    h1 {
        text-align: center;
    }
    .row1 {
        margin-top: -200px;
        margin-left: 100px;
    }
    .hide{
      display:none;
    }
    .show{
      display:block;
    }

Answer №1

After reviewing your photo, it appears that you can achieve your desired layout using flexbox:

.flex-center {
  justify-content: center;
  align-items: center;
}

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

.flex-justify-around {
  justify-content: space-around;
}

.w-100 {
  width: 100%;
}

.mr-50 {
  margin-right: 50px;
}

.ml-50 {
  margin-left: 50px;
}

.round-box {
  border: 2px solid #ccc;
  border-radius: 150px;
  padding: 20px;
}

.d-flex {
  display: flex;
}

.grow {
  flex: 1 0 0;
}

.flex-wrap {
  flex-wrap: wrap;
}

.p-40 {
  padding: 40px;
}

.pt-0 {
  padding-top: 0 !important;
}

.pr-40 {
  padding-right: 40px;
}

.pl-40 {
  padding-left: 40px;
}

.bg-blue {
  background-color: #00B6FD;
  color: white;
}

.text-blue {
  color: #00348C;
}

.font-weight-bold {
  font-weight: bold;
}
<div class="d-flex flex-center flex-column flex-wrap text-blue">
  <div class="d-flex flex-center flex-column">
    <h1>Calculator</h1>
  </div>
  <div class="d-flex flex-center flex-justify-around w-100 flex-wrap">
    <div class="d-flex flex-column grow p-40 pt-0">
      <h4>Question</h4>
      <input type="text" class="round-box " id="bx-1"/>
    </div>
    <div class="d-flex flex-column grow p-40 pt-0">
      <h4>Answer</h4>
      <input type="text" class="round-box" id="bx-1"/>
    </div>
  </div>
  <input type="button" value="Submit" class="round-box pl-40 pr-40 bg-blue font-weight-bold"/>
</div>

For a live demonstration, check out this example on CodePen :)

Keep in mind that the design should be responsive as well ;)

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

Tips for creating an endless scrolling/loader feature in Nuxt?

Hey there! I am looking to display data after implementing infinite loading. The data is sent asynchronously using asyncData to the page with an ID. Page <script> export default { async asyncData({ $axios, store }) { const customerId = store.g ...

What is the best way to utilize window.find for adjusting CSS styles?

Incorporating both AJAX and PHP technologies, I have placed specific text data within a span element located at the bottom of my webpage. Now, my objective is to search this text for a given string. The page consists of multiple checkboxes, with each check ...

Using React Hooks to render radio buttons within a map iteration

My code contains a nested map function where I try to retrieve values from radio buttons. However, the issue is that it selects all radio buttons in a row instead of just one. Below is the snippet of my code: <TableHead> <TableRow> ...

How can I show HTML content in a ListView on an Android device?

One way I am populating a ListView from a database is by using the following code. The only difference is that the COL_TXT_TRANSL2 field contains HTML formatting: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ...

IItemTransform and minified files that are already in use

Summary: IItemTransform is not triggered when a minified file already exists in the same directory as the original (non-minified) file. Issue Description The problem arises due to CSS relative image references, impacting both JavaScript and CSS files when ...

Issue detected: data exceeds limits (length=3, offset=32, code=BUFFER_OVERRUN, version=abi/5.0.7) within next-js and ethereum

While working on my Ethereum and Next.js project, I encountered an error during the initialization of the project: Error: data out-of-bounds (length=3, offset=32, code=BUFFER_OVERRUN, version=abi/5.0.7) at Logger.makeError (/home/Documents/projects/eth ...

Retrieving Axios error codes within an interceptor

How can error codes like ERR_CONNECTION_REFUSED (indicating the API server is down) and ERR_INTERNET_DISCONNECTED (indicating the local network is down) be accessed when using response interceptors with axios in client-side JavaScript, React, etc.? While ...

Finding the correct tablet browser resolution for optimal web design

Is there a way to accurately determine the browser resolution for CSS on Samsung Galaxy Tab A 10.1 or other tablets? Despite the specifications stating that the resolution is 1920 x 1200, I am having trouble finding the correct resolution online. As I hav ...

Extracting targeted information from web pages using Python

I'm a newcomer to python and I'm currently working on an interface. My task is to retrieve the top 250 movies from the IMDb website. def clicked(self): movie=self.movie_name.text() url="https://www.imdb.com/chart/top/" ...

Tips for utilizing the simple-peer module within a Node.js environment?

I recently started using Node.js and I'm interested in incorporating the simple-peer module into my application. However, I am struggling to understand how to implement it based on the provided documentation. Are there any resources available that can ...

Send the form using an alternative method to avoid using preventDefault

Having some trouble with my website's sign-in functionality not working properly on all browsers. In Firefox, I keep getting a "ReferenceError: event is not defined" error. I've read through various posts about preventDefault behaving differentl ...

Retrieving user input in Angular and showcasing extracted keywords

I want to give users the flexibility to customize the format of an address according to their preference. To achieve this, there will be a text input where users can enter both keywords and regular text. The goal is to detect when a keyword is entere ...

The issue with the functionality of position absolute in CSS when used with JavaScript

<html> <head> <style> #wrapper{ position: absolute; top : 250px; width: 500px; height: 500px; border: 1px solid red; } .tagging{ position: absolute; border: 1px solid black; width : 20px; height: 30px; } & ...

Ensure that text within openhtmltopdf is aligned to the right and any unnecessary white space at the

Currently, I am using the open source project openhtmltopdf but I have encountered a certain issue. Within a div-element, I have a p-tag with text-align: right styling. The text is aligned correctly to the right until there is a line break due to the widt ...

Jquery animation in Wordpress without any need for scrolling

My Wordpress site features some animations that work flawlessly when the site is scrolled. The code looks like this: jQuery(document).ready(function($){ $(window).scroll( function(){ if(!isMobile) { $('.animate_1').each ...

Raycasting is functioning properly on objects created within the program, however, it seems to be ineffective on imported OBJ models

As a newcomer to three.js, I am currently exploring raycasting and encountering some confusion regarding its functionality with imported 3D models. Specifically, when I import an obj model and attempt to determine if there is contact with the imported 3D ...

Issues arising from the event target

What is the reason behind this code functioning successfully only when the alert function is called? The color changes after closing the alert box, but if the line with the alert command is commented out, nothing happens. function setLinkColor(el) ...

Order dates within an array by year in descending order, followed by arranging by month in ascending order, and then sorting

Upon receiving data from an AJAX to PHP call, I am presented with an array containing information about classes and the dates they were offered. Let's refer to this array as 'data': var data = [{ "course": "Mathematics", "courseDate": " ...

Validation of PO Box Addresses Using Regular Expressions

I'm having trouble getting the alert to work with my code. $(document).ready( function (){ $("[id*='txtAddress1S']").blur(function() { var pattern = new RegExp('\b[P|p]*(OST|ost)*\.*\s*[O|o|0]*(ffice|FFICE)*& ...

bootstrap 5 with uneven spacing

I am working on some HTML/CSS code that utilizes Bootstrap 5.2 and the justify-content-between class in order to move two buttons to the edges of a container. <div class="container"> <div class="row"> <div cla ...