简体   繁体   English

可点击的图像页脚,HTML

[英]Clickable image footer, html

I have a 2000*300px image I am planning to use as a footer. 我打算将2000 * 300px图片用作页脚。 There are four sections in the middle, and each needs to be clickable - they should be links. 中间有四个部分,每个部分都是可点击的-它们应该是链接。 I'm using an image map right now. 我正在使用图像地图。

I have a footer at the bottom of the site. 我在网站底部有一个页脚。 It has a width of 100% and a height of 300px. 它的宽度为100%,高度为300px。 What I need to do is centre the image in the middle of the div, with any overflow hidden. 我需要做的是将图像居中放置在div的中间,并隐藏所有溢出。 It must remain clickable - that's why I can't just resize the image. 它必须保持可点击状态-这就是为什么我不能只是调整图像大小。

So! 所以!

  • How can I centre the element within the footer div, with overflow hidden? 如何将元素在页脚div中居中并隐藏溢出?
  • Alternatively, how can I dynamically resize the footer image but still have it clickable? 或者,如何动态调整页脚图像的大小,但仍可单击?
  • Alternatively, how can I implement the same effect - a continuous-appearing image with clickable sections as a footer? 另外,我如何实现相同的效果-以可点击部分作为页脚的连续出现的图像?

If it is ok to allow the image to be cut off on the sides, then you can center the image by setting the image position to center in the CSS. 如果可以在侧面切割图像,可以通过将图像位置设置为CSS中心来使图像居中。

.footer {background: transparent url(path/to/image) no-repeat bottom center;}

To get the have other clickable elements just nest new divs or paragraphs or links in footer div. 要获得其他可点击元素,只需在页脚div中嵌套新的div或段落或链接。

It would look something like this. 看起来像这样。

<div class="footer">
    <a>Clickable Content</a>
    <a>Clickable Content</a>
    <a>Clickable Content</a>
    <a>Clickable Content</a>
</div>

Then you can set the height and width for each of those. 然后,您可以为每个设置高度和宽度。 Then set the link. 然后设置链接。 Or use divs and set the links inside of them. 或使用div并在其中设置链接。

.footer a {height: 300px; width: 25%;}

You can try this: 您可以尝试以下方法:

CSS CODE CSS代码

    .footer {background: transparent url(path/to/image) no-repeat bottom center;}

HTML CODE HTML代码

    <div class="footer">
        <a>Clickable Content</a>
        <a>Clickable Content</a>
        <a>Clickable Content</a>
        <a>Clickable Content</a>
    </div>

Also can use this: 也可以使用这个:

    .footer a {height: 300px; width: 25%;}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM