【问题标题】:How can I set the position of my image in an <img> attribute?如何在 <img> 属性中设置图像的位置?
【发布时间】:2014-12-26 12:48:30
【问题描述】:

这是我的代码:

<td class='buttons'><img src='images/buttons.png' alt='del' id='buttons_del' width='25'       height='25'></td>
<td class='buttons'><img src='images/buttons.png' alt='add' id='buttons_del' width='25' height='25'></td>

This is a link to the image I'm using.

更新:
我想选择图像的一部分而不是整个图像。

【问题讨论】:

  • 您能更具体地说明您想要什么吗?
  • 我也删除了css标签,因为这不是css
  • 用css可以设置背景位置,但是我不知道怎么用属性。
  • 当你使用style属性时,你可以把css内联。 &lt;img&gt; 也是标签而不是属性。检查我在下面做了什么

标签: html image html-table


【解决方案1】:

你是这个意思吗?

<img src='images/buttons.png' style="position: absolute; top: 20; left: 20;" alt='del' id='buttons_del' width='25' height='25'></td>

将 top 和 left 属性更改为您需要的任何内容

【讨论】:

    【解决方案2】:

    a{
    	display: inline-block;
    	width: 25px;
    	height: 25px;
    	overflow: hidden;
    }
    a img{
    	position: relative;
    }
    a.two img{
    	left: -25px;
    }
    a.three img{
    	left: -50px;
    }
    a.four img{
    	left: -75px;
    }
    <body>
       	<a href="#" class="button one"><img src="http://i.imgur.com/y8ewSl4.png" /></a>
       	<a href="#" class="button two"><img src="http://i.imgur.com/y8ewSl4.png" /></a>
       	<a href="#" class="button three"><img src="http://i.imgur.com/y8ewSl4.png" /></a>
       	<a href="#" class="button four"><img src="http://i.imgur.com/y8ewSl4.png" /></a>
    </body>

    【讨论】:

      猜你喜欢
      • 2022-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多