【问题标题】:How do i add my own image to a button that links to another website in HTML & CSS?如何将我自己的图像添加到链接到 HTML 和 CSS 中的另一个网站的按钮?
【发布时间】:2015-03-08 17:36:57
【问题描述】:

我正在尝试创建一个链接到另一个网站的按钮,并且我想向其中添加我自己的图像。 我应该使用<input> 标签还是<button> 标签? 谢谢!

【问题讨论】:

  • 我应该使用按钮标签还是输入标签**
  • 我确定你需要使用标签。 :) 说真的,请将代码格式化为“标签”看起来很奇怪。

标签: html css image button


【解决方案1】:

如果你想添加到另一个网站的链接,那么,你需要使用a href 标签,因为你想添加一个图片作为链接,那么,你需要在a href 标签内添加img 标签就像下面给出的代码:

<a href="Your Destined Page"><img src="Your Desired Image"/></a>

【讨论】:

    【解决方案2】:

    您可以使用 HTML 表单:

    <form action="http://yoursite.com">
        <input type="submit" value=" to your site">
    </form>
    

    【讨论】:

      【解决方案3】:

      任何你想要的,你都可以使用。

      您也可以使用按钮或输入并为其设置背景(颜色或图像) 看看这个

      DEMO

      <button type="button" id="button1">My Button with image in background</button>
      
      #button1 {
        -webkit-appearance : none;
        -moz-appearance : none;
        border : none;
        background : url('http://upload.wikimedia.org/wikipedia/en/thumb/f/f2/Core_Image_icon.png/96px-Core_Image_icon.png');
        background-size : 100% 100%;
        background-repeat : no-repeat;
        width : 200px;
        height : 100px;
        box-shadow : 2px 2px 2px 1px gray;
      }
      

      【讨论】:

        猜你喜欢
        • 2018-09-15
        • 2013-05-24
        • 1970-01-01
        • 1970-01-01
        • 2019-01-27
        • 2022-11-04
        • 1970-01-01
        • 2017-02-01
        • 1970-01-01
        相关资源
        最近更新 更多