如何在属性中设置图像的位置?

问题描述 投票:-2回答:2

这是我的代码:

<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.

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

html image html-table
2个回答
0
投票

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>

1
投票

你的意思是?

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

将顶部和左侧属性更改为您需要的任何内容

© www.soinside.com 2019 - 2024. All rights reserved.