Muli-line button in IE

2019-05-07 18:21发布

问题:

I'm currently in a horrible situation that requires me to style an input of type "button" over two lines. Having a fixed width on the button causes the text within the button to wrap onto two lines in all other browsers except IE.

My question is therefore, how do I specify that an input with value="Button to Wrap" wraps onto two lines in IE?

I'm willing to accept any hacks or workarounds to make this happen.

Much appreciated!

回答1:

Use the button element instead - it can contain other markup:

<button type="button">
First Line<br />
Second Line<br />
Third Line<br />
</button>


回答2:

What works for me is to set CSS white-space to pre-line of the button input with a fixed width.

But only the first line will be visible on the button input. So height must be set to a fixed value or to auto.



回答3:

Have you tried hard returns in your source code? Works for me...

<p>
<input type='button' value='3
Line
Button'
/>
</p>


回答4:

The word-wrap CSS attribute seems to be the word on this one. If that doesn't work, you'll have to try using a div tag style to look like a button and an onClick handler...

<input type=button value="test" style="word-wrap: break-word"></input>

This might need position, height and width attributes as well to work.



回答5:

Have you tried using br tags?



回答6:

What works for me is to add a child span to the button, set its display to block and limit its width as the button's is.

It only affects IE 8 and 9 when the document is in IE7 mode.



回答7:

Why not to use image button? Make image for button, and pressed button... Or make button in flash (: