-1

I am trying to position the elements using 'absolute' and 'relative' in CSS, I am also using 'padding' and 'margin' to position but my entire card elements is messed up. here is the code:

  • relative
  • absolute
  • margin
  • padding
    .side3_style {
        padding-left: 15px;
    }

    .side3-dp img {
        position: relative;
        display: inline-block;
        top: 4px;
        height: 40px;
        width: 40px;
        cursor: pointer;
        border-radius: 50px;
        margin-right: 15px;
        float: left;
    }
    .side3-info {
        display: inline-block;
        top: 4px;
    }

    .side3-name {
        font-family: 'Open Sans', Sans-serif;
        font-size: 14px;
        color: #3b3b3b;
        font-weight: bold;
        cursor: pointer;
    }

    .user3-time {
        font-family: 'Open Sans', Sans-serif;
        font-size: 10px;
        color: #9D9D9D;
    }

Screenshot

Patrick
  • 41
  • 1
  • 9

1 Answers1

0

Generally speaking you have a root div 'A' where you set position: relative and then inside this div you place another div 'B' with position absolute.

<div id="A" style="position: relative"><div id="B" style="position: absolute; top: 100px;left:100px;"></div></div>

If you check the above code, you will see that div B will be placed ^ 100px top distance from div A, and < 100px left distance from div A wherever div A exists.

Moreover you have to be carefull if you use float css attribute because you cannot then position based on parent elements easily.

I hope this helps

batspy
  • 385
  • 5
  • 7