Search code examples
jquerycssdraggable

How to make draggable transparent?


i would like to know how to make a draggable transparent. Currently the background is white. Here's my website: http://amp.site88.net/

this is my code:

<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Draggable - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<style>
#draggable { width: 150px; height: 150px; padding: 0.5em; }
 </style><style>
 body {
background-color: lightblue;
}
</style>
<script>
$("#draggable").css("background-color", "transparent");
</script>
<script>
$(function() {
$( "#draggable" ).draggable();
});
</script>
</head>
 <body>

 <div id="draggable" class="ui-widget-content">
 <p>Drag me around</p>
</div>


 </body>
 </html>

Solution

  • Just edit your style block:

        #draggable { width: 150px; height: 150px; padding: 0.5em; background: transparent; }
    

    and it should work :)

    PS. you might have to add border: none; if you also want the border to disappear, leaving just the text.