Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-14-2013, 05:20 AM   PM User | #1
parkerdeano
New to the CF scene

 
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
parkerdeano is an unknown quantity at this point
How to add link to image without misaligning

Ok this may be a very simple question to many here, but for myself I am a novice and stuck on this.

These 2 images are left aligned. When I try to add links to them I lose the alignment. How do I add links to these 2 images without changing anything else?

<div class="left_carpet" style="width: 265px; float: left; margin: 0 0 0 0;"><span style="font-size: x-large;">Carpet Tiles</span> <img style="float: left;" title="View and buy online" src="{{media url="wysiwyg/Buy_carpet_tiles_online.jpg"}}" alt="View and buy online" /> <img title="Online quote" src="{{media url="wysiwyg/fill_in_form_carpet_tiles_page.jpg"}}" alt="Online quote" /></div>

Thanks in advance for any help.
parkerdeano is offline   Reply With Quote
Old 02-14-2013, 10:00 AM   PM User | #2
niralsoni
Regular Coder

 
Join Date: Mar 2008
Location: London
Posts: 129
Thanks: 1
Thanked 31 Times in 31 Posts
niralsoni is an unknown quantity at this point
I am not sure about why its happening... May be some other css written for ANCHOR tag which might be overriding it.

Anyway, if you haven't found a solution yet, I have an alternate option -

make use of the JavaScript onclick event for the images. also add "cursor: pointer" style to the images to moke them as links. It will work !!!


Regards,
Niral Soni
niralsoni is offline   Reply With Quote
Old 02-15-2013, 06:40 AM   PM User | #3
rezfill
New to the CF scene

 
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
rezfill is an unknown quantity at this point
ahmpt, there might be a problem ofcourse, and i guess it some of your codes went wrong, i suggested to use a javascript to avoid mistake and its more easy to use for this case.
rezfill is offline   Reply With Quote
Old 02-15-2013, 09:00 AM   PM User | #4
parkerdeano
New to the CF scene

 
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
parkerdeano is an unknown quantity at this point
Mmm think I may need a web designer. This is a bit too complex for myself. Many thanks for your efforts anyway.
parkerdeano is offline   Reply With Quote
Old 02-15-2013, 06:13 PM   PM User | #5
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello parkerdeano,
Some odd things in your markup...plus, it's always better to style with CSS rather than inline.

Look at the two examples here. I've cleaned up the markup for your images in the first, then added anchors in the second (I've assumed a 200x150 px size for your images since you didn't provide a size).
I tried to comment on everything to explain what it's doing.
Code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
html, body {
	margin: 0;
	font: 100% "Trebuchet MS", Arial, Helvetica, sans-serif;
	color: #000;
	background: #fc6;
}
.left_carpet {
	width: 265px;
	margin: 0 0 20px; /*just some separation for the demo*/
	/*float: left; commented out for demo*/
	overflow: auto; /*clears the floats*/
	background: #ccc; /*jus so you can see the size of .left_carpet*/
}
h1 {font-size: 1.2em;} /*adjust as needed*/
a {display: block;} /*makes the anchor the size of the image it contains*/
img {
	float: left;
	display: block; /*demo only*/
	background: #f00; /*demo only*/
}
</style>
</head>
<body>
	<div class="left_carpet">
            <h1>Carpet Tiles</h1> 
      <img src="wysiwyg/Buy_carpet_tiles_online.jpg" alt="View and buy online" width="200" height="150" title="View and buy online" /> 
      <img src="wysiwyg/fill_in_form_carpet_tiles_page.jpg" alt="Online quote" width="200" height="150" title="Online quote" />
    <!--end .left_carpet--></div>
	<div class="left_carpet">
            <h1>Carpet Tiles</h1> 
      <a href="#"><img src="wysiwyg/Buy_carpet_tiles_online.jpg" alt="View and buy online" width="200" height="150" title="View and buy online" /></a>
      <a href="#"><img src="wysiwyg/fill_in_form_carpet_tiles_page.jpg" alt="Online quote" width="200" height="150" title="Online quote" /></a>
    <!--end .left_carpet--></div>
</body>
</html>
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:41 AM.


Advertisement
Log in to turn off these ads.