0

小さなスタート画面を実行していて、ボタンとして機能する画像を特定のポイントに配置したいのですが、しようとすると同じ場所にとどまり、どうすれば取得できるかわかりません私が望む場所にとどまるために。これが私のコードです。CSS を含む HTML です。

<style>
    #SplashScreen{
        position:relative;
        overflow:hidden;
    }

    #StartButton
    {
        cursor:pointer;
        position:absoloute;
        left:100px;
        top:100px;
    }
</style>
<div id="SplashScreen" width="400" height="400">
    <h1>Game Title</h1>
    <img id="StartButton" src="play.png"/>
</div>

画像はタイトルの下に描画されるだけで、必要な場所には描画されません。何か助けはありますか?

4

2 に答える 2

0

それはあなたのabsoluteスペルが間違っているからです

#StartButton
{
    cursor:pointer;
    position:absolute;
    left:100px;
    top:100px;
}

高さ/幅の属性を使用しないでください。#SplashScreen代わりにMy Fiddleで指定してください

<style>
    #SplashScreen{
        position:relative;
        overflow:hidden;
        height: 400px;
        width: 400px;

    }

    #StartButton
    {
        cursor:pointer;
        position:absolute;
        left:100px;
        top:100px;
    }
</style>
<div id="SplashScreen">
    <h1>Game Title</h1>
    <img id="StartButton" src="http://www.alfresco.com/community/images/windows-icon.png"/>
</div>​
于 2012-10-13T09:27:51.617 に答える
0

これを試してみてください。つづりを間違えabsoluteました。幅と高さを div に設定したい場合は、html タグではなく、CSS を介して行う必要があります。

#SplashScreen{
        position:relative;
        overflow: hidden;
        width: 400px;
        height: 400px;
    }

    #StartButton
    {
        cursor:pointer;
        position: absolute;
        left:200px;
        top:100px;
        width: 50px;
        height: 50px;
        background: black;
    }
于 2012-10-13T09:34:10.803 に答える