将div放在其他div的左边框上

时间:2013-08-05 14:16:40

标签: javascript jquery html css show-hide

是否可以将div .timedistance放在.draggable div的左边框上,以便它看起来像这样?

enter image description here

演示:http://jsbin.com/erofot/189

代码:

$('.draggable').hover(function(){
    $(this).find('.line').show();
                $(this).find('.timedistance').show();

}, function() {
    $(this).find('.line').hide();
      $(this).find('.timedistance').hide();


});      

      }
    });
          $(".draggable").each(function() {
   $(this).append("<div class='line'></div>");
               $(this).append("<div class='timedistance'></div>");

});

和CSS:

.line
{
  display: none;   
  width:5px; height:200px; background:#ccc;
}
.timedistance
{
  display: none;   
  width:100px; 
  height:54px;
  background:#ccc;
}

1 个答案:

答案 0 :(得分:0)

解决方案是:

margin-left: -100px;
margin-top: -54px;