Centering Images using CSS but having links on the Images

Hi all,
I have a problem on centering an image using CSS. I read on many forums that you have to use margin-left , margin-right and set to auto. and also set the display:block which I had done.
The problem is if I want to have a link from the image. Because I have set the display to block, the link will span the entire container containing it! How do I resolve that? I only want the image to be linkable and not the entire container!
Thanks for reading!

Murray *ACP* wrote:
Because I have set the display to block, the link will span the entire container containing it!
That's incorrect.  If the display:block is applied to only the IMAGE, the anchor tag will be exactly the same dimensions as the image and will not fill the container.
Hi Murray,
Weirdly it does in my experiments. (code below). Even if I set the 'a' tag to the width of the image it still makes the whole <div> container clickable:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
#imgWrapper {
    width: 900px;
    margin: 0 auto;
    border: 1px solid #000;
#imgWrapper img {
    margin: 0 auto;
    display: block;
</style>
</head>
<body>
<div id="imgWrapper">
<a href="http://www.bbc.co.uk"><img src="slice_2.jpg" width="595" height="130" /></a></div>
</body>
</html>

Similar Messages

  • Using css but having these browser issues

    Hello
    Wondered if you might have any fix for the following...I've
    tried several forums and a couple of css people but no one seems to
    have an answer other than bugs in the browser. But surely there is
    a way...
    If you go to
    http://www.enhancedwireless.net/Company/TEST.shtml
    and rollover the first "(ODMA)" you should get a gif css pop up
    which works great in FF, IE6/7 and Netscape (PC and MAC). But in
    Safari (any version) and latest Opera (PC and MAC) the pop up is
    fragmented and won't go away, breaks up. Would love a suggestion on
    a fix...
    And I have a swf file css pop up which again works great in
    FF and Netscape, even Safari, but not in IE 6 where the pop up
    won't go away (and even multiplies when you scroll) and IE 7 where
    a strange white "flash" appears over the entire page each time you
    mouseover the "(71 countries)".
    Just rollover "(71 countries)" -
    http://www.enhancedwireless.net/Technology/patentPortfolio.shtml
    So my two questions are:
    1.) how to fix the image css pop up for Safari and Opera
    2.) how to fix the swf css pop up for IE 6/7
    I know I could adapt a javascript code out there but was
    hoping to do this with simplicity using css - any way?
    Thanks very much for your time
    KB

    I think you have just chosen a hinky way to implement that
    CSS 'rollover'.
    And you have so much unecessary/redundant CSS in your rules,
    it's a little
    difficult to sort out what's happening.
    Take a look at this page -
    http://66.165.80.209/page2test.php
    where I have
    done something similar, and see if you can understand what's
    going on.
    The menu links contain an absolutely positioned <span>
    containing a
    transparent GIF image. The background image of that span is
    the door. The
    CSS rollover produces the swap. Positoining your rollover
    image on the page
    you linked should work when applied in the same way, don't
    you think?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "iwics2" <[email protected]> wrote in
    message
    news:[email protected]...
    > Hello
    >
    > Wondered if you might have any fix for the
    following...I've tried several
    > forums and a couple of css people but no one seems to
    have an answer other
    > than
    > bugs in the browser. But surely there is a way...
    >
    > If you go to
    http://www.enhancedwireless.net/Company/TEST.shtml
    and
    > rollover
    > the first "(ODMA)" you should get a gif css pop up which
    works great in
    > FF,
    > IE6/7 and Netscape (PC and MAC). But in Safari (any
    version) and latest
    > Opera
    > (PC and MAC) the pop up is fragmented and won't go away,
    breaks up. Would
    > love
    > a suggestion on a fix...
    >
    > And I have a swf file css pop up which again works great
    in FF and
    > Netscape,
    > even Safari, but not in IE 6 where the pop up won't go
    away (and even
    > multiplies when you scroll) and IE 7 where a strange
    white "flash" appears
    > over
    > the entire page each time you mouseover the "(71
    countries)".
    >
    > Just rollover "(71 countries)" -
    >
    >
    http://www.enhancedwireless.net/Technology/patentPortfolio.shtml
    >
    > So my two questions are:
    >
    > 1.) how to fix the image css pop up for Safari and Opera
    > 2.) how to fix the swf css pop up for IE 6/7
    >
    > I know I could adapt a javascript code out there but was
    hoping to do this
    > with simplicity using css - any way?
    >
    > Thanks very much for your time
    >
    > KB
    >

  • Having mail 4.5 issues- open mail and get a new features message so I must import messages first in order to use mail 4.5.  Just recently put in MAC OSX 10.6.7.  Once it imports click done to start using mail, but end up with the rainbow wheel? Now What?

    Having mail 4.5 issues- open mail and get a new features message that says in order to use the new features, I must import existing messages into the new version first in order to use mail 4.5.  Just recently put in MAC OSX 10.6.7.  Once it imports I am to click done to start using mail, but end up with the rainbow wheel of death and it also says you cannot use mail until the import is finished? Now What?

    Is Mail still "spinning"?  If it's been doing that for a while, I'd kill it, using either Activity Monitor or the OS X application picker.  Then relaunch Mail and see what happens.
    Two "by the ways":
    1) Your system details mention an PPC iMac.  Since a non-Intel Mac can't run OS X 10.6, you seem to have another Mac.  You might want to consider updating your system details.
    2) You seem to have been misled by the poor labeling of the message composition fields on this forum into trying to enter your entire post into the "subject" field.  In the future, just enter a summary of your post there and the main text into the field below it.

  • Hello Apple community... I am trying to combine multiple pdf's into one, using preview, but when I drag the additional pages they show up as separate documents.

    I am trying to combine multiple pdf's into one, using preview, but when I drag the additional pages they show up as separate documents.  When I drag the doc in a line would show up in the past, and if I went above th eline all was good.  It doesn't have a line, and no matter what I try I am having no success.
    Please help!

    According to an Apple Support article, unless there are unforeseen issues
    in file ownership or permissions, the combining of .PDFs should be simple.
    •OS X: Combining PDF documents using Preview - Apple Support
    There are a few variable and similar methods, some change with version
    of OS X in use; some vintage OS X may vary a little in the process...
    A variety of similar topics appear in search results, with terms:
    " mac os x combine pdf into one " such as this page shows...
    https://www.google.com/?gws_rd=ssl#q=mac%20os%20x%20combine%20pdf%20into%20one
    If the system is older than Mavericks there may be other methods to try.
    Suggestions are among linked results in the search. I see a few fair ones.
    •Here's another that offers generally similar suggestions...*  this info looks OK, extra links, do not:
    http://osxdaily.com/2014/06/27/how-to-join-multiple-pdf-files-into-a-single-pdf- document-in-mac-os-x/
    { note: avoid clicking on links to products in * this ^ page, since they likely will not help & may be adware prone }
    If you have a problem after trying other methods, based on an OS X
    your computer is running, post back with more exact information...
    Good luck & happy computing!
    edited

  • HT204053 i have an itunes library with 1,000+ songs on a pc.  my daughter has a macbook air and i loaded my apple ID onto it.  how do i get the songs from my itunes account to show up?  This works fine on her iPhone, but having trouble on the new macbook

    i have an itunes library with 1,000+ songs on a pc.  my daughter has a macbook air and i loaded my apple ID onto it.  how do i get the songs from my itunes account to show up?  This works fine on her iPhone, but having trouble on the new macbook air

    Hey kbert73
    I would do a transfer of purchases from the phone and not sync. If you sync then it will want to start over and sync music that is on the MacBook Pro. If you want to transfer the music, check out the article below that will give you multiple options on how to move. I have also provided on how to sync with multiple computers.
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/ht4527
    Using iPhone, iPad, or iPod with multiple computers
    http://support.apple.com/kb/ht1202
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • I was trying to make a new screen recording using quicktimeplay, but when I watched the video after recording it all I could hear was me talking while the video was showing on the screen. How do I turn off that recording and turn the right one on? thanks

    I was trying to make a new screen recording using quicktimeplay, but when I watched the video after recording it all I could hear was me talking while the video was showing on the screen. How do I turn off that recording and turn the right one on? thanks

    Hi j2399123,
    It sounds like your screen recording is doing what it was designed to do, capture what is happening on your screen, with optional voice over with the microphone.
    Screen recording is for recording what you see on the screen, it is not a "video capture" option, like for capturing a movie with sound that is playing on your screen.
    For the QuickTime recording options, check out "Recording with QuickTime Player" in
    Mac Basics: QuickTime Player creates, plays, edits, and shares video and audio files
    http://support.apple.com/kb/ht4024
    And for screen recording specifically, there's
    QuickTime Player 10.x: Record your computer’s screen
    http://support.apple.com/kb/PH5882
    Thank you for thinking of Apple Support Communities for your support needs.
    Nubz

  • I restored my ipad but i was unable to activate it because it is askimg me for the apple id and password eith which i originally set it up. I know the apple id although i do not remember ever using it but i cannot remember the password.

    I restored my ipad but i was unable to activate it because it is askimg me for the apple id and password eith which i originally set it up. I know the apple id although i do not remember ever using it but i cannot remember the password. I have tried everything from reserting my password to trying different passwords but it asks me for a custom question that i dont remember creating.

    You need to use Apple's iForgot service or contact their Account Security team.
    (123152)

  • Hello all,  I bought an iPhone 5 in the US and brought it back to Brasil. Now I'm trying to use Siri, but once I press the "home" button "voice control" appears and it only works for me to call my contacts. The manual guide tells me to go to Settings Gene

    Hello all,
    I bought an iPhone 5 in the US and brought it back to Brasil. Now I'm trying to use Siri, but once I press the "home" button "voice control" appears and it only works for me to call my contacts. The manual guide tells me to go to Settings>General>Siri. At the General menu "Siri" doesn't appear. What should I do to set Siri up if it doesn't appear at settings>general?
    Thank you,
    Melanie.

    Go to Settings>General>Restrictions and make sure Siri is set to On.

  • I have a Iphone4. Trying to update from 4.3.3 to IOS 5 or 6.  There is no 'Update Software' button under Utilities/General. Tried updating using Itunes but it comes up 'The Iphone software update server cannot be contacted' ????

    I have a Iphone4. Trying to update from 4.3.3 to IOS 5 or 6.  There is no 'Update Software' button under Utilities/General. Tried updating using Itunes but it comes up 'The Iphone software update server cannot be contacted' ????

    iOS 4.3.3 doesnt have the "Update your Software" tab so you will need to go to itunes and back up your iphone then restore your iphone and it will download the latest iphone software (6.1.4) if you dont want 6.1.4 download your current version and hit shift on your keyboard (alt if your on Mac I think) and click restore iphone and find your downloaded software 4.3.3 then download iOS 5 or 6 and do the samething after your phone boots up from restoring it to 4.3.3.

  • I have a MacBook Pro and I created a movie using imovie but once I put the DVD back into my computer it said it was blank! Why?

    I have a MacBook Pro and I created a movie using imovie but once I put the DVD back into my computer it said it was blank! Why?
    Please HELP!!!!

    AFAIK, you can't author a DVD using iMovie - again, AFAIK, you need authoring software such as iDVD or Toast Titanium or something similar.
    Clinton

  • Hello! How I can cancel my iCloud account? I would like to use alias but I have create the second account by mistake. Now, user's name for one alias is unavailable!  Thank you! LG

    Hello! How I can cancel my iCloud account? I would like to use alias but I have create the second account by mistake.
    Now, user's name for one alias is unavailable!
    Thank you! LG

    To the best of my knowledge you have now unfortunately blocked yourself: you can't cancel an iCloud account and as you've got the address there you can't add it as an alias, and I don't know of any workaround for that.

  • I cannot connect to the internet using apps but im connected to the internet!

    i cannot connect to the internet using apps but im connected to the internet!

    What makes you think that you are connected to the internet then?
    Try:
    - Resetting the iPod. Nothing will be lost.
    Reset iPod touch:  Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Power off and then back on your router
    - Reset ntwork settings: Settings>General>Reset>Reset Ntwork Settings.
    - iPhone and iPod touch: Troubleshooting Wi-Fi networks and connections

  • No Video will play on any site using Safari, but I do get the audio

    This is a problem I've had for some time now. I've just switched over to FireFox when there was a video I wanted to watch instead of taking the time to fix it.
    Anyway, when trying to watch a video
    http://www.apple.com/macosx/guidedtour/small.html for example.
    I get no video at all, but I can hear the audio perfectly. Not sure what is going on here.
    I just upgraded to Leopard and was hoping this would resolve itself, but not such luck. Anyone have any ideas what the problem is?
    Thanks.

    That Guided Tour of Leopard works fine for me. Perhaps you need to tweak a few settings:
    These are the downloads and the settings you need in order to view/hear pretty much everything that the net can throw at you: The setup described below has proved repeatedly successful on both PPC and Intel macs, but nothing in life carries a guarantee!
    It is known to work in the great majority of cases with Safari 3.0.4, QT 7.3 and OS 10.4.11.
    Assuming you already run Tiger versions OS 10.4.9 or above (this has not yet been verified with Leopard) and have Quicktime 7.2 or above, and are using Safari 2 or 3, download and install (or re-install even if you already had them) the latest versions, suitable for your flavor of Mac, of:
    RealPlayer 10 for Mac from http://forms.real.com/real/player/blackjack.html?platform2=Mac%20OS%20X&product= RealPlayer%2010&proc=g3&lang=&show_list=0&src=macjack
    Flip4Mac WMV Player from http://www.microsoft.com/windows/windowsmedia/player/wmcomponents.mspx (Windows Media Player for the Mac is no longer supported, even by Microsoft)
    Perian from http://perian.org/
    Adobe FlashPlayer from http://www.adobe.com/shockwave/download/download.cgi?P1ProdVersion=ShockwaveFlash
    (You can check here: http://www.adobe.com/products/flash/about/ to see which version you should install for your Mac and OS.)
    In Quicktime Preferences, under advanced, UNcheck Enable Flash, and under Mime settings/Miscellananeous only check Quicktime HTML (QHTM).
    In Macintosh HD/Library/Quicktime/ delete any files relating to DivX (Perian already has them).
    Now go to Safari Preferences/Security, and tick the boxes under Web Content (all 4 of them).
    Lastly open Audio Midi Setup (which you will find in the Utilities Folder of your Applications Folder) and click on Audio Devices. Make sure that both Audio Input and Audio Output, under Format, are set to 44100 Hz.
    Important: Now repair permissions and restart.
    The world should now be your oyster!
    You should also consider having the free VLC Player from http://www.videolan.org/ in your armory, as this plays almost anything that DVD Player might not.

  • How do I designate an e-mail to use to "send a link" from the File menu?

    When I have a web page open that I want to send to someone through my e-mail, I try to use "Send Link" in the File menu. When I click on it, nothing seems to happen. How do I link that command with my e-mail account?

    http://support.mozilla.com/en-US/kb/Changing+the+e-mail+program+used+by+Firefox

  • HT1766 I tried to upload the data on my iPhone to a new Windows 8 laptop using iTunes but it only copied the music and wiped my contacts and calendar.

    Any help gratefully received.  Would it have saved the data on the hard drive on my PC?  I can see a file called data.syncdb on the C drive but have no idea what's in it or how to use it.

    Hi NWL1,
    Thanks for the question. If I understand correctly, the iPhone won't update and is stuck. I would recommend that you read this article, it may be able to help you resolve or isolate the issue.
    If you can't update or restore your iPhone, iPad, or iPod touch - Apple Support
    Thanks for using Apple Support Communities.
    Have a great day,
    Mario

Maybe you are looking for