BootStrap CSS causing changes to jQuery Drag and Drop Plugin

I have encountered a strange issue where my jQuery Drag & Drop simulation plugin is malfunctioning when BootStrap's CSS file is included in the header.

Below are two fiddles containing the exact same code except for the inclusion of Bootstrap's CSS file:

With BootStrap CSS (Not Working): http://jsfiddle.net/3os4yhen/1/

Without BootStrap CSS (Working): http://jsfiddle.net/zy3h3doo/1/

Does anyone know which specific section of the CSS file I can disable to resolve this issue while still being able to use it on other parts of my page?

Thank you for your help!

Here is the complete HTML code snippet:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>jQuery Simulate Extended Plugin - jsFiddle demo</title>


<!-- CSS Stylesheets -->
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/gosigner.css">

    <!-- THIS IS WHAT CAUSES THE ISSUE 
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/bootstrap.css"> -->

<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/dataTables.css"> 
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/dropzone.css">


<!-- Global JS Files -->
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

<style>
    body {
        background-color: #EAEAEA;
    }

    #view-port {
        margin: 0 auto;
        width: 852px;
    }

    .droppableShape {
        z-index: 10;
    }

    #signature-add-canvas {
        background-image: url("/app/img/sign_bg.png");
    }

    .page {
        margin: 10px 0 10px 0;
        background-repeat: no-repeat;
        width: 850px; 
        height:1100px;
        border: 1px solid #DADADA;
        position: relative;
        background-color: #fff;
        border-radius: 2px;
    }
</style>
</head>

<body>
    <div class="container">
        <div id="view-port">
            <div id="placeme" class="droppableShape">
                <img src="https://upload.wikimedia.org/wikipedia/en/6/6f/Smiley_Face.png" width="25" height="25" />
            </div>
            <button id="testme">Simulate Drop</button>
            <div class="page" id="page1" style="background-image: url(http://images.huffingtonpost.com/2012-08-15-1CanvasPanelInstall5psd.jpg);"></div>
            <!-- Additional Pages Here -->
        </div>
    </div>
</body>


<!-- jQuery UI -->

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type='text/javascript' src="http://j-ulrich.github.com/jquery-simulate-ext/jquery.simulate.js"></script>
<script type='text/javascript' src="http://j-ulrich.github.com/jquery-simulate-ext/jquery.simulate.ext.js"></script>
<script type='text/javascript' src="http://j-ulrich.github.com/jquery-simulate-ext/bililiteRange.js"></script>
<script type='text/javascript' src="http://j-ulrich.github.com/jquery-simulate-ext/jquery.simulate.key-sequence.js"></script>
<script type='text/javascript' src="http://j-ulrich.github.com/jquery-simulate-ext/jquery.simulate.key-combo.js"></script>
<script type='text/javascript' src="http://j-ulrich.github.com/jquery-simulate-ext/jquery.simulate.drag-n-drop.js"></script>

<script>

     $(document).ready(function(){

        $(".droppableShape").draggable({
            helper:'clone'
        });

        $(".page").droppable({
            accept: ".droppableShape",
            tolerance: 'fit',
            drop: function(event,ui){
                alert("Drop Detected");
                // Set variables
                var new_field = $(ui.helper).clone().removeClass('droppableShape');
                var droppable_page = $(this);
                var droppableOffset = $(this).offset();
                new_field.css('top', ui.position.top - droppableOffset.top);
                new_field.css('left', ui.position.left - droppableOffset.left);

                // Set Draggable Options
                new_field.draggable({
                    containment: droppable_page,
                    stop: function(event, ui) {
                       // Save position after dragging stops
                       $(this).data("x_cord", ui.position.left);
                       $(this).data("y_cord", ui.position.top);
                    }
                });

                // Add to drop area
                $(this).append(new_field);
            }
        });

        $( "#testme" ).click(function() {
            $('#placeme').simulate("drag-n-drop", {
                dragTarget: $("#page1")
            });
            console.log("Drag Simulated");
        });
    });

</script>

Answer №1

This is the:

-webkit-box-sizing: border-box;
box-sizing: border-box;

...style applied by Bootstrap. To customize it quickly, you can use this override:

-webkit-box-sizing: none !important;
box-sizing: none !important;

Answer №2

After thorough analysis, I decided to meticulously review the bootstrap.css file line by line in order to identify which styles were impacting the performance:

Upon reaching Line 1068 of bootstrap.css:

* {
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
}

Interestingly, when I commented out this particular section, the functionality of the Simulate Drop button improved significantly.

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 process for transferring sigmajs gephi export files onto a server? [The files consist of javascript, css, and index.html that need to be directed to]

Struggling to upload my sigmajs export from gephi onto a website, particularly my GitHub pages. I'm encountering difficulties in getting it uploaded correctly. Could someone provide guidance on the process? I've already uploaded the folder and a ...

Navigate to the bottom of a particular section without causing any disturbances to the remaining content on the page

<div id="test" style="height:200px;overflow:scroll;"> ...a large amount of text... <div id="bottom"></div> </div> While using jQuery throughout the session to add more text into #test, a challenge arises. The issue is once the ...

Merge diverse backgrounds with Parallax Scrolling

My Parallax scrolling website has a div called "bg" with dimensions of 8000px height and 960px width. The entire page is designed to fit this size, including the body background. However, I am facing an issue where setting the background for "bg" breaks th ...

Adjusting the arrow direction upon clicking in a Select option

Is there a way to make the arrow move upwards when I open the select dropdown option? <select class="form-select" aria-label="Default select example"> <option selected>Choose an option</option> <option value="1">One</optio ...

Clear a variable that was sent through the post method in an ajax call

Within my JavaScript file, I have the following Ajax code: // Default settings for Ajax requests $.ajaxSetup({ type: 'POST', url: path + '/relay.php' + '?curr=' + currency + "&ver=" + Ma ...

Guide to customizing action button color on MatSnackbar?

Currently, I am encountering an issue with the snackbar in my Angular 9 project. Despite adding CSS styles to both the component.scss file and the global style.scss file, the action button on the snackbar displays the same background and text color. In an ...

Tips for displaying text gradually when hovering over a button

Is there a way to make text appear slowly on hover of a button without it coming from the bottom to the right? I attempted using transition:all 5s;, but encountered the issue of the text moving from the bottom to the right due to improper width. Is there a ...

If the title is a match, append an attribute to a tag

Is there a way to automatically add the attribute "target=_blank" to an <a> tag if it has the title "extension" assigned to it? <ul id="mob-right-menu"> <li class="menu-item><a href="#">Work</a></li> <li class="menu- ...

I am having trouble grasping certain syntax in JavaScript when it comes to using `${method_name}`

I'm having trouble understanding some of the syntax in this code, particularly ${method_name}. I'm not sure what we are achieving by passing the method name within curly braces. global._jsname.prototype.createEELayer = function (ftRule) { if ...

Display Bootstrap radios horizontally when the screen size is small or larger, and vertically when the screen

After reviewing the Bootstrap documentation for styling checkboxes and radios, I am searching for a solution to have my radios displayed horizontally on small screens or larger, and vertically on extra small screens. The approach described in the Bootstr ...

Empty Data Returned After Sending AJAX Request

Currently, I am delving into the world of ajax in order to simplify my life going forward. I successfully managed to implement an example where a constant array was posted to my controller without any issues. However, when attempting to fetch data from an ...

Animating the Ember Collection while paginating

Our team is currently developing an ember-pagination library to assist developers with pagination of items within an array collection. The library is already able to display content, enable pagination, and incorporate a typeahead feature for search funct ...

Using Javascript to change CSS in a Polymer application

Coming from a background in angular and react, I am now delving into the world of polymer. I have a polymer class called myClass with the following template. <div id="[[x]]"> Here, 'x' is a property defined in a property getter. stat ...

Develop websites for specific iOs versions as well as various Android versions

When it comes to targeting specific versions of Internet Explorer, conditional comments or hacks can be used. Is there a similar method for targeting different versions of iOS? I'm facing an issue with my website functioning perfectly on iOS 4.2 and ...

Responsive background styling with CSS

I'm currently learning how to create responsive websites, and I've encountered an issue. When I resize the website horizontally to a point just before the edge of the screen touches one of the elements, the background also shrinks, leaving white ...

Executing various onclick functions - Text Display

I've developed a code that includes onclick events to change the color of buttons and prevent them from being clicked twice. Additionally, I am looking to have data added to a table column/row when a button is clicked. For example, clicking button 3 s ...

Tips for setting the style of child components in a ReactJS project with CSS modules, classNames, and JSX syntax

Currently in the process of setting up a project using React JS and I am interested in incorporating auth0 for authentication purposes, along with potentially integrating some serverless functions. auth0 conveniently offers a pre-made "seed" project at ht ...

How to access a class from another JavaScript file using a function call

The title may seem strange, but I will do my best to explain the situation clearly. I have a website with a navigation bar where each tab corresponds to a different php file. All the files share a common js and css file. The directory structure is as foll ...

The offspring elements are positioned outside of the main footer element

There seems to be an issue with my <footer>. All child elements of the <footer> are appearing outside of it. Does anyone know how I can properly place child elements inside the <footer> and align them from left to right? footer{ bac ...

What is preventing ajax from accessing my php file after I move it to a folder?

I currently have a webpage called index.php, which appears as shown in the screenshot below: https://i.sstatic.net/EWGu3.png The code for index.php is: index.php: <div style="width: 90%; margin:0 auto;"> <form class="mb-3& ...