0

を使用して、幅が 20px に固定された入力ボタンがありますbox-sizing: content-box

<input data-role="none" type="button" class="icon_text" value="click me" />

ボタンの幅は、パディングのみを使用して設定されます。

例:

.icon_text {
    border: 1px solid #aaa;
    border-radius: .7em;
    -moz-border-radius: .7em;
    -webkit-border-radius: .7em;
    color: white !important;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    background-color: #7EB238;
    background-image: url("p.png");
    background-image: url("p.png"), -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(rgba(52,109,28,1)), color-stop(rgba(52,109,28,0) )), -webkit-gradient(linear, left top, left bottom, from( #9ad945 ), to( #7eb238 )); 
    background-image: url("p.png"), -webkit-radial-gradient(center, ellipse cover,  rgba(52,109,28,1), rgba(52,109,28,0) ), -webkit-linear-gradient( #9ad945, #7eb238 ); 
    background-image: url("p.png"), -moz-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -moz-linear-gradient( #9ad945, #7eb238 ); 
    background-image: url("p.png"), -ms-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -ms-linear-gradient( #9ad945, #7eb238 ); 
    background-image: url("p.png"), -o-radial-gradient(center, ellipse cover, rgba(52,109,28,1), rgba(52,109,28,0) ), -o-linear-gradient( #9ad945, #7eb238 ); 
    background-image: url("p.png"), radial-gradient(ellipse at center, rgba(52,109,28,1) 67%, rgba(52,109,28,0) 69%), linear-gradient( #9ad945, #7eb238 );
    background-attachment: scroll, scroll, scroll;
    background-repeat: no-repeat, no-repeat, no-repeat;
    background-position: -100px 50%, 7px 50%, center center;
    background-size: 864px 18px, 20px 20px, auto auto;
    -webkit-background-size: 864px 18px, 20px 20px, auto auto;
    background-clip: content-box, content-box, padding-box;
    -webkit-box-sizing: content-box; 
    -moz-box-sizing: content-box;   
    box-sizing: content-box;
    text-indent: 2.1em;
    padding-top: 6px;
    padding-bottom:7px;
    padding-left: 7px;
    padding-right:92px;
    width: 20px;
    height: 20px;

}

これは問題なく機能しますが、テキストを中央に配置したボタンでフルスクリーンを生成できるようにする必要があります。多かれ少なかれボタンpadding-rightを設定できますが、パーセント値を取らない96%ため、テキストを中央に配置する方法がわかりません。text-indent

質問:
ボタンの幅が固定され、ボタンの長さがパディングを使用して設定されている場合にのみ、CSS を介してボタンを引き伸ばしてテキストを中央に配置することは可能ですか? 誰かがアイデアを持っているかどうか、これを行う方法に興味があります。

ありがとう!

4

1 に答える 1