我在网页上有一个横幅,图片的一部分是一个按钮盒的图形.我如何制作按钮是可点击链接(如a href)的部分?您可以看到下面的示例图像.

带有按钮图形的横幅图像示例

在横幅图像中有一个"立即加入,其自由"按钮图形.我想在这个框上添加一个链接,这样当用户单击横幅上的这个框时,它将打开下一页.我想知道如何在这个按钮上添加链接.我不想给它添加<button>标签;我只想添加一个基于"立即加入,它的自由"按钮图形区域的链接.任何人有任何 idea ,我可以添加一个链接的图像区域的这一部分,而不使用<button>标签.

 <div class="flexslider">

                <ul class="slides" runat="server" id="Ul">                             
                    <li class="flex-active-slide" style="background: url(&quot;images/slider-bg-1.jpg&quot;) no-repeat scroll 50% 0px transparent;                                               width: 100%; float: left; margin-right: -100%; position: relative; display: list-item;">

                      <div class="container">

                        <div class="sixteen columns contain"></div>   

                          <img runat="server" id="imgSlide1" style="top: 1px; right: 
       -19px; opacity: 1;" class="item" 
           src="images/slider1.png"            data-topimage="7%">
                           <a href="#" style="display:block; background:#00F; width:356px; height:66px; position:absolute; left:1px; top:-19px; left: 162px; top: 279px;"></a>      


                      </div>   


                  </li>
                </ul>

            </div>

            <ul class="flex-direction-nav">

                <li><a class="flex-prev" href="#"><i class="icon-angle-left"></i></a></li>
                <li><a class="flex-next" href="#"><i class="icon-angle-right"></i></a></li>
            </ul>           

        </div>

非常感谢.

推荐答案

如果不想让按钮成为单独的图像,可以使用<area>标签.这是通过使用类似以下内容的html完成的:

<img src="imgsrc" width="imgwidth" height="imgheight" alt="alttext" usemap="#mapname">

<map name="mapname">
    <area shape="rect" coords="see note 1" href="link" alt="alttext">
</map>

注1:coords=" "属性的格式必须为:coords="x1,y1,x2,y2",其中:

x1=top left X coordinate
y1=top left Y coordinate
x2=bottom right X coordinate
y2=bottom right Y coordinate

注2:usemap="#mapname"属性必须包括#.

EDIT:

我查看了您的代码,并在应有的位置添加了<map><area>标记.我还注释掉了一些与图像重叠或似乎没有用处的部分.

<div class="flexslider">
    <ul class="slides" runat="server" id="Ul">                             
        <li class="flex-active-slide" style="background: url(&quot;images/slider-bg-1.jpg&quot;) no-repeat scroll 50% 0px transparent; width: 100%; float: left; margin-right: -100%; position: relative; display: list-item;">
            <div class="container">
                <div class="sixteen columns contain"></div>   
                <img runat="server" id="imgSlide1" style="top: 1px; right: -19px; opacity: 1;" class="item" src="./test.png" data-topimage="7%" height="358" width="728" usemap="#imgmap" />
                <map name="imgmap">
                    <area shape="rect" coords="48,341,294,275" href="http://www.example.com/">
                </map>
                <!--<a href="#" style="display:block; background:#00F; width:356px; height:66px; position:absolute; left:1px; top:-19px; left: 162px; top: 279px;"></a>-->
            </div>
        </li>
    </ul>
</div>
<!-- <ul class="flex-direction-nav">
    <li><a class="flex-prev" href="#"><i class="icon-angle-left"></i></a></li>
    <li><a class="flex-next" href="#"><i class="icon-angle-right"></i></a></li>
</ul> -->

Notes:

  1. coord="48,341,294,275"是指你发布的截图.
  2. src="./test.png"是您在我电脑上发布的截图的位置和名称.
  3. href="http://www.example.com/"是一个示例链接.

Asp.net相关问答推荐

如何在 ASP.Net Core 中验证上传的文件

C# ASP.NET Core Serilog 添加类名和方法到日志(log)

获取没有主机的 url 部分

我可以根据角色隐藏/显示 asp:Menu 项吗?

如何将 global.asax 文件添加到 ASP.NET MVC4 项目?

如何通过后面的代码不显示

我应该如何在类和应用层之间传递数据?

如何设置 CSS 切换器

如何在 ASP.NET MVC3 中配置区域

如何从 Asp.net Mvc-3 发送邮箱?

在 ASP.NET 4.5 WebForms 中通过 bundle.config 与 BundleConfig.cs Bundle 资源

如何将参数传递给 ASP.NET MVC 2 中的自定义 ActionFilter?

VS 2010 中缺少 App_Code 文件夹

MVC3 值 Ajax 文件上传

会员生成密码 仅限字母数字密码?

在后面的代码中删除 css 类

在 ASP.NET MVC 中模拟 User.Identity

使用 ConfigurationManager.RefreshSection 重新加载配置而不重新启动应用程序

重新生成designer.cs

ASP.NET MVC2/3 中runAllManagedModulesForAllRequests的正确用法是什么?