欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  html按钮设置超链接的方法一:使用超链接与button结合的方法
 
  html按钮超链接代码如下:
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <title></title>
 
  </head>
 
  <body>
 
  <ahref="http://www.php.cn/">
 
  <inputtype=buttonvalue="php中文网">
 
  </a>
 
  </body>
 
  </html>
 
  html按钮超链接效果如下:
 
  2345截图20181009115410.png
 
  说明:<a>标签的href属性用于指定超链接目标的URL。
 
  html按钮设置超链接的方法二:使用链接和css样式设置将超链接设置成按钮的形状
 
  html按钮超链接代码如下:
 
  
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <title></title>
 
  <styletype="text/css">
 
  a.button{
 
  -webkit-appearance:button;
 
  -moz-appearance:button;
 
  appearance:button;
 
  text-decoration:none;
 
  color:initial;
 
  }
 
  </style>
 
  </head>
 
  <body>
 
  <ahref="http://www.php.cn"class="button">php中文网</a>
 
  </body>
 
  </html>
 
  html按钮设置超链接的方法三:使用form表单来设置html按钮超链接
 
  html按钮超链接代码如下:
 
  <!DOCTYPEhtml>
 
  <html>
 
  <head>
 
  <title></title>
 
  </head>
 
  <body>
 
  <formmethod="get"action="http://www.php.cn/">
 
  <buttontype="submit">php中文网</button>
 
  </form>
 
  </body>
 
  </html>
 
  html按钮设置超链接的方法四:使用window.location.href方法
 
  完整的写法:
 
  <ahref="链接">
 
  <inputtype=buttononclick="window.location.href('连接')">
 
  </a>
 
  说明:
 
  1、若直接在本页跳转到新的页面,则用:<inputtype=buttononclick="window.location.href('连接')">
 
  2、如果需要打开一个新的页面进行跳转,则用:<inputtype=buttononclick="window.open('连接')">







本文转载自中文网

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h54592.shtml