2016-11-12 4 views
1

Das Problem ist egal, was ist in chat_ttc es wird immer 300px sein.Div automatisch nimmt seine maximale Breite

Snippet:

.chat_ttc { 
 
    max-width: 300px; 
 
    word-break: break-word; 
 
    background: #e5e5e5; 
 
    margin-left: 70px; 
 
    position: relative; 
 
    border-radius: 15px; 
 
    border-bottom-left-radius: 0px; 
 
    padding: 4px; 
 
    padding-left: 6px; 
 
    letter-spacing: 0.6; 
 
}
<div class="froma_tc"> 
 
    <div class="chat_ttc">D</div> 
 
</div>

Antwort

2

Yaa sein, weil div Blockelement ist und es dauert 100% der Breite wie Sie max-width als 300px Breite immer 300px sein wird gegeben haben

Wenn Sie eine gültige Breite nehmen möchten, machen Sie div als Inline-Block

überprüfen dieser Ausschnitt

.chat_ttc { 
 
    max-width: 300px; 
 

 
    display:inline-block; 
 
    word-break: break-word; 
 
    background: #e5e5e5; 
 
    margin-left: 70px; 
 
    position: relative; 
 
    border-radius: 15px; 
 
    border-bottom-left-radius: 0px; 
 
    padding: 4px; 
 
    padding-left: 6px; 
 
    letter-spacing: 0.6; 
 
}
<div class="froma_tc"> 
 
    <div class="chat_ttc">D</div> 
 
</div>

Hope this

+0

Dank hilft es half! – Papaa

+1

Sie können es als richtig markieren. Und ja: div ist ein Block-Level-Element, also wird es seine max. Google Inline vs Block für mehr dazu. –

Verwandte Themen