css and master page asp.net problem - asp.net

i had used the following code in master page of asp.net project
<a runat="server" href="home.htm" onmouseover="document.Home_Img.src='Images/home_2.png'"
onmouseout="document.Home_Img.src='Images/home.png'">
<img alt="" src="Images/home.png" name="Home_Img" runat="server" />
</a>
It is working well for all associated webforms in the root directory but not in the sub directory pages.
any sugesstion would be respected.
Thnx in advance...

You're using a relative URL Images/home.png for the image location, change it to absolute /Images/home.png:
<a runat="server" href="home.htm" onmouseover="document.Home_Img.src='/Images/home_2.png'"
onmouseout="document.Home_Img.src='/Images/home.png'">
<img alt="" src="/Images/home.png" name="Home_Img" runat="server" />
</a>
Also, this has nothing to do with CSS since you're using old school Javascript mouseovers. I would strongly suggest you change it to something like:
<style>
a.home {
background: url(/Images/home.png) no-repeat;
display: block; /* this may not be correct, depends on the layout */
height: 100px; /* height of image */
text-indent: 9999px;
width: 100px; /* width of image */
}
a.home:hover {
background: url(/Images/home_2.png) no-repeat;
}
</style>
<a class="home" href="home.htm">Home</a>

Put the URL's of your wrapped in the ResolveUrl like so:
<a runat="server" href="<%= this.ResolveUrl("home.htm") %>" onmouseover="document.Home_Img.src='<%= this.ResolveUrl("Images/home_2.png") %>'"
onmouseout="document.Home_Img.src='<%= this.ResolveUrl("Images/home.png") %>'">
<img alt="" src="Images/home.png" name="Home_Img" runat="server" />
</a>

Related

Wordpress CSS image autoresponsive

The following image demonstrates what I'm trying to accomplish.
The A) it's on webbrowser of computer, which displays cool. The B) it's on mobile devices or small screens. I would like to make the images appear on mobile devices like the A).
I'm attempting this on Wordpress in the header.php. I've been searching and I've got this:
<a href="http://url">
<img src="http://urlIMAGE" width="100px" height="95px" style="max-width: 100%; height: auto;"/></a>
<a href="url" target="_blank">
<img src="http://urlIMAGE" width="100px" height="95px" style="max-width: auto; height: auto;"/></a>
But it's not working.
a img{width:100%; float:left;}
You could use some thing like:
float: left;
or
float: right;
inside your style attribute. See if that works.

How to make a section of an image a clickable link

I have a banner on web page, and part of the image there is a graphic of a button box. How do I make just the part where the button is a clickable link such as a href? You can see a sample image below.
In the banner image there is a "Join Now, Its Free" Button graphic. I want to add a link on this box, so when users click on this box on the banner, then it will open the next page. I want to know how I can add a link on just this button. I don't want to add the <button> tag to it; I just want to add a link based on the area of the "Join Now, Its Free" Button graphic. Anybody have any ideas on how I can add a link on this part of the image area without using the <button> tag.
<div class="flexslider">
<ul class="slides" runat="server" id="Ul">
<li class="flex-active-slide" style="background: url("images/slider-bg-1.jpg") no-repeat scroll 50% 0px transparent; width: 100%; float: left; margin-right: -100%; position: relative; display: list-item;">
<div class="container">
<div class="sixteen columns contain"></div>
<img runat="server" id="imgSlide1" style="top: 1px; right:
-19px; opacity: 1;" class="item"
src="images/slider1.png" data-topimage="7%">
</div>
</li>
</ul>
</div>
<ul class="flex-direction-nav">
<li><a class="flex-prev" href="#"><i class="icon-angle-left"></i></a></li>
<li><a class="flex-next" href="#"><i class="icon-angle-right"></i></a></li>
</ul>
</div>
Thank You
If you don't want to make the button a separate image, you can use the <area> tag. This is done by using html similar to this:
<img src="imgsrc" width="imgwidth" height="imgheight" alt="alttext" usemap="#mapname">
<map name="mapname">
<area shape="rect" coords="see note 1" href="link" alt="alttext">
</map>
Note 1: The coords=" " attribute must be formatted in this way: coords="x1,y1,x2,y2" where:
x1=top left X coordinate
y1=top left Y coordinate
x2=bottom right X coordinate
y2=bottom right Y coordinate
Note 2: The usemap="#mapname" attribute must include the #.
EDIT:
I looked at your code and added in the <map> and <area> tags where they should be. I also commented out some parts that were either overlapping the image or seemed there for no use.
<div class="flexslider">
<ul class="slides" runat="server" id="Ul">
<li class="flex-active-slide" style="background: url("images/slider-bg-1.jpg") no-repeat scroll 50% 0px transparent; width: 100%; float: left; margin-right: -100%; position: relative; display: list-item;">
<div class="container">
<div class="sixteen columns contain"></div>
<img runat="server" id="imgSlide1" style="top: 1px; right: -19px; opacity: 1;" class="item" src="./test.png" data-topimage="7%" height="358" width="728" usemap="#imgmap" />
<map name="imgmap">
<area shape="rect" coords="48,341,294,275" href="http://www.example.com/">
</map>
<!---->
</div>
</li>
</ul>
</div>
<!-- <ul class="flex-direction-nav">
<li><a class="flex-prev" href="#"><i class="icon-angle-left"></i></a></li>
<li><a class="flex-next" href="#"><i class="icon-angle-right"></i></a></li>
</ul> -->
Notes:
The coord="48,341,294,275" is in reference to your screenshot you posted.
The src="./test.png" is the location and name of the screenshot you posted on my computer.
The href="http://www.example.com/" is an example link.
You can auto generate Image map from this website for selected area of image. https://www.image-map.net/
Easiest way to execute!
by creating an absolute-positioned link inside relative-positioned div..
You need set the link width & height as button dimensions, and left&top coordinates for the left-top corner of button within the wrapping div.
<div style="position:relative">
<img src="" width="??" height="??" />
</div>
The easiest way is to make the "button image" as a separate image.
Then place it over the main image (using "style="position: absolute;".
Assign the URL link to "button image".
and smile :)

Link on half of an image in CSS

I have an image of a logo which has a slogan underneath it. I want the logo as a hyperlink for the home page but I want it to be only clickable from the actual logo and not the slogan underneath it. But I cant manage to achieve this because the logo and slogan are part as one image.
Is there anyway around this other than having 2 separate images?
HTML:
<a href="http://www.dalewoods.com" id="logo_link">
<img src="images/logo.png" alt="Dale Woods" class="logo"/></a>
CSS:
img.logo {
margin-top: 20px;
}
You could use <map> and <area> to create an image map on the image. The area can then be used to link only parts of the image.
Here is a simple example that you could modify to fit your needs:
<map name="a">
<area shape="rect" coords="25,25,75,75" href="http://www.dalewoods.com">
</map>
<img src="images/logo.png" alt="Dale Woods" class="logo" usemap="#a" />
In this example, only the part of the logo covered by the rectangle area will be linked.
Yes, there is. :)
<div id="logo">
Dale Woods
</div>
And CSS:
#logo {
width:200px;height:200px;position:relative;
background:url(images/logo.png) no-repeat;overflow:hidden;
}
#logo_link {
display:block;position:absolute;top:0;left:0;
width:200px;height:150px;text-indent:-2000px;
}
The positions and dimensions have to be changed, but structurally this should solve your problem.
Here is an example: http://codepen.io/anon/pen/KEdrc
HTML:
<div class="logo">
<img src="image.png" alt="Logo">
</div>
CSS:
.logo {
display: inline-block;
position: relative;
}
a {
position: absolute;
left: 0; top: 0;
height: 50%; width: 100%;
}
img { display: block; }
I tried to explain here on how to do this.. Check the fiddle and you could get an idea of how to do that...
Example
<img src="example.gif" width="145" height="126" alt="Example" usemap="#Example">
<map name="Example">
<area shape="rect" coords="0,0,82,126" alt="Firsthalf" href="#">
</map>
​
Here think that the image and the first half is clickable and the second is not clickable. Try to do that as the same or provide your image in the fiddle..
Having a 286x176 pixels image, this is how I achieved it so that the left half is a link to Android and the right half links to Apple:
<map name="logos">
<area shape="rect" coords="0,0,143,176" href="http://www.android.com" title="Link to Android" alt="Link to Android">
<area shape="rect" coords="143,0,286,176" href="http://www.ios.com" title="Link to Apple" alt="Link to Apple">
</map>
<img src="myimage.png" usemap="#logos">

How to align vertically an unknown sized image in a div

I have a menu made of an <ul>. Every <li> has inside an <a>, and every <a> has an image and a label.
the image changes on hover (javascript) into a bigger image, so the size of the images is of no help. I would like to align the image vertically on the middle of the menu item. here you have the code:
<script type="text/javascript">
<!--
function changeImage(element, toReplace, withReplace) {
var str = document.getElementById(element).src;
document.getElementById(element).src = str.replace(toReplace, withReplace)
}
// -->
<%# Control Language="C#" AutoEventWireup="true" CodeFile="Menu.ascx.cs" Inherits="UserControls_Menu" %>
<ul id="navmenu">
<li><a id="default" runat="server" href="~/Default.aspx" onmouseover="changeImage('sideBar_Menu1_Image7', 'Calendar24x24.png', 'Calendar32x32.png');"
onmouseout="changeImage('sideBar_Menu1_Image7', 'Calendar32x32.png', 'Calendar24x24.png');">
<div class="divImage">
<asp:Image ID="Image7" runat="server" ImageUrl="~/Images/Calendar24x24.png" />
</div>
<div class="divLabel">
<asp:Label ID="Label6" runat="server" Text="CALENDAR" meta:resourcekey="Label6Resource1"></asp:Label>
</div>
</a></li>
.divImage
{
width: 29px;
height: 29px;
float: left;
text-align: center;
vertical-align: middle;
}
.divLabel
{
float: left;
padding-top: 3px;
}
no matter what I do, align-vertically doesn't work...the only way I made things work was with tables, but then the click only works on the image, it doesn't on the lable too...I tried without divs too, can't find a way
edit 3
http://jsfiddle.net/HerrSerker/td4jy/2/
edit 2
another proposal is
don't put them inside as <img /> element but as background-image with background-position: 10px 50% or something
edit 1
http://jsfiddle.net/HerrSerker/sftGT/1
orig
Don't use float: left floats are not vertically alignable. use display:inline-block instead together with line-height values.

Best "Loading" feedback for ASP.Net?

So, we have an ASP.Net application - fairly standard - and in there are lots of updatepanels, and postbacks.
On some pages we have
<ajax:UpdatePanelAnimationExtender ID="ae" runat="server" TargetControlID="updatePanel" BehaviorID="UpdateAnimation">
<Animations>
<OnUpdating>
<FadeOut Duration="0.1" minimumOpacity=".3" />
</OnUpdating>
<OnUpdated>
<FadeIn minimumOpacity=".5" Duration="0" />
</OnUpdated>
</Animations>
</ajax:UpdatePanelAnimationExtender>
Which basically whites out the page when a postback is going on (but this clashes with modal dialog grey backgrounds). In some cases we have a progressupdate control which just has a spinny icon in the middle of the page.
But none of them seem particularly nice and all a bit clunky. They also require a lot of code in various places around the app.
What methods do other people use and find effective?
i havent used the UpdatePanelAnimationExtender but an UpdateProgress-Control in combination with an animated gif(Bermos Link):
<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="UdpImeiLookup" DisplayAfter="500" >
<ProgressTemplate>
<div class="progress">
<img src="images/ajax-loader-arrows.gif" /> please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
The ProgressTemplate will be visible on every Postback of the associated Update Panel(after 500ms in this example).
EDIT: where class "progress" can be f.e. this:
.progress
{
text-align:center;
vertical-align:middle;
position: absolute;
left: 44%;
top: 35%;
border-style:outset;
border-color:silver;
background-color:Silver;
white-space:nowrap;
padding:5px;
}
Regards,
Tim
Like the others, I suggest to use the UpdateProgress in a modal popup.
I will add this twist, put the popup, UpdateProgress and this code in a masterpage, so whenever you need it, just plug the masterpage to the content page.
<script type="text/javascript">
var ModalProgress ='<%= ModalProgress.ClientID %>';
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endReq);
function beginReq(sender, args){
// shows the Popup
$find(ModalProgress).show();
}
function endReq(sender, args)
{
// hide the Popup
$find(ModalProgress).hide();
}
</script>
here some ref:
http://mattberseth.com/blog/2007/07/modalpopup_as_an_ajax_progress.html
http://vincexu.blogspot.com/2008/10/how-to-make-modalupdate-progress-bar-on.html
Animated gifs require the least amount of code and you can select your favourite one with whatever colours you please from the following site - Ajaxload - Ajax loading gif generator.
This is what I use, it has a modal popup type background and a gif
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div style="position: absolute; width: 100%; height: 100%; z-index: 100; background-color: Gray;
filter: alpha(opacity=70); opacity: 0.7;">
</div>
<table style="position: absolute; width: 100%; height: 100%; z-index: 101;">
<tr>
<td align="center" valign="middle">
<div style="color: Black; font-weight: bolder; background-color: White; padding: 15px;
width: 200px;">
<asp:Image ID="Image3" runat="server" ImageUrl="~/Images/progress.gif" />
Please wait....
</div>
</td>
</tr>
</table>
</ProgressTemplate>

Resources