html/css Tranparency in image link not clickable - image

I have a .png image of a star. The area around the star is transparent. Here is an example of my code
<a href='nextPage.html'><img src='starImage.png' border='0'></a>
How do I get only the star part of the image to be clickable?
-or-
How do I get the transparent parts of the image to not be clickable?

You need to use an area shape map
<a href='nextPage.html'><img src='starImage.png' border='0'usemap="#Map" /></a>
<map name="Map" id="Map">
<area shape="poly" coords="54,52,55,52,94,77,118,42,179,63,174,119,105,128,50,122,31,84,54,53" href="#" />
</map>
this is only an example.
You must use the area shape map tool on dreamweaver and draw the polygon of area u need.

you need to use an imagemap check out this site to help you do it...
http://www.image-maps.com/
For more information about what an image map is see this wikipedia article.
Image map

In fact we can make the parent element position:relative, and use z-index to place the link area over the image.
Something like:
div.imageArea {
position: relative;
width: 150px;
height: 150px;
z-index: 2;
}
div.imageArea a {
position: relative;
display: inline-block;
width: 100%;
height: 100%;
background: transparent no-repeat url('images/starImage.png') 0 0;
z-index: 3;
}

Related

Svg image in an img tag shows a border

I have the following code
.clsName {
width: 24px;
height: 24px;
// background-color: #0057bf;
background-image: url('svg/ico-plus-add.svg');
color: transparent;
}
Now I want to display this in a clickable link, I use the following for that
<a (click)="method()" href="#">
<img class="clsName" />
</a>
The problem is that I get a border around the image, how do I get rid of this, and as a side note what is the best way to show an .svg image that is clickable?
In your CSS class add border: 0;

Circular mask an image with the use of just the image itself and pure CSS

I was actually wondering if it was possible to mask an image to a circular shape with the use of a single pseudo element, which is the image itself? Let's say it's a rectangle image (not square) and you want to have it masked to a circular shape, without the image being squeezed?
So you'd have:
HTML
<img src="#" class="mask">
CSS
.mask {
A lot of CSS possibilities, up to you
}
I know, with a parent div and using overflow:hidden & border-radius:50% it's possible, but can you do it without the use of a second pseudo element?
Update!
I've noticed that many users seem to think I'm only looking for the CSS code border-radius:50% to create circular shapes, but that's not it. The image should become a circular, not elliptical shape. You can simply use a width and height equal to each other, but then the image becomes squeezed. The answer should contain a none-squeezed image result
The requirement of the solution
- The image should be be a perfect circle, not elliptical
- The image should not be squeezed, no matter the original aspect ratio. Even if you'd use a panorama picture, you'd only see the middle part as an circular shape and the rest hidden.
If you can only use the img tag to produce a mask over itself, then the only work around i can think of is : DEMO
.mask {
width: 0px;
height: 0px;
border-radius: 100%;
background:url(http://placehold.it/300x400) center;/* define position to choose clipped area */
padding:50px;/* this makes a 100px square, so a perfect circle can be made with border-radius */
}
If you can use a wrapper, it can keep the original space used by image and mask can be settled anywhere on top of it via coordonates. DEMO
Markup:
<div class="mask r150 top100 left150">
<img src="http://placehold.it/300x400" />
</div>
CSS:
.mask {
position:relative;
overflow:hidden;
display:inline-block;/* preserve display behavior of initila image to mask*/
box-shadow:0 0 0 1px;/* show where i stands */
}
.mask img {
display:block;/* a way to remove bottom gap*/
}
.mask:before {
content:'';
position:absolute;
border-radius:100%;
box-shadow:0 0 0 2000px white;
}
.r150:before {
height:150px;
width:150px;
}
.top100:before {
top:100px;
}
.left150:before {
left:150px;
}
The use of extra classes can help you to tune different size and mask position.
Here Fiddle: http://jsfiddle.net/8CuXQ/
Something like this:
.mask {
width: 300px;
height: 300px;
border-radius: 150px;
-webkit-border-radius: 150px;
-moz-border-radius: 150px;
}

How to vertically center multiple images of varying heights in a row using vertical-align: middle

There are many questions on this topic already posted so sorry for posting another. However, none of the others that refer to my situation -- vertically aligning a row of images of undefined height, rather than a single image -- have received a reply that accomplishes what I need to do. As far as I can tell, Kizu's first solution here: How to vertically align an image inside div should be the thing, but alas I can't get it to work.
So, I have a container div. I can specify a height for this div if necessary. I can also place this div in another div if necessary.
Inside the div, I want to place a row of images of varying heights. These images should be vertically centered in relation to each other (not just in relation to the container div).
I cannot use background images in this case (the images are being placed within a text widget for easy replacement purposes).
As far as I can tell, I also cannot use display: table on the container div and display: table cell on my images, because the table cell must have a defined height, and my images are of varying heights.
Here is my code -- I've got a couple of extra divs (#footer-single-widget and .footer-single) to achieve the overall centering and padding I want, so I'm including these as well in case one of them is affecting the subsequent divs:
<div id="footer-single-widget">
<div class="footer-single">
<div class="textwidget">
<div class="media">
<img src="#image-1" width="103" height="36" class="alignleft" />
<img src="#image-1" width="103" height="40" class="alignleft" />
<img src="#image-1" width="103" height="26" class="alignleft" />
<img src="#image-1" width="103" height="40" class="alignleft" />
</div><!-- end of .textwidget -->
</div><!-- end of .media -->
</div><!-- end of .footer-single -->
</div><!-- end of #footer-single-widget -->
And the CSS:
#footer-single-widget {
width: 100%;
}
.footer-single {
text-align: center;
max-width: 980px;
margin: 0 auto;
}
#footer-single-widget .textwidget {
display: block;
height: 40px;
width: 980px;
}
.media {
display: inline-block;
height: 100%;
vertical-align: middle;
}
.media img.alignleft {
display: inline-block;
vertical-align: middle;
max-height: 40px;
max-width: 200px;
}
The frustrating thing is at some point I achieved exactly this effect -- then decided I didn't need it (all my images at that point were the same height) and deleted the code I had written. Now I need it again and don't have the faintest memory of what I did! But I know it's possible... somehow. Thanks for your advice.

How to make a floated image act responsively?

Please see this fiddle
My main concern in this fiddle is the div#text and img.frame. I'm trying to create a responsive website, but this has been my problem for so long, I can't figure out how 'to make the img behave beside the text and be responsive at the same time when I try to reduce the size of the browser window. What it does is, it goes under the text before it acts responsively. Is there a workaround for this?
<div id="text">This is some text this is some text this is some text</div>
<img src="http://upload.wikimedia.org/wikipedia/en/thumb/5/5f/TomandJerryTitleCardc.jpg/250px-TomandJerryTitleCardc.jpg" width="294" height="225" class="frame" />
For your goal you should use em or % and use inline-block.
jsfiddle.net/geNuR/ Look at this jsfiddle
Don't know why i can't put code propely, maybe forum blocked our country))
​
The key to responsive images with flowed text does rely on float. However, the key is in floating the img element, not the text.
First, place the img tag before the text, giving a markup as so:
<img src="image.jpg" width="294" height="225" class="frame" />
<div id="text">This is some text this is some text this is some text</div>
The importance of this order is that the img will be floated to the right, removing its cleared blocked region height, and the text will flow up and around it.
Next, remove the float from the text, allowing it to flow, and apply a float right to the image. I will also note, that to give a margin between the text and the img, the margin is applied to the img, giving you this styling:
img { max-width: 100%; height: auto; }
#text{ width:100px;}
.frame {
float:right;
background: #fff;
padding: 6px;
margin-left:10px;
box-shadow: 1px 1px 2px rgba(40, 40, 40, 0.8);
-moz-box-shadow: 1px 1px 2px rgba(40, 40, 40, 0.8);
-webkit-box-shadow: 1px 1px 2px rgba(40, 40, 40, 0.8);
}
Here is a jfiddle demonstration
I'm assuming that you're looking to have text and an image side-by-side here, so apologies if I'm wrong.
Like M. Berro, I would first put the two elements inside a containing div, as below:
<div id="container">
<p class="text">Here's some text. This will be aligned to the left, and next to the image. It's width will change as the viewport expands or contracts.</p>
<img src="/image.png" title="An image, aligned right" />
</div>
To sit the image and text side-by side, I would use the following CSS as a starting point:
#container {}
#container p.text { float: left; min-width: 320px; }
#container img { float: right; margin-left: 20px; }
In my example, I've applied a float to each of the two elements (You will of course have to clear the floats to make sure the rest of the page's structure remains intact - I suggest looking at Clearfix, as it avoids any extra empty divs). I've also given the text a min-width: this ensures that the text doesn't contract to a point where it is unreadable!
As I understand you need an image beside a text, so when you reduce the window size the image and text behavior isn't affected.
You need the following:
Make a container div id=img_container give style width (let's say 400px)
Put your image inside the container and give a style #img_container img{float: left}
Put your text inside a p tag and give style #img_container (p or div) and give style (margin-left: same of your img width) + 10
This is the full example:
<style>
#img_container {
width: 400px;
}
#img_container.text {
margin-left: 306px;
}
#img_container img.frame {
float: left;
}
</style>
<div id="img_container">
<img src="http://upload.wikimedia.org/wikipedia/en/thumb/5/5f/TomandJerryTitleCardc.jpg/250px-TomandJerryTitleCardc.jpg" width="294" height="225" class="frame" />
<div id="text">This is some text this is some text this is some text</div>
</div>
You could start by adding the css max-width: 60%; in .frame. It's not perfect but is this similar to what you are trying to achieve? Better results can be realized with javascript/jQuery.

Centering an image for responsive website

So i am making a responsive design for a school assignment and i am trying to center an image width.
i scaled the image in photoshop so i don't have to set any width or height to the image
this is what i got now but this does not work
<header>
<img src="afb%20/logo3.png" alt="logo3" width="" height="" />
</header>
header{
width: 100%;
margin-left: auto;
margin-right: auto;
}
Can someone help me out ? really need this !
thanks in advance
Just set text-align: center in the header CSS.
You are currently making the header 100% width, so your margins wont apply. Furthurmore since your container is 100% wide and there is no text-alignment, the img will ALWAYS be aligned on the left.
Here:
header { width: 100%; text-align: center; }​
http://jsfiddle.net/xMPZ4/
.center{margin: 0px auto; display: block;}
<header><img src="updates_button.jpg" alt="logo3" class="center"></header>
You could add a logo class to the image and set the CSS to : margin:0px auto; width:200px; of course replace the image width...

Resources