Hi,

I have a couple of labels in the header of my master page. One of these displays the game-server that the user is currently connected to (the website controls the gameserver).

The name of the gameservers can be longer than the room I gave them in the header. When this happens, the text wraps around (this is good!), and any elements underneath this label shift down (this is wrong!).

Here is how it looks when not connected, so that the labels that show the name and IP of the server are hidden:


After connecting, the labels are shown but the text is slightly too large and wraps around, causing the two links underneath to shift. The header becomes larger than it should be and a blank strip results (where the header background image stops):



The relevant ASPX code:
asp Code:
  1. <div class="header">
  2.  
  3.             <div class="server">
  4.                <h2><asp:Label runat="server" ID="lblServer" Text="Connected to:" /></h2>
  5.                <h1><asp:Label runat="server" ID="lblHostname" Text="Tigers 1 - TDM" /></h1>
  6.                <h3><asp:Label runat="server" ID="lblIp" Text="(192.158.29.11:3074)" /></h3>
  7.                <br />
  8.                <h4><asp:Hyperlink runat="server" ID="lnkServers" Text="View Servers" NavigateUrl="~/Servers.aspx"/></h4>
  9.                <h5><asp:LinkButton runat="server" ID="lnkDisconnect" Text="Disconnect" onclick="lnkDisconnect_Click" /></h5>
  10.             </div>
  11.            
  12.            <div class="title">
  13.                 <h1>Black Ops</h1>
  14.                 <h2>WebCon</h2>
  15.            </div>
  16.  
  17.            <!-- Login display div omitted -->
  18.            
  19.         </div>
  20.  
  21.         <div class="clear hideSkiplink">
  22.  
  23.                 <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
  24.                     <Items>
  25.                         <asp:MenuItem NavigateUrl="~/Players.aspx" Text="Player List"/>
  26.                         <asp:MenuItem NavigateUrl="~/Players.aspx" Text="Map & Playlist Rotation"/>
  27.                         <asp:MenuItem NavigateUrl="~/Players.aspx" Text="Server Settings"/>
  28.                         <asp:MenuItem NavigateUrl="~/Players.aspx" Text="Messages"/>
  29.                         <asp:MenuItem NavigateUrl="~/Players.aspx" Text="Console"/>
  30.                     </Items>
  31.                 </asp:Menu>
  32.  
  33.         </div>

The relevant CSS is this (it's a bit of a mess, sorry..):
css Code:
  1. /* TAB MENU  
  2. ----------------------------------------------------------*/
  3.  
  4. div.hideSkiplink
  5. {
  6.     background: url('../Images/menu_bg.jpg');
  7.     width:100%;
  8.     height: 62px;
  9. }
  10.  
  11. div.menu
  12. {
  13.     padding: 18px 0px 0px 18px;
  14.     width: 940px;
  15.     height: 35px;
  16.     font-size: 1.0em;
  17. }
  18.  
  19. div.menu ul
  20. {
  21.     list-style: none;
  22.     margin: 0px;
  23.     padding: 0px;
  24.     width: auto;
  25. }
  26.  
  27. div.menu ul li a, div.menu ul li a:visited
  28. {
  29.     color: #ffffff;
  30.     display: block;
  31.     line-height: 1.35em;
  32.     padding: 4px 20px;
  33.     text-decoration: none;
  34.     white-space: nowrap;
  35. }
  36.  
  37. div.menu ul li a:hover
  38. {
  39.     color: #00ff00;
  40.     text-decoration: none;
  41. }
  42.  
  43. div.menu ul li a:active
  44. {
  45.     text-decoration: none;
  46. }
  47.  
  48. /* MISC  
  49. ----------------------------------------------------------*/
  50.  
  51. .clear
  52. {
  53.     clear: both;
  54. }
  55.  
  56. .title
  57. {
  58.     padding-left: 50px;
  59.     display: block;
  60.     float: left;
  61.     text-align: left;
  62. }
  63.  
  64. .title h1
  65. {
  66.     font-size: xx-large;
  67.     text-align: left;
  68. }
  69.  
  70. .title h2
  71. {
  72.     padding: 0px 0px 0px 80px;
  73.     font-size: xx-large;
  74. }
  75.  
  76. /* DIV that displays the 'Connected to' label, server name & ip and two links */
  77. .server
  78. {
  79.     padding: 15px 0px 0px 22px;
  80.     display: block;
  81.     float: left;
  82.     text-align: left;
  83.     width: 270px;
  84.     font-variant: normal;
  85.     font-weight: bold;
  86. }
  87.  
  88. .server h1, h2, h3, h4, h5
  89. {
  90.     font-size: large;
  91.     color: #ffffff;
  92.     text-align: left;
  93.     margin-bottom: 0px;
  94.     font-weight: bold;
  95.     font-variant: normal;
  96.     white-space: nowrap;
  97. }
  98.  
  99. /* h1 is for the server name */
  100. /* h3 is for the IP */
  101. .server h1, h3
  102. {
  103.     padding-left: 15px;
  104. }
  105.  
  106. /* h2 is for the 'Connected to' label */
  107. .server h2
  108. {
  109.     font-size: 1.2em;
  110.     font-weight: normal;
  111. }
  112.  
  113. .server h3
  114. {
  115.     font-size: 1.0em;
  116.     margin-top: 0px;
  117. }
  118.  
  119. /* h4 is for the 'View servers' link */
  120. /* h5 is for the 'Disconnect' link */
  121. .server h4, h5
  122. {
  123.     margin-top: 14px;
  124.     font-size: 1.2em;
  125.     float: left;    
  126. }
  127.  
  128. .server h5
  129. {
  130.     float: right;
  131. }


My question really is: how do I handle this?

When the server name is longer than the 'server' div (basically the black box) I want it to wrap around (otherwise most servers wouldn't fit). But if the server name is REALLY long it might wrap around 3 of 4 times in which case there would be no room for the links underneath...

Can i possibly limit the amount of wrapping so that it only wraps once? When it is longer still it should just cut off (or display some ellipsis " ..." if that's possible), or even just spill into the rest of the header (rather not..)


In each case, when the label does wrap, how do I stop the other elements underneath from being pushed down? The two links should remain on the same spot really, they shouldn't move down when the label turns out larger.


I hope I'm making myself clear. I'm really a CSS noob, the CSS I have now is mostly hacked together from various sources and I just kept trying until I got something that I liked...

Thanks!