我正在尝试创建一个拖放框,就像购物车一样。但是,当我从框中拖出时,脚本框中的内容隐藏了我需要拖动的div。我需要一个scoll bar,所以底部和顶部可以隐藏。有没有办法允许左侧的仅显示内容?
这是我到目前为止的演示:http://www.statuesplus.com/admin/stackoverflow.php
我正在使用malihu的自定义jQuery滚动条。我可以在这里找到:http://manos.malihu.gr
我发现隐藏它的代码在js文件中。 可在此处找到:http://www.statuesplus.com/admin/scroll/jquery.mCustomScrollbar.concat.min.js
在此文件中更改它的代码行是:
m.wrapInner("<div class='mCustomScrollBox mCS-"+e.theme+"' id='mCSB_"+c(document).data("mCustomScrollbar-index")+"' style='position:relative; height:100%; overflow:hidden; max-width:100%;' />")
可能的解决方法:必须有一种方法可以使我选择的jQuery项目从这个框中拖出弹出,所以它不受限制。也许我可以在点击上创建一个“克隆”作为解决方法?
或许我只能展示左侧。但要做到这一点,我需要改变js。
任何想法都将不胜感激。
以下是我的代码:(请注意我尝试使用的div称为“content2”
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<style>
#fileEm {
/* Note: display:none on the input won't trigger the click event in WebKit.
Setting visibility: hidden and height/width:0 works great. */
visibility: hidden;
width: 0;
height: 0;
}
.fileSelect {
width: 250px;
display: block;
height: 20px;
}
.leftUpload {
float: left;
}
.rightUpload {
background-image: url(../images/bgGrunge.jpg);
height: 500px;
width: 500px;
display: block;
float: right;
background-position: center;
border-top-style: dashed;
border-right-style: dashed;
border-bottom-style: dashed;
border-left-style: dashed;
clip: rect(auto,auto,auto,auto);
margin-bottom: 10px;
}
.catHolder {
padding-left: 50px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
padding-top: 10px;
display: block;
margin-left: 15px;
float: none;
position: relative;
}
.cat {
float: left;
background-image: url(../images/bgCat.png);
height: 30px;
width: 133px;
line-height: 30px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
font-size: 11px;
text-align: center;
display: block;
font-family: Arial, Helvetica, sans-serif;
color: #333;
z-index: 33;
}
.catBox {
float: left;
background-image: url(../images/catagory.png);
background-position: center;
height: 483px;
width: 166px;
padding-top: 20px;
background-repeat: no-repeat;
padding-left: 20px;
margin-right: 0px;
z-index: 0;
}
.spacer {
width: 150px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
display: block;
top: 33px;
margin-top: 15px;
height: 25px;
}
.catItems {
width: 133px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
padding-top: 5px;
padding-left: 3px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
text-transform: uppercase;
position: relative;
}
.content2{
margin: 40px;
width: 171px;
height: 433px;
padding: 20px;
background: #333;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
position: absolute;
left: 220px;
top: -25px;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="scroll/jquery.mCustomScrollbar.concat.min.js"></script>
<script>
$( document ).ready(function() {
$(function() {
$( ".cat" ).draggable();
$( ".catBox" ).droppable({
drop: function( event, ui )
{
$( this )
$("<div class=\"catAdded\" id=\"catAdded\">"+ui.draggable.attr('id')+"</div>").appendTo(".catItems");
$("#"+ui.draggable.attr('id')+"").remove();
}
});
});
////
$( ".fileSelect" ).hide();
$( ".Name" ).hide();
$( "#test" ).click(function()
{
alert( $( ".fileSelect" ).val());
});
$( "#Browse" ).click(function()
{
$( ".fileSelect" ).click();
});
$( ".fileSelect" ).change(function() {
$( "#Browse" ).hide();
$( ".Name" ).show();
//$( ".fileSelect" ).show();
var value = $( ".fileSelect" ).val();
$( ".Name" ).text( value );
alert($('.fileSelect').text.val())
});
});
</script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="scroll/js/minified/jquery-1.9.1.min.js"%3E%3C/script%3E'))</script>
<!-- custom scrollbars plugin -->
<script src="scroll/jquery.mCustomScrollbar.concat.min.js"></script>
<script>
(function($){
$(window).load(function(){
$("#content_1").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
});
})(jQuery);
</script>
<link href="scroll/jquery.mCustomScrollbar.css" rel="stylesheet" />
</head>
<body><form action="" method="post" enctype="multipart/form-data">
<table width="777" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><div class="rightUpload">
<div class="catBox" id="name">
<div class="spacer" id="name"></div>
<div class="catItems" id="name">
</div><!-- CAT ITEM -->
</div>
<div class="catHolder">
<div id="content_1" class="content2">
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
<div class="cat" id="Stack">Stack</div>
<div class="cat" id="Over">Over</div>
<div class="cat" id="Flow">Flow</div>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
</form>
</body>
</html>
答案 0 :(得分:0)
您可以在可拖动项目的容器上设置overflow
hidden
。在拖动它们时,它们仍然是该DOM元素的一部分,并且在删除之前遵守其规则。尝试添加:
#mCSB_1 {
overflow:visible;
}