文本换行按钮

Anu*_*ari 7 html css word-wrap

我有4个标准a杆.每个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;
  }
}
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)

Kev*_*Pei 0

相信你用过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;
}
}
Run Code Online (Sandbox Code Playgroud)

而且你似乎以一种非常奇怪的方式使用你的课程。难道您不应该将这些类分配为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>
Run Code Online (Sandbox Code Playgroud)

CSS:

@media only screen and (max-device-width: 480px) {
    .button{
        width:49%;
        word-wrap:break-word;
        float: left;
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 如果出现问题,您可以在此处添加空格或“&lt;wbr&gt;”标记。但我们真的不知道真正的问题是什么。然而,无论问题是什么,断言几乎是一个错误的解决方案。 (3认同)
  • `word-wrap: break-word` 会中断单词,例如“Register”变为“R”和“egister”。它*不*仅在允许的断点处执行连字符或中断字符串。 (2认同)