0

I have a question...

The subnavi on my website doesn't work proper... See the Screenshots: Here you see, how it looks like. The problem is, that the a-tag with "Mathematik & Naturwissenschaften" not resizes, if the browser window is small enough, so that the words wrap. It should look like the second picture, only with the wrap in a-tags with long words in it...<code>wrong</code>

Here you see, how it should look like... (in full screen => without wrapping) <code>right</code>

The HTML-Code:

<ul id="subnavi">    
    <li><a href="XYZ">Sprachen</a></li>
    <li><a href="XYZ">Gesellschaftswissenschaften</a></li>
    <li><a href="XYZ">Mathematik &amp; Naturwissenschaften</a></li>
    <li><a href="XYZ">künstlerisch-musische Fächer</a></li>
    <li><a href="XYZ">Religion</a></li>
    <li><a href="XYZ">Sport</a></li>
</ul>

The CSS-Code:

ul#subnavi a {
    float: left;
    font-size: 0.8em;
    letter-spacing: 1px;
    text-decoration: none;
    color: #fff;
    padding: 10px;
    padding-top: 2px;
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-weight: bold;
    line-height: 150%;
    background-color: #9c9e9f;
    clear: left;
}

I hope, that you understand my problem and can help me... :( I searched so long for a solution but I found nothing...

Farzad Yousefzadeh
  • 2,296
  • 1
  • 18
  • 26
Gykonik
  • 330
  • 1
  • 3
  • 11

3 Answers3

0

Simply add the line white-space: nowrap; to the CSS part. Here's a working sample https://jsfiddle.net/zkmpwry9/.

The white-space property is used to describe how whitespace inside the element is handled.

nowrap
Collapses whitespace as for normal, but suppresses line breaks (text wrapping) within text.

ul#subnavi a {
    float: left;
    font-size: 0.8em;
    letter-spacing: 1px;
    text-decoration: none;
    color: #fff;
    padding: 10px;
    padding-top: 2px;
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-weight: bold;
    line-height: 150%;
    background-color: #9c9e9f;
    clear: left;
    white-space: nowrap; /* the extra line */
}
Reda
  • 1,311
  • 10
  • 12
  • I want, that the text to wrap, but I don't want the space on the right, if it wraps... And white-space: nowrap; doesn't solve my problem, it only prohibits the wrapping, this is not my aim... – Gykonik Feb 11 '16 at 18:40
0

Use white-space: nowrap; this help to not colapse!

Fakux
  • 101
  • 1
  • 4
0

You can use: white-space: nowrap;

joe_young
  • 3,991
  • 2
  • 24
  • 36
Microsmsm
  • 2,854
  • 3
  • 17
  • 35