2012-06-04 84 views
4

是否可以通過CSS/HTML僅在沒有JavaScript的情況下創建此圖像?因爲內容是動態的而圖像是透明的。僅使用CSS和HTML創建透明圖像

enter image description here

+0

是圖像*實際*文本的文本,或者是圖像本身的一部分?如果是文字,你可以發佈一些標記以供我們使用嗎? Ans,如果可能的話,鏈接到您試圖使用的圖像或演示文稿? –

+0

是的,它的文本 - –

回答

2

您已經分手圖像分爲多層:

  1. 色彩繽紛的背景
  2. 白色層與透明圈
  3. 眼睛和其他圖標把圓

內它可能看起來像這樣:

HTML:

<div class="colorful-box"> 
    <div class="box-with-circle"> 
     <span class="eye icon"/>Lorem Ipsum With eye 
    </div> 
</div> 

<div class="colorful-box"> 
    <div class="box-with-circle"> 
     <span class="ear icon"/>Lorem Ipsum an ear instead 
    </div> 
</div> 

CSS:

.colorful-box{ 
    background: url(link-to-the-colorfull-background.jpg); 
    width: 400px; 
    height: 100px; 
    float: left; 
} 

.box-with-circle{ 
    background: url(white-box-with-transparent-circle.png); 
    margin: 10px; 
    width: 380px; 
    height: 80px; 
    float: left; 
} 

.icon{ 
    width: 80px; 
    height: 80px; 
    float: left; 
    position: realtive; 
    top: 80px; /*Make it fit inside circle*/ 
    left: 80px; /*Make it fit inside circle*/ 
} 

.eye{ 
    background: url(transparent-eye.png); 
} 

.eye{ 
    background: url(transparent-ear.png); 
} 
+0

但如果文字超出了該區塊,文字背景將不再是圓框方塊,而是.colorful-box !!! –

2

是的,你可以在彼此疊放幾個圖像來創建你已經使用HTML CSS &貼什麼。

爲了得到透明度效果使用

.opacity40 { 
opacity:0.4; 
filter:alpha(opacity=40); /* For IE8 and earlier */ 
} 
+1

這是正確的答案。 –

0

當你需要動態加載的內容,則必須使用JavaScript來獲得訪問該內容。在你的情況下,如果圖像是靜態的,可以用css和html完成,並且要加載的內容必須使用javascript。

濾波器:α(不透明度= 0.001);對於即/ * */

不透明度:0.001;

+0

你能舉出這些例子嗎? –

+0

sample text
<腳本類型= 「文本/ JavaScript的」> $( 「跨度」)當量(1)的.text( 「動態文本」); – Ram