使用jquery将元素滑动到右侧

时间:2014-04-27 14:49:37

标签: jquery html css

<link rel="stylesheet" type="text/css" href="css/style.css">
<head>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<script>

$(document).ready(function(){
  $("#btn1").click(function(){
    $("p").append(" <b>Appended text</b>.");
  });
  $("#btn2").click(function(){
    $("#d87").append("<div id='d76'>H</div>").;

  });
});
</script>
</head>
<body>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<ol>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ol>

<button id="btn1">Append text</button>
<button id="btn2">Append list item</button>

</body>
</html>
<div id="d87"></div>

当我按下附加列表项时我通过css创建的框在向下方向滑动。我希望它向右滑动,每次单击按钮时,它都应移到上一个框的右侧100px

1 个答案:

答案 0 :(得分:0)

#d87{
  margin-left:100px; 
  float:left; 
}