如何在右上角放置图像

时间:2012-11-18 03:30:44

标签: html css html5

如何将图像放在桌子的右上角?我想为桌角设置一个图像。 我怎么能在html或css中做到这一点?

以下是我想要的例子:

enter image description here

2 个答案:

答案 0 :(得分:3)

@Sonasish Roy说:

。你需要一个桌子包装器。

HTML:

<div id="container_table">
   <img src="img_right.jpg">
   <table>
     <!-- Here is your table content /-->
   </table>
</div>

CSS:

#container_table{
   position:relative;
   //Set some width because table has width:100%;
   width: 90%;
}
#container_table img{
   position:absolute;
   right:0;
   top:0;
}
#container_table table{
   //Here some css for your table, even you can use background-image, but you can have some problem with borders.
}

如果你想看到所有上面的代码都使用示例表和图像,我就做了这个小提琴:http://jsfiddle.net/H3Vqc/5/

答案 1 :(得分:1)

你需要将表格包装在div中,将div设置在相对位置,将角落细节图像设置在绝对位置。