简体   繁体   English

怎么做 <img style> 可点击

[英]How to make <img style> clickable

I am using the following code: 我正在使用以下代码:

<img style="border:2px solid #3591c0;
width:200;
height:200;
border-radius-30px;
-moz-border-radius:30px;
-khtml-border-radius:30px;
-webkit-border-radius:30px;"
src="1.jpg"/></style>

How can I make the image in this code clickable? 如何使此代码中的图像可点击?

You could put it in an anchor <a> tag, which would make it a link. 您可以将其放在锚点<a>标记中,这将使其成为链接。

<a>
    <img style="border:2px solid #3591c0;
    width:200;
    height:200;
    border-radius-30px;
    -moz-border-radius:30px;
    -khtml-border-radius:30px;
    -webkit-border-radius:30px;"
    src="1.jpg"/>
</a>

Surround it in an anchor tag: 用锚标记将其包围:

<a href="destination.html">
    <img style="border:2px solid #3591c0;
    width:200;
    height:200;
    border-radius-30px;
    -moz-border-radius:30px;
    -khtml-border-radius:30px;
    -webkit-border-radius:30px;"
    src="1.jpg"/>
</a>

where "destination.html" is the file path or link where you want the user to be redirected to. 其中“ destination.html”是您要将用户重定向到的文件路径或链接。 And yes, you don't need the </style> tag. 是的,您不需要</style>标记。

This is all shown in the JSFiddle: http://jsfiddle.net/Mf6Dq/5/ 这全部显示在JSFiddle中: http : //jsfiddle.net/Mf6Dq/5/

Wrap that <img> tage within an <a> tag. <img>阶段包装在<a>标记内。 In addition, </style> is not needed. 另外,不需要</style>

<a href="http://stackoverflow.com">
  <img style="border:2px solid #3591c0;
  width:200;
  height:200;
  border-radius-30px;
  -moz-border-radius:30px;
  -khtml-border-radius:30px;
  -webkit-border-radius:30px;"
  src="1.jpg"/>
</a>

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

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