2013-02-07 107 views
1

我正在處理地圖項目,出於某種原因,我的工具提示的文本寬度將繼續按照我想要的那樣擴大,直到我爲文本添加一個空格。如果我添加一個空格,它會跳到下一行;發生了什麼,我該如何解決這個問題?我希望在一行中的文本沒有指定寬度,所以它可以自動設置寬度,我該如何解決這個問題?寬度不擴展?

在下面的示例中,查看段落標記中的文本「棒球場」。如果它讀取「BaseballFields」,它將保持在一行上。但是一旦我添加空間,它就會換行。

<div style="width: 750px; height: 1221px; border: 0; padding: 0; margin-top: 10px; display: block; position:relative; background: url('http://www.thefirstacademy.org/filerequest/9701.jpg') no-repeat left top;"> 
    <style type="text/css"> 
     .triangle { 
      position:absolute; 
      bottom:-5px; 
      left:40%; 
      height:0; 
      width:0; 
      border-left:5px solid transparent; 
      border-right:5px solid transparent; 
      border-top:5px solid white; 
     } 
     .tooltip { 
      color:#ef4c4c; 
      background:#ffffff; 
      padding:17 10; 
      display:block; 
      position:absolute; 
      border-radius:5px; 
      font:.8em 'MuseoSans-500','Museo Sans'; 
      top:-40px; 
      box-shadow:0px 3px 3px #000; 
      border:1px solid #000; 
     } 
    </style> 

    <div class="marker" style="position:absolute;cursor:pointer;left:450px;top:75px;" id="baseball"> 
     <img src="http://www.thefirstacademy.org/filerequest/9702.png" alt="Location Marker" /> 
     <div class="tooltip" > 
      <div class="triangle"></div> 
      <p style="padding:0;margin:0;line-height:0;display:block;">Baseball Fields</p> 
     </div> 
    </div> 
</div> 
+1

你試過'白色空間:nowrap'? – natlee75

+0

這是它!我會在時間之後標記它解決。我知道我錯過了一些CSS代碼片段。那究竟是什麼目的? – beta208

+0

呃,猜我不能標記你的帖子作爲解決方案時,我標記它有幫助= / – beta208

回答

1

只是擡起頭來:除了white-space: nowrap;它可以幫助包括display: inline-block;瀏覽器兼容性的目的