Forums

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

Home Forums CSS How to make custom thumbnail with css?

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #41766
    pedram
    Member

    Hi guys,
    i want to make custom thumbnail like this:

    Resident Evil Upload Center

    this is my css:

    #user_area img.avatar {
    border:1px solid #000000;
    width: 30px;
    height: 30px;
    background: #000000;
    display: block;
    }

    can anyone help to make thumbnail fix to center?

    #119907
    chrisburton
    Participant

    @pedram Put your markup up on http://codepen.io so we can help you with the css.

    #119913
    TheDoc
    Member

    To get cropping like that you’ll need to turn it into a background image in a `

    `.
    #119883
    pedram
    Member

    @TheDoc yes, its work
    Thanks guys, i figure it out!

    #div_avatar {
    width: 30px;
    height: 30px;
    border: 1px solid #000000;
    overflow: hidden;
    position: relative;
    float: left;
    margin: 2px 10px 0 0;
    }
    #div img.avatar {
    width: 30px;
    height: auto;
    padding: 1px;
    position: absolute;
    }

    it works!

    #119916
    TheDoc
    Member

    I was thinking more like this:

    HTML:

    CSS:

    .avatar {
    width: 30px;
    height: 30px;
    background: url(‘/your/path/to/image.jpg’);
    float: left;
    /* etc */
    }

    #119918
    dfogge
    Participant

    you can do it with inline img’s like this: http://codepen.io/derekfogge/pen/IlfwD

    #120029
    Atelierbram
    Participant

    Forked dfogge’s codepen with inline img’s, here with absolute positioning and css clip property ( with added/bonus hover state ): http://codepen.io/atelierbram/pen/DplKs

    #120031
    chrisburton
    Participant

    Yeah, I was imagining what @dfogge had produced without using a background image.

    #120033
    dfogge
    Participant

    that’s way slicker, @Atelierbram.

    #120064
    TheDoc
    Member

    Ver cool, not particularly flexible though. I had a feeling the OP was referring to a solution that would be able to work on *any* image, but I could be wrong!

    #120183
    Atelierbram
    Participant

    @dfogge: thanks! @TheDoc: inflexible indeed; awkward in layout (: element with clip property needs to have absolute positioning), difficult to maintain: need to set clip property values for every single thumbnail in order to determine the ‘focalpoint’. So is this worth it for only a cool hover state? Maybe not on a blogroll, but then for some it might. So I made this new codepen with a kind of ‘grid-helper image’:
    http://codepen.io/atelierbram/pen/Ipzhi.
    Work in progress.

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