28
4

6 に答える 6

65

本当に のスタイルを設定し<div>ますか? または、スタイルを設定し<input type="button">ますか? 後者が必要な場合は、正しいセレクターを使用する必要があります。

input[type=button] {
    color:#08233e;
    font:2.4em Futura, ‘Century Gothic’, AppleGothic, sans-serif;
    font-size:70%;
    /* ... other rules ... */
    cursor:pointer;
}

input[type=button]:hover {
    background-color:rgba(255,204,0,0.8);
}

以下も参照してください。

于 2012-06-15T15:24:11.310 に答える
9

.buttonCSS で、 を試してくださいdisplay:inline-block。このJSFiddleを参照してください

于 2012-06-15T15:23:08.907 に答える
6

与えられたフィドルのようなものが欲しいですか!


HTML

<div class="button">
    <input type="button" value="TELL ME MORE" onClick="document.location.reload(true)">
</div>

CSS

.button input[type="button"] {
    color:#08233e;
    font:2.4em Futura, ‘Century Gothic’, AppleGothic, sans-serif;
    font-size:70%;
    padding:14px;
    background:url(overlay.png) repeat-x center #ffcc00;
    background-color:rgba(255,204,0,1);
    border:1px solid #ffcc00;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    border-radius:10px;
    border-bottom:1px solid #9f9f9f;
    -moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    -webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    cursor:pointer;
    display:block;
    width:100%;
}
.button input[type="button"]:hover {
    background-color:rgba(255,204,0,0.8);
}
于 2012-06-15T15:21:24.787 に答える
1

Float:left... div ではなく入力のスタイルを設定したいと思いますが?

.button input{
    color:#08233e;float:left;
    font:2.4em Futura, ‘Century Gothic’, AppleGothic, sans-serif;
    font-size:70%;
    padding:14px;
    background:url(overlay.png) repeat-x center #ffcc00;
    background-color:rgba(255,204,0,1);
    border:1px solid #ffcc00;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    border-radius:10px;
    border-bottom:1px solid #9f9f9f;
    -moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    -webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    cursor:pointer;
}
.button input:hover{
    background-color:rgba(255,204,0,0.8);
}
于 2012-06-15T15:21:53.693 に答える
0

問題はボタンではなく、div. s はブロック要素であるためdiv、デフォルトで親要素の全幅を占有します (原則として、1 つのドキュメントで異なる配置スキームをいじっている場合、いくつかの例外があると確信しています)。階層内の上位要素の全幅を占める)。

とにかく、セレクターfloat: left;のルールに追加してみてください。.buttonこれにより、divwith クラスbuttonがボタンの周りに収まり、divさらに s が必要な場合は、同じ行に複数の float s を配置できますdiv.button

于 2012-06-15T15:21:59.457 に答える
0

入れてみて

Display:inline;

CSSで。

于 2012-06-15T15:22:04.550 に答える