2017-04-22 47 views
0

我想破解文本以適應最大區域,但區域是動態的,文本數量也是如此。我有,所以我覺得這個形象,有利於如何使動態文本限制到某個特定點?

enter image description here

的圖片顯示我多麼希望它是,但粗糙的時間把它的話,因爲div的大小和文本的長度都是動態的;在某些分辨率下,文本分解並將按鈕從div中移除。 有沒有什麼辦法可以讓文本在最後一行上正確顯示?

.div { 
    position: relative; 
    width: 100%; 
    height: 44vh; 
    display: inline-block; 
} 

.text { 
    font-size: 100%; 
    text-align: left; 
    margin-top: 5px; 
    margin-left: 15px; 
    margin-bottom: 0px; 
    word-wrap: break-word; 
} 


#Button { 
    font-size: 1vw; 
    text-align: center; 
    display: inline-block; 
    background-color: green; 
    padding: 15px; 
    margin-top: 15px; 
    cursor: pointer; 
} 

jsfiddle here

+0

我們看一些你的代碼? –

+0

「在某些分辨率文本分解並推動div的按鈕」我想你的意思是不同的屏幕尺寸?如果是這種情況,可以使用媒體查詢在每個中斷點設置不同的字體大小 – kennasoft

+0

另一個堆棧可能的答案... https://graphicdesign.stackexchange.com/questions/44770/what-are-the-最好的做法,以處理與所需的線斷裂在響應瓦特 – Scott

回答

0

有沒有什麼辦法可以使文字休息權的最後一行它到達按鈕之前?

您可以使用word-wrap: break-word;white-space: nowrap;組合

.text-wrapper { 
    word-wrap: break-word; 
    white-space: nowrap; 
    overflow: hidden; 
} 

請看這個例子

.container { 
 
    border: 1px solid green; 
 
    padding: 5px; 
 
    text-align: center; 
 
} 
 

 
.text-wrapper { 
 
    border: 1px solid blue; 
 
    word-wrap: break-word; 
 
    white-space: nowrap; 
 
    overflow: hidden; 
 
}
<div class="container"> 
 
    <div class="text-wrapper"> 
 
    Lorem Ipsum Dolor Gedhang Goreng Lorem Ipsum Dolor Gedhang Goreng Lorem Ipsum Dolor Gedhang Goreng 
 
    </div> 
 
    <button>Button</Button> 
 
</div>

+0

我已經嘗試了文本的包裝,但包裝父級高度是動態的,因爲網絡比例隨分辨率而變化,因此在某些情況下會留下一些空白區域 – user3630772

相關問題