You can force long (unbroken) text to wrap in a new line by specifying break-word with the word-wrap property. For example, you can use it to prevent text extending out the box and breaking the layout. This commonly happens when you have a long URL in the sidebar or comment list.
Remove the width and display: block and then add display: inline-block to the button. To have it remain centered you can either add text-align: center; on the body or do the same on a newly created container.
AS long as you've set the width of the element, just take the whitespace:no-wrap off, and it will wrap the text exactly to the width of the element.
I found that you can make use of the white-space CSS property:
white-space: normal;
And it will break the words as normal text.
white-space: normal;
word-wrap: break-word;
Mine works with both
You can force it (browser permitting, I imagine) by inserting line breaks in the HTML source, like this:
<INPUT value="Line 1
Line 2">
Of course working out where to place the line breaks is not necessarily trivial...
If you can use an HTML <BUTTON>
instead of an <INPUT>
, such that the button label is the element's content rather than its value
attribute, placing that content inside a <SPAN>
with a width
attribute that is a few pixels narrower than that of the button seems to do the trick (even in IE6 :-).
I have found that a button works, but that you'll want to add style="height: 100%;"
to the button so that it will show more than the first line on Safari for iPhone iOS 5.1.1
white-space: normal;
word-wrap: break-word;
"Both" worked for me.
Multi-line buttons like that are not really trivial to implement. This page has an interesting (though somewhat dated) discussion on the subject. Your best bet would probably be to either drop the multi-line requirement or to create a custom button using e.g. div
s and CSS, and adding some JavaScript to make it work as a button.
If we have some inner divisions inside <button>
tag like this-
<button class="top-container">
<div class="classA">
<div class="classB">
puts " some text to get print."
</div>
</div>
<div class="class1">
<div class="class2">
puts " some text to get print."
</div>
</div>
</button>
Sometime Text of class A get overlap on class1 data because these both are in a single button tag. I try to break the tex using-
word-wrap: break-word; /* All browsers since IE 5.5+ */
overflow-wrap: break-word; /* Renamed property in CSS3 draft spec */
But this won't worked then I try this-
white-space: normal;
after removing above css properties and got my task done.
Hope will work for all !!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With