23.02.2015, 20:37
So guys, i need some help with css. I made a button which outputs in the button the text that the user wrote.
Ex: I write "hi" in the text form and the button will output "hi".
This is the css code:
The problem is: I made a button with a static width/height, so if i type a long text i will come up in this:
http://s2.postimg.org/z23ch8x7d/kik.jpg
See? The text is going out of the button, i wanna adapt it on what user writes..
My question is: How i can enlarge/make more small the button depending on what user types?
I mean, i wanna make the button dynamic, if i write a long text button should adapt at the lenght of the text and viceversa.
Any help?
Ex: I write "hi" in the text form and the button will output "hi".
This is the css code:
Код:
<style type="text/css">
.classname {
-moz-box-shadow:inset 0px 1px 0px 0px #f5978e;
-webkit-box-shadow:inset 0px 1px 0px 0px #f5978e;
box-shadow:inset 0px 1px 0px 0px #f5978e;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #f24537), color-stop(1, #c62d1f) );
background:-moz-linear-gradient( center top, #f24537 5%, #c62d1f 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f24537', endColorstr='#c62d1f');
background-color:#f24537;
-webkit-border-top-left-radius:0px;
-moz-border-radius-topleft:0px;
border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-moz-border-radius-topright:0px;
border-top-right-radius:0px;
-webkit-border-bottom-right-radius:0px;
-moz-border-radius-bottomright:0px;
border-bottom-right-radius:0px;
-webkit-border-bottom-left-radius:0px;
-moz-border-radius-bottomleft:0px;
border-bottom-left-radius:0px;
text-indent:0;
border:1px solid #d02718;
display:inline-block;
color:#ffffff;
font-family:Arial;
font-size:14px;
font-weight:bold;
font-style:normal;
height:25px;
line-height:25px;
width:154px;
text-decoration:none;
text-align:center;
text-shadow:1px 1px 0px #810e05;
}
.classname:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #c62d1f), color-stop(1, #f24537) );
background:-moz-linear-gradient( center top, #c62d1f 5%, #f24537 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#c62d1f', endColorstr='#f24537');
background-color:#c62d1f;
}.classname:active {
position:relative;
top:1px;
}</style>
http://s2.postimg.org/z23ch8x7d/kik.jpg
See? The text is going out of the button, i wanna adapt it on what user writes..
My question is: How i can enlarge/make more small the button depending on what user types?
I mean, i wanna make the button dynamic, if i write a long text button should adapt at the lenght of the text and viceversa.
Any help?



I just happen to know a lot about these things because they're in my field of study (programmer/webdev [though mostly back-end]) and they interest me.