我需要在圖像的一些基本的文字我已經website.I首先給使用放置文本RGB和RGBA functions.Then透明黑盒子這樣做通過將圖像聲明爲「相對」而將文本聲明爲「絕對」來覆蓋它。
問題
當我調整瀏覽器,文本在向下的方向上耗盡的圖像。 它在https://jsfiddle.net/Lheg26kw/ 這裏顯示的是HTML的
<div class="hero-container">
<div class="hero-image">
<img src="https://upload.wikimedia.org/wikipedia/commons/0/05/Old-Style_Balinese_Cat.png" width=100% height=80%>
<div class="hero-text">
<p>This is text<br>
<span>this is some more text for trial of this problem</span></p>
</div>
</div>
</div>
這裏是CSS:
.hero-image{
position: relative;
width: 100%;
}
.hero-text p{
position: absolute;
text-align: center;
bottom: 0px;
top: 0px;
width: 100%;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.4);
padding-top: 80px;
color: white;
font-weight: bolder;
}
.hero-text span{
font-weight: normal;
}
需要
我需要的文本調整到最低後留在圖像金額,即如果通過手機訪問網站。
您的填充,頂部,您的段落的像素(80px)固定金額。這就是爲什麼你的文本被壓低。使填充頂部的百分比(即10%)保持相對於圖像。 – Goombah
爲文字添加前20-25%,併爲圖片指定最小寬度,即320px,或者您可以查看flexbox並使用此https://css-tricks.com/snippets/css/a-guide-to -flexbox / – Edrees