The issue with displaying inline block is that the divs are not appearing side by side on the

Two of my div elements, namely form-panel and data-panel, are currently not aligned on the same line. How can I use display:inline-block to align them in a single line? Please review the code provided below. I have already used display:inline-block on both panels, but their alignment remains offset.

var data=[
{"name":"Test Task#1","date":"12/01/2012","assigned":"John Doe"},
{"name":"Test Task#2","date":"12/02/2012","assigned":"John Doe"},
{"name":"Test Task#3","date":"12/03/2012","assigned":"John Doe"},
{"name":"Test Task#4","date":"12/04/2012","assigned":"John Doe"},
{"name":"Test Task#5","date":"12/05/2012","assigned":"John Doe"},
{"name":"Test Task#6","date":"12/06/2012","assigned":"John Doe"},
{"name":"Test Task#7","date":"12/07/2012","assigned":"John Doe"}
];
function load() { 
var tableData="";
var stage=$("#stage");
$.each(data,function(i){
          stage.prepend('<tr><td>  ' + data[i].name + '</td>'+'<td> ' + data[i].date+ '</td>'+'<td style="width:30px;"></td><td> ' + data[i].assigned+ '</td></tr>');
  });
}
$( document ).ready(function() {
$( "#sfrm" ).on( "submit", function( event ) {
event.preventDefault();
showValues();
 
});
function showValues() {
    var str = $( "form" ).serializeArray();
    var dateArr = str[1].value.split('-');
   dateArr.push(dateArr.shift());
   var date=dateArr.join('/')
$( "#stage" ).prepend( '<tr><td>  ' + str[0].value + '</td>'+'<td> ' + date + '</td>'+'<td style="width:30px;"></td><td> ' + str[2].value + '</td></tr>');
  }
});
body{
margin: 0px;
padding: 0px;
font-family: arial;
}
.background_panel{
width: 1024px;
margin: 0px auto;
background-color: #e2e2e2;
padding: 10px;
margin-top: 85px;
overflow: auto;
}
h1{
  position: relative;
  z-index: 1;
  margin-bottom: 0;
}
.main_panel{
  background-color: #ffffff;
  padding: 10px;
  position: relative;
}
input[type="text"],input[type="date"]{
height: 40px;
font-size: 16px;
width: 90%;
border: 1px solid #dedede;
background-color: #ececec;
border-radius: 6px;
}
input[type="submit"]{
background-color: #434343;
border: 1px solid #ececec;
border-radius: 6px;
padding: 10px;
color: #fff;
font-size: 18px;
}

.content{
position: relative;
}
.form_panel{
width: 47%;
padding: 10px;
display: inline-block;
background-color: white;
}
.data_panel{
background-color: white;
display: inline-block;
width: 48%;
padding: 10px;
}
.clear{
clear: left;
}
.main_header{
  border: 1px solid #f0f0f0;
  min-height: 120px;
  background-color: #f0f0f0;
  z-index: 1;
  padding: 10px;
}
hr{
  width: 3px;
  height: 370px;
  position: absolute;
  left: 490px;
  background-color: #f0f0f0;
  border: 1px solid #f0f0f0;
  border-radius: 5px;
  top: -12px;
}
table{
border-collapse: collapse;
border: 3px solid #dedede;
border-radius: 6px;
}
td{
padding: 9px;
}

tr:nth-child(even){
background-color: #cecece;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
    <meta name="author" content="Spino Tutorials" />
<title>Task Tracker</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body onload="load()">

<div class="background_panel">
<div class="main_header">
<h1>Task Tracker</h1>
<span>v2.0</span>
</div>
<div style="vertical-align:top">
<div class="form_panel">
<h3>Create a Task</h3>
<form id="sfrm">
Task Name<br>
<input type="text" name="task" ><br><br>
Date<br>
<input type="date" name="date"><br><br>
Assigned To<br>

<input type="text" name="assigned" ><br><br>
<input type="submit" id="target" value="Submit">
</form>
</div>
<div class="data_panel">
<h3>Existing Tasks</h3>
<table id="stage" style="table-layout: fixed; max-height: 350px;"></table>
</div>
</div>
 <div class="clear">
 
 </div>
</div>
</body>
<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/functions.js"></script>
</html>

Answer №1

Instead of applying vertical-align: top to the parent div, add it to both individual divs.

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

Is it possible to preserve the query parameters from the previous page using Vue Router's Navigation guard feature?

Hey there! So, I'm looking to pass a query from the current page to the next one without manually coding it into all of my push functions. I was wondering if there's a way to do this through Navigation guard or some hooks? I did some research an ...

How can you style text with a circular border using CSS?

I'm struggling to locate an example of what I need. My goal is to make a circle around my text using CSS. While I've seen examples of circles with the text inside, in this case, I aim to have a circle surrounding the text. Here's an illustr ...

Encountering issues with JSON.Parse in JavaScript leads to errors

I'm encountering issues with JSON parsing in my code and I can't figure out the cause of it. I have a function that calls two ajax functions, one at the start and another in the success function. Everything seems to be working fine until I try to ...

Executing a method to retrieve a value from an empty function in Node.js

I am currently dealing with the code snippet below: function done(err, file) { //handling of code here return "test"; } function process() { retext() .use(keywords) .process(sentence, done); return val; } The proce ...

What is causing the breakdown in communication between my server and client?

While utilizing React and an Express server for the backend, I am facing an issue where my API call to server.js is not going through. The React client is running on port 3001 and the server on port 3002. The fetch code in CreateAccount.js is as follows: ...

Tips on setting a singular optional parameter value while invoking a function

Here is a sample function definition: function myFunc( id: string, optionalParamOne?: number, optionalParamTwo?: string ) { console.log(optionalParamTwo); } If I want to call this function and only provide the id and optionalParamTwo, without need ...

Avoid the ability for individuals to interact with the icon embedded within a button

I'm currently working on a website where users need to interact with a button to delete an "Infraction." The button has a basic bootstrap style and includes an icon for the delete action. <button referencedInfraction="<%= i.infractionID %>" ...

How can you use JavaScript to create a JSON object using values from an HTML form textarea and then send

I need to create an HTML form that will send specific information in the Http-request body. { “info” : { “id” : “123” “text1” : <data from html text-box> } Therefore, my goal is to convert the provided data into a JavaScri ...

What is the reason for browsers changing single quotation marks to double when making an AJAX request?

Jquery: var content = "<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='IE=edge'><meta name='viewport' content='w ...

Tips for incorporating "are you sure you want to delete" into Reactjs

I am currently working with Reactjs and Nextjs. I have a list of blogs and the functionality to delete any blog. However, I would like to display a confirmation message before deleting each item that says "Are you sure you want to delete this item?" How ...

Having Multiple Login Forms on a Single Page

I have encountered an issue with my login form code. It works perfectly as a single form, but I need to have 20 of these forms on one page. Despite my efforts to duplicate the code for each new form and adjusting the IDs, I am unable to make more than one ...

Use jQuery to retrieve HTML content excluding comments

Take a look at the code snippet below. HTML: <div> <p>sdfsdfsfsf</p> <!--<p>testing</p>--> </div> JQUERY $(document).ready(function(){ alert($("div").html()); }); OUTPUT <p>sdfsdfsfsf</p> & ...

Is it possible to refrain from using the object variable name in an ng-repeat loop?

When utilizing an ng-repeat directive to loop through an array, the syntax requires ng-repeat="friend in friends". Inside the template, you can then use the interpolation operator like this {{friend.name}}. Is there a way to directly assign properties to ...

Steer clear of using inline styling when designing with Mui V5

I firmly believe that separating styling from code enhances the clarity and cleanliness of the code. Personally, I have always viewed using inline styling (style={{}}) as a bad practice. In Mui V4, it was simple - I would create a styles file and import i ...

Implementing CSS keyframes when a specified PHP condition is satisfied

I am looking to implement an opening animation on my website that should only play when a user visits the site for the first time. I want to avoid displaying the animation every time the page is reloaded, so it should only run if a cookie indicating the us ...

Unable to stop submission as a result of ajax verification

As someone new to java and jquery, I am facing a challenge with the code below: $(document).ready(function() { //Prevent SUBMIT if Session setting = On (Ajax) $('#formID').submit(function(e) { var prevent = false; $.ajax({ type: ...

Encountering a 403 error while attempting to install Meteor with npm using the command npm install -

Following the installation instructions provided on the official Meteor website at , I encountered an error while trying to install Meteor using the command "npm install -g meteor". Here is the detailed error message: os  win 10 pro node -v  v14.15.1 n ...

The animation loop completes and restarts from the initial keyframe

I have a CSS animation that I want to play through once and then stop at the final keyframe. However, currently it keeps returning to the initial keyframe and stopping there instead of reaching the end. The animation involves a title heading that gradually ...

Conceal the background of the lower div when the top div is displayed

I am struggling to figure out how to achieve this, or if it can even be done: <body> has a background image <div parent> has a background image <div child></div> does not have a background </div> My goal is to make the chi ...

Retrieving text data in Controller by utilizing jQuery AJAX request

Text box and button for input <input type="text" class="form-control" name="ClaimNumber" placeholder="Enter a claim number" id="ClaimNumber" /> <button class="btn btnNormal" type="submit" id="btnSearch"> ...