Solved

WaterMark Image with javascript

Posted on 2008-06-18
5
1,516 Views
Last Modified: 2012-06-21
Hi all,
I have web application developed by asp.net 2.0 (VS 2005), I have a page displaying a table with thefollowing information: Car Model ,Description and Image.
In the Database i stored image as a path. and i use a datalist control to display these information as a table.

Challenge:
When a car is sold, then i want to display a stamp such as [SOLD] to be displayed over the image.
i tried many ways, such as javascript [attahed code snippet]. but the problem is:
When i minimize the browser the [SOLD]  displayed in the same position that because position:absolute.

<ItemTemplate>

        <br />

        <table border="1" style="width: 100px; height: 100px">

         <tr>

         <td style="width: 100px">

        <asp:Image ID="Image1" runat="server" Height="94px" ImageUrl='<%# Eval("img") %>'

        Width="134px" />

       <script type="text/javascript" language="javascript">

       var top;

       var left;

      top=document.getElementById("DataList1_ctl00_Image1").style.top;

      left=450;

     document.write("<font color='red'><div id='d1' style='left:"+left+"px; width: 100px; position: absolute; top:"+top+"px; height: 100px;font-size:50px;font-color:red'>[SOLD]</div></font>")

          </script> 

     </td>

    </tr>

</table>

<br />

</ItemTemplate>

Open in new window

0
Comment
Question by:Mremawi
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
bluefezteam earned 200 total points
Comment Utility
You should use CSS for this - i did it for a property site.

<div class="imageHolder"><img src="car.jpg"/><img src="sold.jpg" class="sold"/></div>

.imageHolder {
display:block;
width:200px;
height:100px;
position:relative;
}
.imageHolder .sold {
position:absolute;
bottom:0;
left:0;
}

This will then holder a sold sign at the base of the image so you can still see the item on sale/sold but there's a sold image over it.

in action or a variation of it can be seen here

http://www.jhilditch.com/buy.html
0
 
LVL 10

Expert Comment

by:bluefezteam
Comment Utility
If possible can you move this item to CSS ? it is a CSS related issue.
0
 
LVL 1

Author Comment

by:Mremawi
Comment Utility
Dear bluefezteam:

thank you very much for your solution, but can I make the image sold in middle of car.jpg image?
0
 
LVL 10

Expert Comment

by:bluefezteam
Comment Utility
yes - instead of bottom:0; you just need to know the height of your JPEG and divide that by 2, then remove the height of the sold.jpg divided by 2.

Eg

the car graphic is 100px high - its mid point is 50px.
The sold image that sits on the top is 30px - its mid point is 15px.

this means to get sold.jpg to appear over the middle of the the car.jpg you pocition it from TOP or BOTTOM by 50-15 = 35px.

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now