CSS 热点 &居中问题

发布于 2024-12-23 03:32:29 字数 1041 浏览 3 评论 0原文

我正在创建一个网站,我遇到了一个我不知道如何解决的问题,在网站上有一个矩形图像,中心有一个热点,我使用了以下 css 代码 -

 #image_map  
    {
        display: block;   margin-left: auto;   margin-right: auto; 
        width:302px;
        height:65px;
        background:url(Images/ManordLogo.png) no-repeat;
        position:relative;
        }
        #image_map a
        {
            display:block;
            position:absolute;
            }

            #image_map a#link1
            {
                width:42px;
                height:49px;
                top:11%;
                left:43%;
                }

第一行居中图像并允许页面可缩放,以下代码定义并创建热点。一切正常,热点和热点均可用。图像保持在正确的位置,但是在设计方面,我需要图像比页面顶部的当前位置低约 20px。 每次我尝试使用边距或填充或任何形式的定位时,图像都会跳到页面的右上角,我不知道为什么。

我需要图像和热点保持相同,并且热点的位置保持相对,无论浏览器窗口大小如何,但对于设计,我需要将图像向下移动 20px

我哪里出错了以及如何实现这?

编辑 - 我已经创建了 JsFiddle 版本,所以你可以明白我的意思,黑色代表整个图像,浅绿色代表热点,我需要整个块(黑色和浅绿色)向下移动 20 像素,同时仍然保持居中,可扩展。

链接到 JSFIDDLE - http://jsfiddle.net/cT3Eu/

谢谢。

I am midway through creating a website and I have come across an issue that I do not know how to fix, on the site there is a rectangular image with a hotspot in the center, I have used the following css code -

 #image_map  
    {
        display: block;   margin-left: auto;   margin-right: auto; 
        width:302px;
        height:65px;
        background:url(Images/ManordLogo.png) no-repeat;
        position:relative;
        }
        #image_map a
        {
            display:block;
            position:absolute;
            }

            #image_map a#link1
            {
                width:42px;
                height:49px;
                top:11%;
                left:43%;
                }

The first line centers the image and allows the page to be scale-able, the following code defines and creates the hotspot. Everything works fine and the hotspot & Image remain in their correct position, however on the design side I need the image about 20px lower than its current position at the top of the page.
Every-time I try and use margins or padding or any form of positioning the image jumps to the top right hand corner of the page, and I have no Idea why.

I need the image and the hotspot to stay the same and the position of the hotspot to remain relative regardless of the browser window size but for the design I need the image to be moved down by 20px

Where am I going wrong and how can I achieve this?

EDIT - I have created JsFiddle Version, so you can see what I mean, the black represents the entire image and the aqua represents the hotspot, I need the entire block (black and aqua) to move down by 20 pixels while still remaining centered and scale-able.

Link to JSFIDDLE - http://jsfiddle.net/cT3Eu/

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱的故事 2024-12-30 03:32:29

我已经在 IE7、8、9、当前的 Firefox 版本和当前的 Chrome 版本中进行了测试,并且为 #image_map 添加 margin-top: 20px; 对我来说效果很好: http://jsfiddle.net/cT3Eu/1/

I have tested it in IE7, 8, 9, current Firefox version and current Chrome version, and the add of margin-top: 20px; for #image_map works fine for me: http://jsfiddle.net/cT3Eu/1/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文