Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 表格右上角的CSS位置图标_Html_Css - Fatal编程技术网

Html 表格右上角的CSS位置图标

Html 表格右上角的CSS位置图标,html,css,Html,Css,我对CSS比较陌生。我的页面上有一张宽度为70%的表格。我需要在表格右侧上方放置一个小图标,以便图标与其下方表格的右边距对齐。我怎样才能做到这一点 因此,一般来说,这个问题是如何使用CSS定位页面中元素相对于其他元素的位置 谢谢, 卡尔文在CSS中,你应该写: .myclass { position:relative; } 或 请给出以下css: <img src="position: relative; top: 20px;" /> 我希望您的问题将得到解决,现在您可

我对CSS比较陌生。我的页面上有一张宽度为70%的表格。我需要在表格右侧上方放置一个小图标,以便图标与其下方表格的右边距对齐。我怎样才能做到这一点

因此,一般来说,这个问题是如何使用CSS定位页面中元素相对于其他元素的位置

谢谢,
卡尔文

在CSS中,你应该写:

.myclass {
    position:relative;
}


请给出以下css:

<img src="position: relative; top: 20px;" />

我希望您的问题将得到解决,现在您可以轻松地将位置交给
父位置相对
子位置绝对
并根据您的布局执行右上方

现场演示


上面的人已经回答了这个问题,但是如果你想知道它是如何工作的,试着看看:

当创建整个页面的布局时,您也应该考虑使用div而不是表。

谢谢。我仍然不明白这是如何告诉图像相对于表格的?图像实际上应该是绝对定位的,而表格定位的相对性在我的CSS中使用上述语法,它就像一个符咒。我想我需要探索CSS的更多属性。谢谢如石
<img src="position: relative; top: 20px;" />
.classname {
    position:relative;
}
<div style="position:relative;float:left;overflow:hidden">
<table>
...
</table>
<div class="icon"></div>
</div>

.icon {
position:absolute;
width:10px;
height:10px;
top:0;
right:0; 
}
top:-10px; /* above the table */
right:-10px; /* on the right side the table */