Css 如何在每个包裹中进行1次俯冲保持在右侧和顶部

Css 如何在每个包裹中进行1次俯冲保持在右侧和顶部,css,Css,如何使每个.wp\u列表中的.c保持在右侧和顶部,如右侧:0顶部:0? 我将位置设置为绝对位置,但如果这样,则top:0stand.wpnot.wp\u list html A. B C A. B C //从php生成 您可以将.c元素放置在以下位置: .c{ position:absolute; right:0px; top:0px; width: 130px; height: 130px; } 您还需要相对定位容器,以便将.c元素绝对定位在.wp

如何使每个
.wp\u列表中的
.c
保持在右侧和顶部,如
右侧:0顶部:0

我将位置设置为绝对位置,但如果这样,则
top:0
stand
.wp
not
.wp\u list

html


A.
B
C
A.
B
C
//从php生成

您可以将
.c
元素放置在以下位置:

.c{
    position:absolute;
    right:0px;
    top:0px;
    width: 130px;
    height: 130px;
}
您还需要相对定位容器,以便将
.c
元素绝对定位在
.wp\u list
元素中,而不是
.wp

.wp_list{
    position:relative;
    background-color: red;
    margin: 10px;
    height: 130px;
}

这应该可以做到:-

.wp_list{
    background-color: red;
    margin: 10px;
    height: 130px;
    position:relative; /*mark parent as relative*/
}

.c{
    width: 130px;
    height: 130px;
    top:0; /*set right and top of the relative parent*/
    right:0;
    position:absolute; /*mark child as absolute*/
}

为了更好地解释为什么我要设置.a.b.c的边距:10px;,我想补充一下。a和.c仍然喜欢页边空白顶部:0我尝试设置。a.b.c喜欢页边空白:10,周围和每个都有空格。wp_列表页边空白:10,但看起来都没有留下顶部空间
.wp_list{
    position:relative;
    background-color: red;
    margin: 10px;
    height: 130px;
}
.wp_list{
    background-color: red;
    margin: 10px;
    height: 130px;
    position:relative; /*mark parent as relative*/
}

.c{
    width: 130px;
    height: 130px;
    top:0; /*set right and top of the relative parent*/
    right:0;
    position:absolute; /*mark child as absolute*/
}