简体   繁体   English

防止文本溢出指定的div

[英]Prevent text from overflowing the specified div

Hello I've occurred this problem twice and I just cannot seem to be able to fix the second problem. 你好我已经发生过两次这个问题了,我似乎无法解决第二个问题。 The first time it happened with an image and I used max-height,width to prevent it from going out the div once zoomed in but for the footer which includes links it just won't do it. 第一次发生在图像上,我使用了max-height,width来防止它一旦放大就出了div,但对于包含链接的页脚,它就不会这样做了。

I've tried position:absolute; 我尝试过的位置:绝对的; aswell and many other answers I've seen from google but I've been stuck on this problem for the past fourty minutes and I am just drawing blanks. 以及我从谷歌看到的许多其他答案,但我在过去的四十分钟一直坚持这个问题,我只是画空白。

#footer {
    padding-top: 0.5%;
    width: 98%;
    height: 9%;
    padding-left: 1%;
    padding-right: 1%;
    text-align: center;
    background-color: #00FF1E;
}
#footer li {
    max-width: 100%;
    max-height: 100%;
    display: inline;
    padding: 1%;
    background: #7e7e7e; /* Old browsers */
    background: -moz-linear-gradient(top, #7e7e7e 0%, #595959 34%, #6d6d6d 60%, #666666 93%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #7e7e7e), color-stop(34%, #595959), color-stop(60%, #6d6d6d), color-stop(93%, #666666)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #7e7e7e 0%, #595959 34%, #6d6d6d 60%, #666666 93%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #7e7e7e 0%, #595959 34%, #6d6d6d 60%, #666666 93%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #7e7e7e 0%, #595959 34%, #6d6d6d 60%, #666666 93%); /* IE10+ */
    background: linear-gradient(to bottom, #7e7e7e 0%, #595959 34%, #6d6d6d 60%, #666666 93%); /* W3C */
 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7e7e7e', endColorstr='#666666', GradientType=0 ); /* IE6-9 */
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    border-radius: 15px;
    font-size: 30px;
    word-wrap: break-word;
}
#footer a { display: inline-block; }

HTML: HTML:

 <div id="footer">
    <ul>
    <li><a href="home.php" title="homepage"> Homepage </a></li>
    <li><a href="signin.php" title="signin"> Signin </a></li>
    <li><a href="playlist.php" title="playlist"> Playlist </a></li>
    <li><a href="settings.php" title="settings"> Settings </a></li>
    </ul>
 </div>

Try like this: Demo 试试这样: 演示

CSS: CSS:

.clearfix:after { 
   content: "."; 
   visibility: hidden; 
   display: block; 
   height: 0; 
   clear: both;
}

HTML: HTML:

<div id="footer" class="clearfix">...</div>

Source Link 来源链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM