Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button width in css3

I have a button and I want it to be a particular size

html

<a class="button icon Raise"
onclick="raiseButtonAction(realPlayer, gameState)" id="nupp1" href="#"><span>RAISE</span></a>

css

.button {
position: absolute;
border-top: 1px solid #96d1f8;
background: #65a9d7;
background: -webkit-gradient(linear, left top, left bottom, from(#3e779d),
    to(#65a9d7) );
background: -moz-linear-gradient(top, #3e779d, #65a9d7);
padding: 5px 10px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: rgba(0, 0, 0, 1) 0 1px 0;
-moz-box-shadow: rgba(0, 0, 0, 1) 0 1px 0;
box-shadow: rgba(0, 0, 0, 1) 0 1px 0;
text-shadow: rgba(0, 0, 0, .4) 0 1px 0;
color: white;
font-size: 19px;
font-weight: bold;
font-family: Segoe;
text-decoration: none;
vertical-align: middle;

But if I put for example width:100px; it doesn't change in size. Am I doing something wrong or you just can't change the size of a premade button?

like image 843
nils Avatar asked Mar 28 '11 16:03

nils


People also ask

How do I customize a button size in CSS?

The font size property will be used to increase the size of a button using the style tag CSS. First, we open the style tag in the file header and create a styling class for the button. In this class, we assign a background color to the button. After that, we assign the font size as well.

How do you make a button 100 width?

To do so use display: block and width: 100% . This property can be used with <button> element as well as <input> element.


3 Answers

Try this..

.button {
display:inline-block;
min-width: 50px;
width: 80px;
padding:5px 10px;

}
like image 147
Robin Maben Avatar answered Oct 13 '22 01:10

Robin Maben


That style is on an a element, which is an inline and won't accept a width. You could change it to be inline-block or block and then you'll have control over the width.

like image 29
Liza Daly Avatar answered Oct 13 '22 00:10

Liza Daly


You need to make your <a> into a block level element. Here's an example of it working.

I just added this to your CSS for .button:

display: block;
width: 200px;
text-align: center;
like image 37
Conspicuous Compiler Avatar answered Oct 13 '22 00:10

Conspicuous Compiler