The div block containing the table is experiencing horizontal overlap as additional elements are inserted

When creating a table within the div section of the code, I am incorporating text using the DRAG and DROP feature with appropriate styling. The table adjusts in size when I resize my window, indicating that it is functioning correctly.

However, as the number of elements increases in the table, it expands horizontally even though only 66.67% of the window has been allocated to the div element.

Below is the code snippet:

<div class = "container">
    <div class="row" >

        <div class="col-md-8" >

            <h1 >Selected Courses</h1>
            <table width = "100%"  order="5" cellspacing=0 cellpadding=5>

                <tr>
                    <td width="100%"  id="red" ondrop="dropIt(this, event)" ondragenter="return false" ondragover="return false">
                        <span draggable="true" id="lt1" ondragstart="dragIt(this, event)"><rc>RC</rc></span> 
                    </td>
                </tr>

            </table>  

        </div>


        <div class="col-md-4" >
            <h1 >Select Your Courses</h1;

            <table width = "100%" border="5" cellspacing=0 cellpadding=5>
                <tr>

                    <td valign="bottom" align="left" id="holder" ondrop="dropIt(this, event)" ondragenter="return false" ondragover="return false">
                        <span draggable="true" id="lt" ondragstart="dragIt(this, event)"><cse>CSE114</cse></span>
                        (more course elements go here)...
                    </td>

                </tr>
            </table>;
        </div>
    </div>
</div>

https://i.sstatic.net/nWDXi.png

When dragging elements from the right box to the left, an issue arises where if the number of elements in the left box exceeds its capacity, they overlap into the right box area.

Here is the JavaScript code used for drag and drop functionality:

<script>
    function dragIt(target, e) {
        e.dataTransfer.setData('SpanImg', target.id);
    }
    
    function dropIt(target, e) {
        var id = e.dataTransfer.getData('SpanImg');
        target.appendChild(document.getElementById(id)); 
        e.preventDefault();
    }
    
    function trashIt(target, e) {
        var id = e.dataTransfer.getData('SpanImg');
        removeElement(id);
        e.preventDefault();   
    }
    
    function removeElement(id)  {
        var d_node = document.getElementById(id);
        d_node.parentNode.removeChild(d_node);
    }
</script>

CSS Styling:

.title {
    color: rgb(0, 207, 255);
}

(description, screenshot, app, text, etc...)...

Answer №1

Simply include this line to ensure that EVERYTHING IS FINE..

CHECK OUT THE DEMO HERE

td span{
    float:left;
}

Essentially, make sure your additional spans are floated to the left

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

Utilizing .env Variables in NestJS Main App Module for Establishing Database Connection

I recently embarked on my first NestJS project, where I initially had a hardcoded database connection string in app.module.ts that worked perfectly fine. However, our project requirements called for fetching the database configuration values from environm ...

Sending a blob through AJAX to a different domain using CORS

Could someone please explain why my current request is being blocked by the SO policy restriction? Javascript Code: var blob = new Blob([req.response], {type: "application/octet-stream"}); req = new XMLHttpRequest(); req.open("POST", ws_path(other_contex ...

Create original identifiers for dynamically generated material

I have developed a custom invoice tool that has the capability to dynamically add rows. Here is the code snippet responsible for generating new rows: $("#addrow").click(function(){ $(".item-row:last").after('<tr class="item-row"><td> ...

Exploring the asynchronous nature of componentDidMount and triggering a re-render with force

I am puzzled by the behavior in the code provided. The async componentDidMount method seems to run forceUpdate only after waiting for the funcLazyLoad promise to be resolved. Typically, I would expect forceUpdate to wait for promise resolution only when wr ...

Problems arising from positioning elements with CSS and organizing list items

I've been working on creating a navigation sidebar using Angular and Bootstrap, but I'm having trouble getting my navigation items to display correctly. APP Component HTML <div class="container-fluid"> <div class="row" id="header"&g ...

Switching from React version 15.6.2 to 16 results in disruptions to the functionality of the web

Currently, I am encountering an issue where none of my index.js files are rendering. After using the react-scripts to build my web application in version 16.2.0, I receive an error stating that r.PropTypes is undefined when trying to access the localhost a ...

Display array elements without numerical indexes

Consider the code snippet below: for(i=0; i<3; i++){ a = {}; a['name' + i] = i; data.push(a); } This code will generate the following array: { 1:{name0:0}, 2:{name1:1}, 3:{name2:2} } How can I modify the code ...

The update of data has encountered a hurdle with Mongoose

Is there a way to update user data without having to fill out all the fields? For instance, if I only input the name, only the name should be updated while keeping other values the same. However, when I attempted this, my password validation displayed an e ...

Node-Fetch encounters problematic JSON response with Danish characters

I'm currently working on querying a Real Estate Website. When I send a fetch request with terms like 'Næstved','Præstø',Karrebæksminde, the response is not satisfactory as characters like æ,ø are replaced by ? symbols. I att ...

What steps can be taken to choose a particular class when multiple classes share the same name?

Imagine having a table layout like this: <table class="first-table" border="1" width="400px"> <tr> <td><?php echo $row_cond['title']; ?></td> <td><a class="more" href="#" onClick="slideup() ...

tips for successfully transferring date and time data between json and nosql databases like firestore

Input: Created_At:Monday, 29 April 2019 15:07:59 GMT+05:30 Updated_At:Monday, 29 April 2019 15:07:59 GMT+05:30 I attempted to export data in JSON format from Firestore using the npm package firestore-export-import. However, the output I received was: ...

I'm having some unexpected reflections with the threejs cube camera

I'm currently experimenting with creating an object that reflects on all sides. Although I've made progress, I seem to be encountering some issues. At certain angles, I can only see partial reflections and the scale of the reflection is much larg ...

Strategies for identifying specific children in my particular situation

Here's a snippet of my code: <ul id='nav'> <li><h1 id='unique' class='title'>Topic</h1></li> <li><h1 class='toptitle'>Department</h1></ ...

What is the best way to increment the stock number based on the quantity of items in the cart using Next.js

I am in the process of developing a shop system where customers can order items and save them to the database. I have encountered an issue where I need to calculate the remaining stock after deducting the quantity of items ordered. My API is responsible f ...

What is causing columns.render not to trigger when DataTable().draw() is invoked?

I'm wondering why the columns.render method is not part of the execution flow when using DataTable().draw(). For instance: HTML <table id="data"> <thead> <tr> <th>TimeColumn</th> < ...

Issue with Tailwind CSS: The 'overflow-y' property does not scroll all the way to the bottom when using 'top-[63px]'

I'm facing an issue with my Tailwind CSS code that is hindering me from scrolling to the bottom of an aside element. <body> <div> <nav class=" bg-white px-2 py-2.5 dark:bg-gray-800 sm:px-4 fixed w-full z-20 border-b borde ...

Locate the index of an item within an array of objects based on a matching property in the

My current situation involves having an array of objects structured like this : [ {label: "<p>Opacity | %<br/></p>", customRow: false, id: 0, items: Array(13)}, {label: "Brand_hs_id", customRow: false, id: 0, items: A ...

Unexpected Outcome Arises When Applying Lodash's Debounce Function to Axios API Call

I keep encountering an issue with my app where it updates every time text is typed. I've implemented debounce on an axios request to queue them up until the timer runs out, then they all go at once. But I want to limit the requests to one per 10-secon ...

Ways to show text in a password field

I'm looking to have the password field on a page. I'd like to show the text "Enter password" on the screen before the user starts entering their password, but once they focus on the field to enter their password, it should switch back to password ...

The AngularJS directive is being triggered before the Jquery AJAX request is completed

I am currently facing an issue where the chart in my AngularJS application (using NVD3.org) is loading before the AJAX call completes and data is fetched. How can I ensure that the chart waits for the AJAX call to finish? <script> var dataxx= ...