我正在使用引导程序和JavaScript进行测验。
按钮中的文本有时比按钮的主体长,并且在移动设备上,文本不适合按钮,因此我们无法阅读文本。 如何使文本适合按钮主体?谢谢!。
<button id="answer_a_btn" class="answer btn btn-default btn-lg btn-block" role="button">
<span><p id="answer_a" style="width: 100%"></p></span>
</button>
<button id="answer_b_btn" class="answer btn btn-default btn-lg btn-block" role="button">
<span><p id="answer_b" style="width: 100%"> </p></span>
</button>
<button id="answer_c_btn" class="answer btn btn-default btn-lg btn-block" role="button">
<span max-width: 100%><p id="answer_c" style="width: 100%"></p></span>
</button>
答案 0 :(得分:0)
使用媒体查询来调整import re
def skip_token(s, pattern, token, sub):
p = pattern.split()
gex = "|".join([pattern] + [" ".join(p[:i] + [token] + p[i:]) for i in range(1, len(p))])
return re.sub(gex, sub, s)
s = "I like green and PLUS blue beans!"
token = "PLUS"
sub = "red"
>>> print(skip_token(s, "green and blue", token, sub))
>>> print(skip_token(s, "green and blue beans", token, sub))
>>> print(skip_token(s, "I like green", token, sub))
I like red beans!
I like red!
red and PLUS blue beans!
或使用动态值来设置字体大小,例如font-size
或使用插件来插件succinct
答案 1 :(得分:0)
尝试使用像素代替
:style="width: 200px;"
答案 2 :(得分:-2)
尝试使用bootstrap
额外的小按钮
可能会帮助您 看一下代码片段:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Button</h2>
<p>The .btn-xs class makes extra small buttons:</p>
<button type="button" class="btn btn-default btn-xs">Extra small Default Button</button>
<button type="button" class="btn btn-info btn-xs">Extra small Info Button</button>
</div>
</body>
</html>