2016-12-19 60 views
0

我想在顯示鼠標時顯示一些文字。你能幫我嗎?我怎樣才能隱藏和顯示圖像上的文字?在我的代碼下面。我想在使鼠標移過時顯示一些文字

.foodMenu { 
 
\t text-align: center; 
 
\t background-image: url(../img/burger.jpg); 
 
\t background-image: url(../img/burger.jpg); 
 
\t background-image: url(../img/burger.jpg); 
 
\t background-size: cover; 
 
\t background-position: center; 
 
\t height: 210px; 
 
\t width: 280px; 
 
\t } 
 

 
.foodMenu .menuTitle { 
 
\t font-size: 22px; 
 
\t text-transform: none; 
 
\t } 
 
\t 
 
.foodMenu .menuTitle:hover { 
 
\t 
 
\t }
<div class="col span-1-of-4 step_box"> 
 
    <div class="foodMenu"><h3 style="color:#ffffff;" class="menuTitle">Burgers</h3></div> 
 
</div>

IV>

回答

4

.foodMenu { 
 
\t text-align: center; 
 
\t background-image: url(../img/burger.jpg); 
 

 
    /**** Do not repeat your Commands 
 
\t background-image: url(../img/burger.jpg); 
 
\t background-image: url(../img/burger.jpg); 
 
    ****/ 
 

 
\t background-size: cover; 
 
\t background-position: center; 
 
\t height: 210px; 
 
\t width: 280px; 
 
    
 
    /* positioning to make the text element inside the div */ 
 
    position:relative; 
 
\t } 
 

 
.foodMenu .menuTitle { 
 
\t font-size: 22px; 
 
\t text-transform: none; 
 

 
    /** position text element **/ 
 
    position:absolute; 
 
    bottom:0; 
 
    left:0; 
 
    right:0; 
 

 
    opacity:0; /* opacity to hide the element */ 
 
    background:rgba(0,0,0,.75); /* background for good looking */ 
 
    transition:all 0.3s; /* animation effect */ 
 
    -webkit-transition:all 0.3s; /* animation effect */ 
 
\t } 
 
\t 
 
.foodMenu:hover .menuTitle { 
 
\t opacity:1; /* opacity to show the element on mouse over */ 
 
\t }
<div class="col span-1-of-4 step_box"> 
 
    <div class="foodMenu"><h3 style="color:#ffffff;" class="menuTitle">Burgers</h3></div> 
 
</div>

+0

沒錯這就是工作。感謝幫助 – atomant

相關問題