html - <a> 里面的字溢出了,如何解决?

标签 html css

这是我的 HTML 代码的一部分:

<div id="content" class="row">
       <div id="tab1" class="col-md-3 col-sm-4">
       <div class="panel panel-primary">
     <div id="login-title" class="panel-heading"> Customer Login </div>
       <div class="panel-body">
         <form class="form-horizontal" action="index.html" method="post" role="form">
           <div class="form-group">
             <label class="label_login">Login Name:</label>
             <input id="input_login" type="text" name="user_name" value="" class="form-control" placeholder="Enter the Login Name.">
             <label class="label_login">Password:</label>
             <input id="input_login" type="password" name="user_password" value="" class="form-control" placeholder="Enetr the Password.">
             <button id="btn_login" type="login" name="btn">Login</button>
           </div>
         </form>
       </div>
       <div id="login-title" class="panel-heading"> Company News </div>
         <div class="news">
           <h2> Aug 12, 2016 </h2>
            <a href="#" target="_blank"> ...</a>
           <h2> Jun 23, 2016 </h2>
            <a href="#" target="_blank">...</a>
           <h2> Dec 06, 2015 </h2>
            <a href="#" target="_blank">...</a>
           <h2> Oct 10, 2014 </h2>
            <a href="#" target="_blank">...</a>
           <h2> Jul 22, 2014 </h2>
            <a href="#" target="_blank">...</a>
         </div>
     </div>
   </div>
   <div class="col-md-9 col-sm-8">
     Main
   </div>
</div>

这是我得到的结果: enter image description here

很明显,字都溢出来了。 我尝试了 widthoverflow(在 .news a 中)但它们没有用... 怎么了??

最佳答案

解决方案 1(简短,如果您不关心隐藏 URL 的某些部分):

.news a {
    display:block;
    overflow:hidden;
}

解决方案 2(简短,如果您不关心隐藏 URL 的某些部分):

.news {
    overflow:hidden;
}

解决方案 3:

.news a {
    overflow-wrap: break-word;
    word-wrap: break-word; /* legacy version */
}

关于html - <a> 里面的字溢出了,如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39930141/

相关文章:

javascript - 查找没有特定类的直接子元素的元素

javascript - JavaScript 下拉菜单功能的问题

jquery - 响应式设计菜单问题仅限 iPhone

html - 用于标记链接的空 anchor 的 RegEx 模式,其中 <img> 除外

javascript - 为什么我的输入元素(div 子元素)不可点击,而当我用按钮替换此输入时,该按钮是可点击的

javascript - 在 JavaScript 的按钮单击事件上打印与 HTML 中的复选框关联的值

html - 每当我用来固定标题的位置时,使用 css 设置网页样式时,它的宽度就会减小。我该如何解决这个问题?

html - 使父 DIV 成为其子项的宽度

Javascript - 生成控件并附加

html - 选择单选按钮时更改单选按钮标签颜色?