我有4个a-tags。每个CSS中的所有内容都可以正常工作。它完美地调整了我手机上的按键大小。我唯一的问题是在我的手机上,对于登录/注册按钮,按钮内的文本剪切,所有显示的都是登录/注册。
在我的记忆中,white-space: normal是做这件事的方法,但也许我错了。
@media only screen and (max-device-width: 480px) {
.newsButton {
width: 49%;
height: 140px;
white-space: normal;
float: left;
}
.venueButton {
width: 49%;
height: 140px;
white-space: normal;
float: right;
}
.learnButton {
width: 49%;
height: 140px;
white-space: normal;
float: left;
}
.loginButton {
width: 49%;
height: 140px;
white-space: normal;
float: right;
}
}<a href="menu.php" class="newsButton" data-role="button" data-theme="e">News</a>
<a href="venue.php" class="venueButton" data-role="button" data-theme="e">Venue Hire</a>
<a href="learn.php" class="learnButton" data-role="button" data-theme="e">Learn</a>
<a href="login.php" class="loginButton" data-role="button" data-theme="e">Login/Register</a>
发布于 2020-08-06 16:11:00
.custom-btn{
display: inline-block;
width: 49%;
height: auto;
white-space: normal;
text-align: left;
padding: 16px;
}发布于 2019-04-15 23:19:29
问题是:默认情况下,a标签是display: inline。word-wrap: break-word对任何不是display: inline-block或display: block的元素都不起作用(参见this)。
因此,您必须像这样按下按钮
.button {
// ...
display: inline-block;
word-wrap: break-word;
// ...
}希望这能有所帮助。
发布于 2013-10-11 11:41:30
我相信你用的是word-wrap: break-word;。此外,删除height限制-当单词换行到新行时,它只会导致奇怪的文本溢出问题。
@media only screen and (max-device-width: 480px) {
.newsButton{
width:49%;
word-wrap:break-word;
float: left;
}
.venueButton{
width:49%;
word-wrap:break-word;
float: right;
}
.learnButton{
width:49%;
word-wrap:break-word;
float: left;
}
.loginButton{
width:49%;
word-wrap:break-word;
float: right;
}
}此外,您似乎正在以一种非常奇怪的方式使用您的类。您不应该将这些类指定为id类,然后像这样给所有按钮分配一个button类吗?
<a href="menu.php" id="newsButton" class="button" data-role="button" data-theme="e">News</a>
<a href="venue.php" id="venueButton" class="button" data-role="button" data-theme="e">Venue Hire</a>
<a href="learn.php" id="learnButton" class="button" data-role="button" data-theme="e">Learn</a>
<a href="login.php" id="loginButton" class="button" data-role="button" data-theme="e">Login/Register</a>CSS:
@media only screen and (max-device-width: 480px) {
.button{
width:49%;
word-wrap:break-word;
float: left;
}
}https://stackoverflow.com/questions/19309803
复制相似问题