how to make an image into a link - html

I have a simple question which I can't seem to solve.
#tps_block {
height: 45px;
width: 940px;
}
#tps_point1 {
width: 351px;
background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") 0 0 no-repeat;
text-indent: -9999px;
display: block;
height: 100%;
float: left;
}
#tps_point1:hover {
background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") 0 -45px no-repeat;
}
#tps_point2 {
width: 284px;
background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") -351px 0 no-repeat;
text-indent: -9999px;
display: block;
height: 100%;
float: left;
}
#tps_point2:hover {
background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") -351px -45px no-repeat;
}
#tps_point3 {
width: 305px;
background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") -677px 0 no-repeat;
text-indent: -9999px;
display: block;
height: 100%;
float: left;
}
#tps_point3:hover {
background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") -677px -45px no-repeat;
}
<div id="tps_block">
<div id="tps_point1">Point 1
</div>
<div id="tps_point2">Point 2
</div>
<div id="tps_point3">Point 3
</div>
</div>
The idea is that there are 3 images side by side, and when the mouse hover's over each image, the image changes to a highlighted one, and the image is clickable too, so that the user is taken to some other place when the image is clicked.
I have managed to apply the hover effect, but I can't get the linking to work.
Can someone help me out ?
JSFiddle: http://jsfiddle.net/ahmadka/Fjmnt/

If you're able to change the HTML, just lose the inner div tags and apply exactly the same styles to the links themselves:
<div id="tps_block">
Point 1
Point 2
Point 3
</div>
Updated jsFiddle: http://jsfiddle.net/Fjmnt/7/

Best solution if you are unable to modify the HTML.. add the following CSS.
#tps_block a {
display: block;
width: 100%;
height: 100%;
}
This will fill <a> making the entire div clickable.
jsFiddle demo

<div id="tps_block">
<div id="tps_point1"></div>
<div id="tps_point2"></div>
<div id="tps_point3"></div>
</div>

Related

Sharp corner curved background image

been thinking of what would be the best way to achieve a background image with a sharp corners. I tried some css like border-radius and clip-path but no luck. I guess clip-path is the nearest possible answer but can't get it. Please see my sample below.
.main-header {
background: url('http://placehold.it/150x150') no-repeat center center;
background-position: 0% 33%;
background-size: cover;
min-height: 480px;
border-radius: 0 0 45% 45%;
}
<div class="main-header">
<br>
</div>
I'm looking to have below image.
How about this approach?
JSBin
body {
background: white;
margin: 0;
}
.main-header {
background: url('http://www.stevensegallery.com/g/400/200') no-repeat center center;
background-position: center;
background-size: cover;
min-height: 480px;
position: relative;
}
.main-header::after {
content: '';
display: block;
position: absolute;
background: transparent;
/* You can play around with these numbers to adjust the curve */
bottom: -4rem;
left: -25%;
width: 150%;
height: 400px;
border-bottom: solid 4rem white;
border-radius: 0 0 50% 50%;
}
<div class="main-header">
<br>
</div>
You can use below code for it
Add border-bottom-left-radius:60% 30%; border-bottom-right-radius:60% 30%; css. You can play with radius properties to know how it works..
.main-header {
background: url('http://placehold.it/150x150') no-repeat center center;
background-position: 0% 33%;
background-size: cover;
min-height: 480px;
border-bottom-left-radius:60% 30%;
border-bottom-right-radius:60% 30%;
}
<div class="main-header">
<br>
</div>
if you can use image by img, not background. I think you can try "clip-path" as below.
Codepen example
HTML:
<div class="main-header">
<img src="http://placehold.it/150x150">
</div>
CSS:
img {
-webkit-clip-path: circle(100% at 50% 0);
clip-path: circle(100% at 50% 0);
}
and this site is useful to make clip-path (http://bennettfeely.com/clippy/)

Two Images Side by Side With Hover Effect in CSS

I have two images that I want to place side by side with hover effects. I've managed to get them side by side...but I'd like the images centered under the logo image.
CSS:
a.btn1 {
display: inline-block;
float: left;
width: 332px;
height: 85px;
cursor: pointer;
background-image: url(images/bttn_model.png);
text-indent: -9999em;
margin:
}
a.btn1:hover {
background-image: url(images/bttn_model_over.png);
}
a.btn2{
display: inline-block;
width: 332px;
height: 85px;
cursor: pointer;
background-image: url(images/bttn_photographers.png);
text-indent: -9999em;
}
a.btn2:hover {
background-image: url(images/bttn_photographers_over.png);
}
}
HTML:
<body>
<div align="center">
<p> </p>
<p><img src="images/logo.gif" width="618" height="85" /></p>
</div>
<p> </p>
<div align="center">Models
<div align="center">Photographers
</div>
</div>
<p> </p>
</body>
</html>
You should wrap the 2 images in one div, so you can center that div with the following class
.centerDiv
{
width: 50%;
margin: 0 auto;
}
One possible way to do what you want is following.
HTML
<div class="logo">
<img src="images/logo.gif" width="618" height="85" />
</div>
<div class="pictures">
Models
Photographers
</div>
CSS
.logo {
text-align: center;
}
.pictures {
text-align: center;
}
.pictures a {
cursor: pointer;
display: inline-block;
width: 332px;
height: 85px;
text-indent: -9999em;
}
.btn1 {
background-image: url('images/bttn_model.png');
}
.btn1:hover {
background-image: url('images/bttn_model_over.png');
}
.btn2{
background-image: url('images/bttn_photographers.png');
/* next margin-left is to fix the space between */
/* images that because of the inline-block */
/* margin-left: -4px; */
}
.btn2:hover {
background-image: url('images/bttn_photographers_over.png');
}
Using attributes like align is not nice practise nowdays. For this things there is solution in CSS.
Using display: inline-block and float: left is not needed in this case, while it is in one line already with display.
If you wanted to use <p> </p> instead of margin & padding, that put them back, but better practise is to stick with margin & padding

How to set a background inside a div

Final resulting background image that I need:
Background image that I have used:
But I have got this Fiddle
::Summary of Fiddle::
HTML...
<div id="top-part">
<div id="topmost">
<div id="top-most" class="wrapper">
</div>
</div>
<div id="topmenu" class="wrapper">
</div>
CSS...
.wrapper{
position: relative;
width: 943px;
margin: 0 auto;
}
#top-part{
background: url(img/bg-header-effects.png) no-repeat top center;
}
#topmost{
background: #900;
opacity: 0.8;
}
#top-most{
height: 139px;
}
#topmenu{
background: #900;
opacity: 0.8;
height: 51px;
border-radius: 0 0 20px 20px;
}
Update - to cover your recent edit
#header{
background: #f00 url('http://i.stack.imgur.com/GWVfL.jpg');
opacity: .6;
width: 100%;
height: 189px;
}
Working Fiddle
You could try using the background property in CSS:
div{
background: url('path_to_your_image.jpg') no-repeat;
}
Learn more about using the background-image property here
Note:
There is a difference between background and background-image. In this answer I've used the background property which basically takes all of the possible options for a background image in CSS and lets them be used in a single call.
For example, you could split the above up into two selectors:
div{
background-image: url('path_to_your_image.jpg') no-repeat;
background-repeat: no-repeat;
}
You could do like this fiddle
html...
<div id="top-part">
<div id="topmost">
</div>
</div>
<div id="top-menu" class="wrapper">
<div id="topmenu">
</div>
</div>
css...
.wrapper{
position: relative;
width: 943px;
margin: 0 auto;
}
#top-part{
background: url(img/bg-header-effects.png) no-repeat top center;
}
#topmost{
background: #900;
opacity: 0.8;
height: 139px;
}
#top-menu{
background: url(img/bg-header-effects.png) no-repeat 50% 45%;
border-radius: 0 0 20px 20px;
}
#topmenu{
background: #900;
opacity: 0.8;
height: 51px;
border-radius: 0 0 20px 20px;
}
The easy approach that I'm thinking of is having a picture within divs covering the whole page. The code will be very simple, but the only downside is the image may be warped or it can be clicked on unless you have this.
HTML:
<div id="backgroundcolor">
<div id="backgroundimage">
</div>
</div>
CSS:
#backgroundcolor {
background-color: #000;
z-index: 1;
}
#backgroundimage {
background: ("http://cdn.theatlantic.com/static/infocus/election110712/s_e01_37923312.jpg");
resize: none;
object-position: center;
object-fit: initial;
}

Why my menu is not aligning?

I'm trying to create in HTML/CSS the following menu inside of a sidebar:
myimage http://img1.firenex.net/9Z0eupHnvV7LIPQd950r.png
Every button has its own corresponding pressed/non-pressed image, and when hovered its opacity moves from 0.8 to 1.0 via CSS.
The problem is that I get is this:
myimage2 http://img1.firenex.net/nooUcfe0HvvfMaCmz6N8.png
Not quite the result I expected :)
This is my HTML:
<div id="homepageBtn"></div>
<div id="progressiBtn"></div>
<div id="interessiBtn"></div>
<div id="friendzoneBtn"></div>
<div id="emailBtn"></div>
This is my CSS:
#homepageBtn {
background:url(img/buttons/homepage_btn.png) no-repeat;
opacity: 0.8;
width: 88px;
height: 79px;
margin-left: 30px;
float: left;
}
#homepageBtn:hover {
background:url(img/buttons/homepage_btn.png) no-repeat;
opacity: 1.0;
}
#homepageBtn:active {
background:url(img/buttons/homepage_btn_pressed.png) bottom right no-repeat;
}
#progressiBtn {
background:url(img/buttons/progressi_btn.png) no-repeat;
opacity: 0.8;
width: 88px;
height: 79px;
margin-left: 10px;
float: left;
}
#progressiBtn:hover {
background:url(img/buttons/progressi_btn.png) no-repeat;
opacity: 1.0;
}
#progressiBtn:active {
background:url(img/buttons/progressi_btn_pressed.png) bottom right no-repeat;
}
#interessiBtn {
background:url(img/buttons/interessi_btn.png) no-repeat;
opacity: 0.8;
width: 88px;
height: 79px;
margin-left: 30px;
margin-top: 10px;
clear: left;
float: left;
}
#interessiBtn:hover {
background:url(img/buttons/interessi_btn.png) no-repeat;
opacity: 1.0;
}
#interessiBtn:active {
background:url(img/buttons/interessi_btn_pressed.png) bottom right no-repeat;
}
#friendzoneBtn {
background:url(img/buttons/friendzone_btn.png) no-repeat;
opacity: 0.8;
width: 88px;
height: 79px;
margin-left: 10px;
margin-top: 10px;
float: left;
}
#friendzoneBtn:hover {
background:url(img/buttons/friendzone_btn.png) no-repeat;
opacity: 1.0;
}
#friendzoneBtn:active {
background:url(img/buttons/friendzone_btn_pressed.png) bottom right no-repeat;
}
#emailBtn {
background:url(img/buttons/email_btn.png) no-repeat;
opacity: 0.8;
width: 188px;
height: 29px;
margin-left: 30px;
margin-top: 10px;
clear: left;
}
#emailBtn:hover {
background:url(img/buttons/email_btn.png) no-repeat;
opacity: 1.0;
}
#emailBtn:active {
background:url(img/buttons/email_btn_pressed.png) bottom right no-repeat;
}
I really don't know if I am using the correct method to do this, I would appreciate any solutions at this point... thanks in advance.
PS: this happens with Chrome, with IE for example I get it showed correctly
You are using clear property incorrectly. you can use this code.
<div id="homepageBtn"></div>
<div id="progressiBtn"></div>
<div style="clear:both;border:0px"></div>
<div id="interessiBtn"></div>
<div id="friendzoneBtn"></div>
<div style="clear:both;border:0px"></div>
<div id="emailBtn"></div>​
And Remove Clear:left from following CSS
#interessiBtn {
background:url(img/buttons/interessi_btn.png) no-repeat;
opacity: 0.8;
width: 88px;
height: 79px;
margin-left: 30px;
margin-top: 10px;
clear: left; <-- Remove this
float: left;
}
Demo Code
margin-top:.. or padding top but even a better solution is that do the following amendment ,
Add a new and do it like this
<div id="upper">//further divide it in two parts
<div id="homepageBtn"></div>//here goes homepage button
<div id="progressiBtn"></div>
</div > //end of upper
and do same thing for bottom Div
<div id="bottom">//further divide it in two parts
<div id="friendzoneBtn"></div>
<div id="emailBtn"></div>
</div > // end of bottom
and not whatever the dimensions you set for upper div or then bottom div your content will be easily adjustable there

Arranging buttons side by side

please help me arrange these 3 buttons horizontally like this photoshopped image:
Please take a look at the code here.
CSS:
a.facebookbt {
background: url(http://i1068.photobucket.com/albums/u445/neobx/bonus5.png) no-repeat 0 0;
width: 132px;
height: 52px;
display: block;
}
a.facebookbt:hover { background-position: 0 -52px; }
a.facebookbt:active { background-position: 0 -104px; }
a.twitterbt {
background: url(http://i1068.photobucket.com/albums/u445/neobx/bonus5.png) no-repeat -132px 0;
width: 132px;
height: 52px;
display: block;
}
a.twitterbt:hover { background-position: -132px -52px; }
a.twitterbt:active { background-position: -132px -104px; }
a.abpbt {
background: url(http://i1068.photobucket.com/albums/u445/neobx/bonus5.png) no-repeat -265px 0;
width: 286px;
height: 50px;
display: block;
}
a.abpbt:hover { background-position: -265px -52px; }
a.abpbt:active { background-position: -265px -104px; }​
HTML:
<a class="facebookbt" href="javascript:;"></a>
<a class="twitterbt" href="javascript:;"></a>
<a class="abpbt" href="javascript:;"></a>​
a { float:right; margin-left: 5px;}
and change the html markup to this way:
<a class="abpbt" href="javascript:;"></a>
<a class="twitterbt" href="javascript:;"></a>
<a class="facebookbt" href="javascript:;"></a>
This way the layout will be aligned to the right, and in the correct order like in your screenshot.
Demo: http://jsfiddle.net/FzYkJ/12/
How about:
a {
float:left;
}
​
or
a {
display:inline-block !important;
}
You can add
float:left;
to each button
http://jsfiddle.net/FzYkJ/2/