我有一个带有文本的输入按钮 - 我希望文本适合输入按钮(意思是,如果它不合适,它会在2或3行上传播)。
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<style>
.blankbtn
{
text-align:center;
font-size:20px;
width:150px;
height:150px;
background-image: url(http://thumbnails.billiondigital.com/200/930200/794615_small_checkboard.jpg);
background-repeat:no-repeat;
}
</style>
<input type="button" value="heres a long text" class="blankbtn"/>
</body>
</html>
&#13;
有什么建议吗?
答案 0 :(得分:1)
添加此css
white-space: pre-line;
答案 1 :(得分:0)
使用white-space:normal;
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<style>
.blankbtn
{
text-align:center;
font-size:20px;
width:150px;
height:150px;
background-image: url(http://thumbnails.billiondigital.com/200/930200/794615_small_checkboard.jpg);
background-repeat:no-repeat;
white-space: normal;
}
</style>
<input type="button" value="heres a long text" class="blankbtn"/>
</body>
</html>
&#13;
答案 2 :(得分:0)
使用:
word-wrap: break-word; /* IE 5.5-7 */
white-space: -moz-pre-wrap; /* Firefox 1.0-2.0 */
white-space: pre-wrap; /* current browsers */
它适用于IE。点击此处 white-space 向下滚动到浏览器兼容性
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<style>
.blankbtn
{
text-align:center;
font-size:20px;
width:150px;
height:150px;
background-image: url(http://thumbnails.billiondigital.com/200/930200/794615_small_checkboard.jpg);
background-repeat:no-repeat;
word-wrap: break-word; /* IE 5.5-7 */
white-space: -moz-pre-wrap; /* Firefox 1.0-2.0 */
white-space: pre-wrap; /* current browsers */
}
</style>
<input type="button" value="heres a long text" class="blankbtn"/>
</body>
</html>