2016-09-20 92 views
-1

如果我有一個圖像,讓我們說有聊天對話。在圖像頂部的響應文本覆蓋

我想覆蓋文本頂部的div,然後我想在div上放一些文本。

當我縮小瀏覽器的尺寸時,文字應該變小,但位置保持不變。反之,當瀏覽器重新調整大小時,文本變得更大。

div可能是背景色,也​​應該像文本一樣重新調整比例。

.herotext span { 
    position: absolute; 
    bottom: 20px; 
    font-family: 'museo_slab500'; 
    font-size: 150%; 
    color: #fff; 
    padding: 0 20px; 
    width: 40%; 
    line-height: 150%; 
    background: rgb(0, 0, 0); 
    background: rgba(0, 0, 0, 0.7); 
} 

但是,即使嘗試了我的文字重新調整時,我重新調整我的瀏覽器,但我的DIV是白色背景不正確重新調整,並在瀏覽器關閉時,股利不重新調整。

此實現的任何解決方案或想法?

+0

你能告訴我們的HTML代碼呢? – Core972

回答

1

您可以使用「VW」文本中的CSS文本相對的大小設置爲您的設備的寬度:

.wrapper { 
 
    background-image: url('http://lorempixel.com/output/abstract-q-c-640-480-5.jpg'); 
 
    background-size: cover; 
 
    width: 100%; 
 
} 
 

 
.content { 
 
    font-size: 2.5vw; 
 
}
<div class="wrapper"> 
 
    <div class="content"> 
 
    <span> 
 
     Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    </span> 
 
    </div> 
 
</div>

https://jsfiddle.net/o3fcczwb/1/