3

我有一个旧网站的问题,我需要在 div 元素中放置一个按钮,但在表格的顶部。

<div class="panel2" style="border: 1px solid red;">
    <div id="charInfo">
        <input type="button" id="lockList" name="lockList" value="Lock WL" />
        <table width="500px" style="border:1px solid #000;border-collapse:collae;font-familyrif;font-size:80%;">
            <caption style="font-size:140%;padding:5px;">Wish list status <b>Tyde</b>
            </caption>
            <thead>
                <tr>
                    <th scope="col">Zone name</th>
                    <th scope="col">Wish Items</th>
                    <th scope="col">Received</th>
                    <th scope="col">Status</th>
                </tr>
            </thead>
            <tbody>
                <tr></tr>
                <tr>
                    <th scopre="row">Heart of Fear</th>
                    <td align="center">22</td>
                    <td align="center">0</td>
                    <td align="center" style="color:Green;"><b>Active</b>
                    </td>
                </tr>
                <tr>
                    <th scopre="row">Mogu-shan Vaults</th>
                    <td align="center">27</td>
                    <td align="center">4</td>
                    <td align="center" style="color:Green;"><b>Active</b>
                    </td>
                </tr>
                <tr>
                    <th scopre="row">Throne of Thunder</th>
                    <td align="center">45</td>
                    <td align="center">0</td>
                    <td align="center" style="color:Green;"><b>Active</b>
                    </td>
                </tr>
                <tr>
                    <th scopre="row">Throne of Thunder (Heroic)</th>
                    <td align="center">5</td>
                    <td align="center">1</td>
                    <td align="center" style="color:Red;"><b>Not locked</b>
                    </td>
                </tr>
            </tbody>
        </table>
    </div> </div>

我这里有一个例子http://jsfiddle.net/TvwKz/

如您所见,按钮放置在右侧,但我希望将其放置在表格标题的顶部。可以做到吗?如果可以,怎么做?
这是我想要的

(来源:odinsoft.dk

4

3 回答 3

2

你可以这个

CSS

#lockList {width:auto;margin:auto;position: relative;}

HTML

<caption style="font-size:140%;padding:5px;">Wish list status <b>Tyde</b>
            <input type="button" id="lockList" name="lockList" value="Lock WL" />
            </caption>

演示:http: //jsfiddle.net/ypAVr/

于 2013-07-25T10:36:28.380 回答
1

检查下面的CSS

#lockList 
{

    width:auto;
}
#charInfo
{
    position: absolute;
    text-align: center;   
}

和小提琴演示

于 2013-07-25T10:40:25.347 回答
1

关于您提供的小提琴链接,请float:right;lockListcss 类中删除。

#lockList {width:auto;margin:auto;position: relative;}
于 2013-07-25T10:39:31.333 回答