2017-12-31 26 views
0

ich brauche:Inline-Block: Es wurde umbrochen aber besonders viel Platz auf der rechten Seite nach links

enter image description here

ich habe:

enter image description here

Also "Fiskus" umbrochen wurde Allerdings hat es ziemlich viel Platz gelassen, trotz orange div ist Inline-Block. CSS:

.BlockContainer{ 
 
    background: blue; 
 
    width: 400px; 
 
} 
 

 
.InlineBlock { 
 
    display: inline-block; 
 
    background: teal; 
 
    font-size: 18px; 
 
    line-height: 1.2; 
 
    font-weight: 700; 
 
    text-transform: uppercase; 
 
    color: #f5511e; 
 
    padding: 2px 4px; 
 
}
<div class="BlockContainer"> 
 
    <div class="InlineBlock"> 
 
    Dumpy kibitzer jingles as exchequer overflows. 
 
    </div> 
 
</div>

+0

Wo ist das Problem? https://jsfiddle.net/Liamm12/fv0jzo9k/ – Liam

+0

Und was willst du stattdessen? Um das Wort mit einem Bindestrich zu brechen? Um die Schriftgröße anzupassen? – agrm

+1

Dieses Problem im Zusammenhang mit Padding oder Breite – Liam

Antwort

1

Wenn Sie diese Ausgabe müssen Sie br Tag nach dem Wort zu verwenden. Standardmäßig wird der Text versuchen, den gesamten Raum der Linie zu nehmen, und es bricht, wenn es nicht den Raum verlassen kann Sie sehen:

.BlockContainer{ 
 
    background: blue; 
 
    width: 400px; 
 
} 
 

 
.InlineBlock { 
 
    display: inline-block; 
 
    background: teal; 
 
    font-size: 18px; 
 
    line-height: 1.2; 
 
    font-weight: 700; 
 
    text-transform: uppercase; 
 
    color: #f5511e; 
 
    padding: 2px 4px; 
 
}
<p>Inline-block alone (no spaces)</p> 
 
<div class="InlineBlock"> 
 
    Dumpy kibitzer jingles as exchequer overflows. 
 
    </div> 
 

 
<p>Inline-block with fixed width of parent (in this case upper text fit the space)</p> 
 
<div class="BlockContainer"> 
 
    <div class="InlineBlock"> 
 
    Dumpy kibitzer jingles as exchequer overflows. 
 
    </div> 
 
</div> 
 
<p>Inline-block with fixed width of parent (no enough space for text so line break)</p> 
 
<div class="BlockContainer" style="width:350px;"> 
 
    <div class="InlineBlock"> 
 
    Dumpy kibitzer jingles as exchequer overflows. 
 
    </div> 
 
</div> 
 
<p>Inline-block with fixed width of parent and *br*</p> 
 
<div class="BlockContainer" style="width:350px;"> 
 
    <div class="InlineBlock"> 
 
    Dumpy kibitzer jingles as<br> exchequer overflows. 
 
    </div> 
 
</div>

+0

Vielen Dank für die Antwort. Es tut mir leid, aber Ihre Herangehensweise reagiert nicht. Es ist in Ordnung, wenn wir das Fix-Weiten-Layout betrachten, aber es ist eine andere Lösung für den responsiven Layout-Fall erforderlich. –

+0

@GurebuBokofu meine Antwort versuchen Sie einfach, Ihr Verhalten zu erklären, das das normale Verhalten ist :) Ich weiß, die Verwendung von br ist nicht der beste Weg, aber tatsächlich und ich sehe keine andere Alternative, aber denke ich;) –

+0

OK, trotzdem danke für Erklärungen! –

Verwandte Themen