2014-04-06 44 views
0

所以在早些時候,我試圖弄清楚如何使用CSS將透明圖像變暗,但是當我發現這一點時,新的問題出現了,我將如何將文本置於其上?這是我迄今爲止... http://jsfiddle.net/PXU6j/3/文字在黑暗的透明背景之上

<h1> Any Help Will Be appreciated </h1> 
+0

根據文本你的意思是標誌或新的內容?你在掙扎什麼? –

+4

在您的問題中發佈您的代碼,並且不要在鏈接到jsFiddle.net時嘗試避開這樣做的SO規則。 – j08691

+0

就像在透明度之上一般地發佈文本一樣。 – user3430532

回答

0

http://jsfiddle.net/j8592/27/

/* apply a natural box layout model to all elements */ 
*, *:before, *:after { 
    -moz-box-sizing: border-box; 
    -webkit-box-sizing: border-box; 
    box-sizing: border-box; 
} 
.container { 
    position: relative; 
    display: inline-block; 
} 
.container img {float: left;} 
.foo-background { 
    background: rgba(0,0,0,0.5); 
    position:absolute; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
} 
.foo-text { 
    position: absolute; 
    left: 0; 
    top:0; 
    width: 100%; 
    height: 100%; 
    color: #f2f2f2; 
    padding: 20px; 
} 
+0

是的,那不起作用 – user3430532

+0

你是什麼意思,它不起作用? – JohanVdR