- This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
Viewing 11 posts - 1 through 11 (of 11 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
@pedram Put your markup up on http://codepen.io so we can help you with the css.
To get cropping like that you’ll need to turn it into a background image in a `
@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!
I was thinking more like this:
HTML:
CSS:
.avatar {
width: 30px;
height: 30px;
background: url(‘/your/path/to/image.jpg’);
float: left;
/* etc */
}
you can do it with inline img’s like this: http://codepen.io/derekfogge/pen/IlfwD
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
Yeah, I was imagining what @dfogge had produced without using a background image.
that’s way slicker, @Atelierbram.
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!
@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.