javascript - How create an overlay button on different containing div - Stack Overflow

How to create a button that will overlay each html element with class WSEDIT.First I Know I'll nee

How to create a button that will overlay each html element with class WSEDIT.

First I Know I'll need a javascript loop to find each element with css Class WSEDIT and create on the fly a button and prepend this button in each element with WSEDIT class.

Example of javascript loop and the button creation

$(function()
   $(".WSEDIT").each(function(){
      var btnConfigure = $("<div class='BBtnConfigure'>");
      $(this).prepend(btnConfigure);
   });
);   


<div class="WSEDIT" style="width:200px;height:400px;border:1px solid #000000">
    <p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore 
    </p>
<div>

<div class="WSEDIT" style="width:200px;height:400px;border:1px solid #000000">
   <h2>Sale For First Trimestriel</h2>
   <img src="/graph.png" />
<div>


<div class="WSEDIT" style="width:200px;height:400px;border:1px solid #000000">
   <table>
     <tr><td>Name</td><td>Sex</td></td>Age</td<td>Country</td></tr>
     ...
   </table>

<div>

Here is what I'm trying to do in the following picture.


The question is , What should be the CSS for my btn class button BBtnConfigure
As you can see in the picture, the BtnConfigure is overlapping each Section.

How to create a button that will overlay each html element with class WSEDIT.

First I Know I'll need a javascript loop to find each element with css Class WSEDIT and create on the fly a button and prepend this button in each element with WSEDIT class.

Example of javascript loop and the button creation

$(function()
   $(".WSEDIT").each(function(){
      var btnConfigure = $("<div class='BBtnConfigure'>");
      $(this).prepend(btnConfigure);
   });
);   


<div class="WSEDIT" style="width:200px;height:400px;border:1px solid #000000">
    <p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore 
    </p>
<div>

<div class="WSEDIT" style="width:200px;height:400px;border:1px solid #000000">
   <h2>Sale For First Trimestriel</h2>
   <img src="/graph.png" />
<div>


<div class="WSEDIT" style="width:200px;height:400px;border:1px solid #000000">
   <table>
     <tr><td>Name</td><td>Sex</td></td>Age</td<td>Country</td></tr>
     ...
   </table>

<div>

Here is what I'm trying to do in the following picture.


The question is , What should be the CSS for my btn class button BBtnConfigure
As you can see in the picture, the BtnConfigure is overlapping each Section.

Share Improve this question asked Feb 21, 2012 at 18:03 Jean-FrancoisJean-Francois 1,9594 gold badges35 silver badges75 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5
  1. The container (WSEDIT) should have position:relative so you can absolutely-position the button.
  2. The button should be inside the container
  3. The button needs: position:absolute; top:-10px; right:-20px (approximately)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742350276a4427375.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信