How to make a gif clickable to a new page? - hyperlink

I would like to make a gif clickable to a new page. I'm not sure what code to include and have tried many options that did not work out. The following is part of the code:
<div class="col-md-7 col-sm-4 col-xs-12" style="background-image: url('xx.gif'); background-size: cover; background-position: 50% 50%;" id="xx" data-image-url="xx.gif">
Thank you in advance!

Welcome to SO. HTML link use the <a> tag with the intended URL in the href property. Wrap your GIF in an <a> tag to make it clickable.

Related

How to add icon to mat-icon-button

I am using Angular with Material
<button mat-icon-button><mat-icon svgIcon="thumb-up"></mat-icon>Start Recording</button>
I am trying to add an icon to button, but I can't figure out how to do it, and can't find documentation for this.
https://material.angular.io/components/button/api
looking the docs, there is this:
that button has the following html:
<a _ngcontent-c1="" aria-label="Angular Material" class="docs-button mat-button" mat-button="" routerlink="/" tabindex="0" aria-disabled="false" href="/"><span class="mat-button-wrapper">
<img _ngcontent-c1="" alt="angular" class="docs-angular-logo" src="../../../assets/img/homepage/angular-white-transparent.svg">
<span _ngcontent-c1="">Material</span>
</span> <div class="mat-button-ripple mat-ripple" matripple=""></div><div class="mat-button-focus-overlay">
</div>
</a>
is that the right way to do it?
Just add the <mat-icon> inside mat-button or mat-raised-button. See the example below. Note that I am using material icon instead of your svg for demo purpose:
<button mat-button>
<mat-icon>mic</mat-icon>
Start Recording
</button>
OR
<button mat-raised-button color="accent">
<mat-icon>mic</mat-icon>
Start Recording
</button>
Here is a link to stackblitz demo.
All you need to do is add the mat-icon-button directive to the button element in your template. Within the button element specify your desired icon with a mat-icon component.
You'll need to import MatButtonModule and MatIconModule in your app module file.
From the Angular Material buttons example page, hit the view code button and you'll see several examples which use the material icons font, eg.
<button mat-icon-button>
<mat-icon aria-label="Example icon-button with a heart icon">favorite</mat-icon>
</button>
In your case, use
<mat-icon>thumb_up</mat-icon>
As per the getting started guide at https://material.angular.io/guide/getting-started, you'll need to load the material icon font in your index.html.
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
Or import it in your global styles.scss.
#import url("https://fonts.googleapis.com/icon?family=Material+Icons");
As it mentions, any icon font can be used with the mat-icon component.
My preference is to utilize the inline attribute. This will cause the icon to correctly scale with the size of the button.
<button mat-button>
<mat-icon inline=true>local_movies</mat-icon>
Movies
</button>
<!-- Link button -->
<a mat-flat-button color="accent" routerLink="/create"><mat-icon inline=true>add</mat-icon> Create</a>
I add this to my styles.css to:
solve the vertical alignment problem of the icon inside the button
material icon fonts are always a little too small compared to button text
button.mat-button .mat-icon,
a.mat-button .mat-icon,
a.mat-raised-button .mat-icon,
a.mat-flat-button .mat-icon,
a.mat-stroked-button .mat-icon {
vertical-align: top;
font-size: 1.25em;
}
Add to app.module.ts
import {MatIconModule} from '#angular/material/icon';
& link in your global index.html.
the above CSS can be written in SASS as follows (and it actually includes all button types, instead of just button.mat-button)
button,
a {
&.mat-button,
&.mat-raised-button,
&.mat-flat-button,
&.mat-stroked-button {
.mat-icon {
vertical-align: top;
font-size: 1.25em;
}
}
}
The Material icons use the Material icon font, and the font needs to be included with the page.
Here's the CDN from Google Web Fonts:
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

Padding issue with foundation 6 and top-bar with user avatar image

I have a nav-bar and trying to place the users name and profile picture in the nav-bar with a dropdown menu. Its working fine except I cant get the padding/margins right to prevent it from making the top-bar larger when the image is there. This is the html for the part of the top-bar with the user avatar and name (its a dropdown menu)
<div class="top-bar-right">
<ul class="dropdown menu" data-dropdown-menu>
<li>
<a class="avatar">
<%= image_tag(current_user.avatar.present? ? current_user.avatar : "default-user.jpg", width: "40", height: "40") %>
<span><%= current_user.displayname.present? ? current_user.displayname : current_user.firstname %></span>
</a>
<ul class="menu vertical">
......
</ul>
</li>
</ul>
</div>
Ive tried adding various classes and editing the css but I cant seem to get rid of the padding that creates the extra space...I can make the image smaller but the size gets to small to prevent the padding making the bar larger. Heres a screenshot of what i mean with the bar being too tall, you can see that there is a gap under the rest of the bar besides the image:
EDIT: Been playing around and still cant figure this out, Ive updated the screenshot with the inspect so you can see the specific html. Also ive tried to add a class "avatar" and added this to my scss file:
a.avatar{
padding-top: 500px;
padding-bottom: 0px;
}
but it doesnt change anything (tested with another element and it did change things)
EDIT 2: Figured it out...took awhile but I had to fully define the path in the css. So it turned out to be this:
.dropdown.menu li.is-dropdown-submenu-parent a.avatar{
padding-top: 0rem;
padding-bottom: 0rem;
}
And that worked out perfectly....thanks for all the comments still

Using custom icons on left and right in jquery mobile list

I'm trying to figure out how to add custom icons on the left and right side of a list item. I found this example (see link and code below) but if you notice the icon does not show up, it's just an empty circle. At first I thought it was because the link was invalid but I tried it on my page with my own image but the same thing happened. Unfortunately I only have a reputation of 13 so I am not allowed to post pictures, however here is a sample of how I would like the li item to have icons on both ends.
-*****************************-
| icon_left TEXT icon_right |
-*****************************-
<html>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<style>
.ui-icon-myapp-smiley {
background-image: url(http://swiftthemes.com/forums/images/icons/icon6.png) !important;
}
</style>
<div data-role="page">
<div data-role="content">
<ul data-role="listview">
<li data-icon="myapp-smiley">My LI!!!</li>
</ul>
</div>
</div>
</html>
Code on jsfiddle page http://jsfiddle.net/KYaQT/
jQM 1.0.1 is quite old and outdated now. You should upgrade to 1.4 and jQuery 1.9 or greater.
<ul data-role="listview" data-inset="true" >
<li data-icon="myicon"><span class="ui-icon-myicon2 ui-btn-icon-notext inlineIcon"></span>Text in list item 1</li>
</ul>
.ui-icon-myicon:after {
background-image: url("http://people.mozilla.org/~shorlander/files/australis-linux-svg-test/images-linux/toolbarButton-bookmark.svg");
}
.ui-icon-myicon2:after {
background-image: url("http://forum.librecad.org/images/gear.png");
}
.inlineIcon {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
For the icon on the right you had the correct approach. Set the data-icon attribute on the <LI>. In jQM 1.4, the CSS uses the pseudo :after element for the background image.
To add an icon on the left, you can put a span inline with the text and add CSS to position it.
If you don't want the gray disk behind the icon, set the background color transparent:
.ui-icon-myicon2:after {
background-image: url("http://forum.librecad.org/images/gear.png");
background-color: transparent;
}
Here is a DEMO

ASP MVC3 Use image as link to a different View/Controller

Sorry if this is a benign question but still new to ASP MVC3 - what is the best syntax for using an image as a link? It needs to navigate to the Index.cshtml page of another Controller (called Home).
What I have below causes the image to completely disappear:
<a href="#Url.Action("Index", "Home")><img src="#Url.Content("~/Content/images/Monet3.png")" id="MonetSig" /></a>
I think that there is a closing " missing after #Url.Action("Index", "Home") it might be the problem
I would use CSS to give the anchor a background image. This way you can easily change the image for mobile or tablets:
CSS:
#MonetSig {
display: block;
width:100px; /* change this to your image width and height */
height:100px;
background: url('../images/Monet3.png') no-repeat;
}
Html:
<a id="MonetSig" href="#Url.Action("Index", "Home")"></a>

How to center an image inside a button, using jQuery Mobile?

I'm new to jQuery mobile and Phonegap. Sorry if this is not the place to ask for this question.
I'm trying to put a custom image inside a button (not the small icon to the left or to the right but a bigger image).
I use the following code:
<a data-role="button" data-corners="false" data-shadow="false" >
<img src="images/car.png" />
</a>
In the rendering, the image is not centered but goes right.
I have also tried using a class="car-icon" and the corresponding css3 rule:
.ui-icon-car-icon {
background-image: url("car.png");
}
.ui-icon-car-icon {
text-align: center;
}
Any help will be greatly appreciated (I have spent the whole night trying to fix this).
Thanks in advance.
Try using the thing, like this: http://jsfiddle.net/den232/sFupf/
<button><img src="http://doc.jsfiddle.net/_downloads/jsfiddle-logo.png" height=35 width=35 ></button>
Good luck!
You can try setting your image as the background of your link <a>, and centering it using background-position: center center;:
HTML:
<a id="mybutton" data-role="button" data-corners="false" data-shadow="false" > </a>
CSS:
#mybutton {
background: url('car.png') no-repeat scroll 0 0 transparent;
background-position: center center;
}

Resources