CSS Code
1 2 3 4 5 6 7 8 | <style type= "text/css" > #overLayText{ position : relative ; bottom : 0px ; font-size : 12px ; padding : 5px ; } </style> |
HTML Code
1 2 3 4 5 6 | < div id = "hilightDiv" > < img src = "demo/big_img.jpg" /> < div id = "overLayText" > เรียนรู้การทำอาหารจากมืออาชีพ ได้แล้ว โดยไม่เสียค่าใช้จ่ายใดๆ </ div > </ div > |
Javascript Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <script type= "text/javascript" src= "js/jquery-1.2.6.min.js" ></script> <script type= "text/javascript" > $( function (){ var Tw=$( "#hilightDiv img" ).width(); var Tw2=Tw-$( "#overLayText" ).css( "padding" ); $( "#hilightDiv" ).width(Tw); var Th=$( "#overLayText" ).height()+10; $( "#overLayText" ).css({ "background-color" : "#000000" , "color" : "#FFFFFF" , "top" :-Th, opacity:0.75 }); }); </script> |
ตัวอย่าง

เรียนรู้การทำอาหารจากมืออาชีพ ได้แล้ว โดยไม่เสียค่าใช้จ่ายใดๆ