Link on half of an image in CSS - 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">

Related

Social Media Icons in Footer

I use wordpress and want to add social media icons to my footer. What I did so far is to add the following code to the footer.php:
<div id="social-buttons">
<a href="http://twitter.com/veda_vit" rel="me"><img title="veda-vit.de bei Twitter" src="http://veda-vit.de/wp-content/uploads/2017/11/Twitter.svg" alt="Twitter Button" width="24" height="24" />
</a>
<a href="https://www.facebook.com/vedavit.de" rel="me"><img title="veda-vit.de bei Facebook" src="http://veda-vit.de/wp-content/uploads/2017/11/Facebook.svg" alt="Facebook Button" width="24" height="24" />
</a>
</div>
And additionally I added the following css code to place the icons on the right:
#social-buttons a img {
margin: 10px 12px 0 0;
float: right;
}
It works so far, but the icons are placed on a second line (see here: www.veda-vit.de).
What can I do to place the copyright and the icons on one line? I tried already everything, but couldn't solve the problem. Can anybody help me, please?
Thank you!
You can add this CSS code and it will work nicely
#social-buttons {
float: right;
position: relative;
top: -9px;
}
You can edit it more by changing top position.

3 Scaling images inline

So, I created an image in photoshop that is 1920x1080 and I've spliced it into sections, so that the images that require a link can have an javascript tag attached to them for a link.
I want the images to scale depending on the type of monitor you're using, as long as you're in a 16:9 ratio. The problem I'm having, is in regards to the way the images align 3 in a row. Either the 3rd image in the row gets pushed down, for sections with 3 images. Or, the image is the full size 1920x1080, but no scaling and gaps between images.
My HTML looks like this:
<main>
<section>
<img src="images/NuclearFuelCycle1.png"/>
</section>
<section>
<div><img id="1" src="images/NuclearFuelCycle2.png"/><span style="cursor:pointer" onclick="openMining()"><img id="2" src="images/NuclearFuelCycle3.png"/></span><img id="3" src="images/NuclearFuelCycle4.png"/></div>
</section>
<section>
<img src="images/NuclearFuelCycle5.png"/></section>
<section>
<img src="images/NuclearFuelCycle6.png"/><span style="cursor:pointer" onclick="openConversion()"><img src="images/NuclearFuelCycle7.png"/></span><img src="images/NuclearFuelCycle8.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle9.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle10.png"/><span style="cursor:pointer" onclick="openEnrichment()"><img src="images/NuclearFuelCycle11.png"/></span><img src="images/NuclearFuelCycle12.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle13.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle14.png"/><span style="cursor:pointer" onclick="openReactor()"><img src="images/NuclearFuelCycle15.png"/></span><img src="images/NuclearFuelCycle16.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle17.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle18.png"/><span style="cursor:pointer" onclick="openSpentFuel()"><img src="images/NuclearFuelCycle19.png"/></span><img src="images/NuclearFuelCycle20.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle21.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle22.png"/><span style="cursor:pointer" onclick="openFuelFabrication()"><img src="images/NuclearFuelCycle23.png"/></span><img src="images/NuclearFuelCycle24.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle25.png"/></section>
<section>
<img src="images/NuclearFuelCycle26.png"/><span style="cursor:pointer" onclick="openStorageDisposal()"><img src="images/NuclearFuelCycle27.png"/></span><img src="images/NuclearFuelCycle28.png"/>
</section>
<section>
<img src="images/NuclearFuelCycle29.png"/>
</section>
</main>
My CSS looks like this:
* {
margin: 0;
padding: 0;
border: 0;
border-collapse: collapse;
}
body {
max-width: 100% !important;
height: auto;
}
main {
display: inline-block;
padding: 10px;
}
section div img{
width: auto;
}
Some of this code is not useful... It's me experimenting to try and create a solution. Any help would be greatly appreciated, I have to submit this in 2 days P
The 'spaces' problem is most likely due to the way display:inline works, which is what an image and a span is. Any newlines, etc get treated as a space char. An easy fix could be something that uses display:flex.
The second (and main part) of your problem is that you want to scale based on width. A little bit of javascript and use of transform: scale(...) fixes that. Below is a snippet (which can't show resizing), so here's a CodePen too: https://codepen.io/anon/pen/PpXpwO
window.onresize = resizer;
resizer();
function resizer() {
console.log("resized")
var _main = document.querySelector("main");
var image_width = 600; // the original image width
var ratio = _main.offsetWidth/image_width;
_main.style.transform = "scale("+ratio+")";
};
main {
transform-origin: 0 0;
}
section {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}
section * {
flex: 0 0 auto;
display: block;
}
<main>
<section>
<img src="https://placehold.it/600x150g" />
</section>
<section>
<img id="1" src="https://placehold.it/100x150" />
<a style="cursor:pointer" onclick="openMining()"><img id="2" src="https://placehold.it/300x150/370000" /></a>
<img id="3" src="https://placehold.it/200x150" />
</section>
<section>
<img src="https://placehold.it/600x150g" />
</section>
</main>
If I'm understanding correctly your sliced image segments are repositioning incorrectly as the browser window resizes.
Rather than slicing up your image and using javascript, why not try a pure HTML solution and use the <map> tag to insert your links at various parts of the image?
Here's a Fiddle demonstrating a scalable HTML image map (uses the image-map-resizer plugin)
You can learn more about image maps here.

Can I use #media queries and css classes in a Popup Window?

I am setting up a Pop-up Window in a Wordpress 4.1 website located here:
http://ajourneyofepiphanies.com/dev/
You can see two options in the footer. The Get the Book link works correctly but the CSS is hardcoded inline and I can't change it for smaller screens by using a #media query.
Here the code I am using:
<div style="width: 48%; margin-right: 3.5%; float: left;">
<h3><span style="color: #fb6d03;"><strong>A practical guide to leadership virtually anyone can use.</strong></span></h3>
<span style="color: #000000;">A Journey of Epiphanies: Learning Leadership lays out the path –showing how our progress toward leadership affects us, the people around us, and our future. Then it applies these insights to help identify people that could become great leaders and helps them on their journey.</span>
<img class="alignnone wp-image-68 size-medium" src="http://ajourneyofepiphanies.com/dev/wp-content/uploads/2015/03/a-journey-of-epiphanies-cover-207x300.png" alt="a-journey-of-epiphanies-cover" width="207" height="300" />
</div>
<div style="width: 48%; margin-right: 0; float: left;">
<img class="alignnone size-full wp-image-70" src="http://ajourneyofepiphanies.com/dev/wp-content/uploads/2015/03/amazon.png" alt="amazon" width="227" height="46" /><a class="buy-book-btn" title="Buy it on Amazon.com">Buy the book! ►</a>
<img class="alignnone size-full wp-image-72" src="http://ajourneyofepiphanies.com/dev/wp-content/uploads/2015/03/button-itunes.png" alt="button-itunes" width="227" height="84" /><a class="buy-book-btn" title="Buy it on iTunens">Buy the book! ►</a>
<img class="alignnone size-full wp-image-71" src="http://ajourneyofepiphanies.com/dev/wp-content/uploads/2015/03/bnlogo.png" alt="bnlogo" width="227" height="63" /><a class="buy-book-btn" title="Buy it on Barnes & Noble.com">Buy the book! ►</a>
<img class="alignnone size-full wp-image-69" src="http://ajourneyofepiphanies.com/dev/wp-content/uploads/2015/03/lulu.png" alt="lulu" width="227" height="80" /><a class="buy-book-btn" title="Buy it on Lulu.com">Buy the book! ►</a>
</div>
Basically I want to dynamically split the popup window in half by using CSS to apply a #media query to it but the CSS rules I set up don't seem to affect it.
You can see a live example in the "Download the First Chapter" link in the footer of the site.
Here is my HTML code using CSS classes:
<div class="one-half">
<h3><span style="color: #fb6d03;"><strong>A practical guide to leadership virtually anyone can use.</strong></span></h3>
<span style="color: #000000;">A Journey of Epiphanies: Learning Leadership lays out the path –showing how our progress toward leadership affects us, the people around us, and our future. Then it applies these insights to help identify people that could become great leaders and helps them on their journey.</span>
<img class="alignnone wp-image-68 size-medium" src="http://ajourneyofepiphanies.com/dev/wp-content/uploads/2015/03/a-journey-of-epiphanies-cover-207x300.png" alt="a-journey-of-epiphanies-cover" width="207" height="300" />
</div>
<div class="one-half last">
Form and Download link will go here but this needs to be the right hand column.
</div>
Here is the CSS code:
.one-half {width 48.5%; margin-right:3.5%; float:left;}
.last {margin:0 !important;}
#media all and (max-width: 400px) {
.one-half {width:100%;}
}
I have tried using plugins for responsive columns and more but nothing seems to affect the popup window.
Any suggestions? Does CSS not work in the popup window? I am using the Popup Maker plugin.
You could add an ID to the body element, then target that ID specifically ahead of the popu pop up in your CSS to apply to the contents of the popup. Then you would end up with something like this:
HTML
<body class="bunch of classes" id="body-wrap">
Other markup...
<div class="popmake" id="popmake"></div>
</body>
CSS
#body-wrap .popmake .one-half {
width 48.5%;
margin-right:3.5%;
float:left;
}
#body-wrap .popmake .last {
margin:0 !important;
}
#media all and (max-width: 400px) {
#body-wrap .popmake .one-half {
width:100%;
}
}
This was just a simple missing colon. I had
#body-wrap .popmake .one-half {
width 48.5%; }
and needed
#body-wrap .popmake .one-half {
width: 48.5%; }

Twitter Bootstrap is screwing up my imagemap - Anyone else have this issue?

First off - this is my first question ever (I'm still a beginner) and I can't say how much I appreciate this site and all the help I've found on here. Hopefully every question I ask can help someone else too :)
I realize not many people use imagemaps any more but I have one and twitter bootstrap (version 3.0.0) is screwing up my coordinates - putting the links in the wrong places. I can make it work with the following code but then it wont resize to fit the screen. Any tips?
<style>
<!Driving me nuts - without this the imagemap links are in the wrong places - with this it wont resize>
#img_ID {
max-width:none;
width:auto;
display: inline;
}
</style>
Here is a snippet of the actual imagemap code
<div style="width:100%">
<img id="img_ID" src="NewMatGuide.png" USEMAP="#map" border="0" class="" width:100% alt="">
</div>
<Map id="map_ID" name="map">
<AREA shape="RECT" COORDS="80,151,258,252" HREF="PlacementResults.php?ChosenArea=A">
<AREA shape="RECT" COORDS="80,328,258,432" HREF="PlacementResults.php?ChosenArea=B">
<AREA shape="RECT" COORDS="80,521,258,620" HREF="PlacementResults.php?ChosenArea=C">
I'd recommend, rather than an image map, make 3 divs that are links with the following HTML and accompanying CSS.
<div id="box_a">
<a class="box_link" href="PlacementResults.php?ChosenArea=A"></a>
</div>
<div id="box_b">
<a class="box_link" href="PlacementResults.php?ChosenArea=B"></a>
</div>
<div id="box_c">
<a class="box_link" href="PlacementResults.php?ChosenArea=C"></a>
</div>
Use percentages to define the coordinates. Given that your X1 and X2 coordinates are the same for the links in your image map, the following example (with different %s to actually cover your image correctly) should work.
#box_a, #box_b, #box_c {
margin-left: 10%;
margin-top: 5%;
height: 15%;
width: 25%;
}
.box_link {
display: block;
height: 100%;
width: 100%;
}
You should check out this page to learn more about making div links. I would also suggest using NewMatGuide.png as a background-image and define the size of #img_ID.

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 :)

Resources