Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Center image above the box

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #177952
    Romchick
    Participant

    Guy, here I am again!

    Here is the goal. And the question is how to center the round of image? Cuz it not the real center. It always alittle bit to the left or to the right… The solution is obvious, but cant see a thing.

    #177955
    Paulie_D
    Member
    
    .new img {
    display: block;
    margin: 0 auto;
    }
    

    should do it.

    #177956
    Romchick
    Participant

    No, I mean not the exect image, but the .new class…

    #177958
    Paulie_D
    Member

    Oh…

    
    .new {
    width: 40px;
    height: 40px;
    padding: 10px;
    border-radius: 50%;
    background: #6699cc;
    display: flex;
    position: absolute;
    justify-content: center;
    align-items: center;
    /* top: -30px; */ <-- remove this 
    /* lefft: 40%; */ <-- remove this 
    top: 0;
    left: 50%;
    transform: translate(-50%,-50%);
    }
    
    #177962
    Romchick
    Participant

    and the hover effect ? 8)))

    #177963
    Paulie_D
    Member

    and the hover effect ?

    What about it?

    #177965
    Romchick
    Participant

    When hovered .new uses transform: rotateY(360deg);

    #177966
    Paulie_D
    Member

    Oh…well, I’m sure that could all be worked out (applying both at the same time) but instead, if you want a quick fix just use

    
    .new {
      width: 40px;;
      height: 40px;
      padding: 10px;
      border-radius: 50%;
      background: #6699cc;
      display: flex;
      position: absolute;
      justify-content: center;
      align-items: center;
      top: 0;
      left: 50%;
      margin-top: -30px; /* 50% of total height */
      margin-left: -30px; /* 50% of total width */
    }
    

    Less ‘automatic’ but it works.

    #177967
    Romchick
    Participant

    Just the way I needed! Thanks!

    #178013
    Romchick
    Participant

    No problem! Let it be used! )

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘CSS’ is closed to new topics and replies.