- This topic is empty.
-
AuthorPosts
-
May 17, 2014 at 4:36 am #170445
ckubs
ParticipantI know the title sounds pretty noobish but my problem is a s follows. I know how to make a picture frame around an image( or I hope so, I’m no CSS expert) but in my website(wordpress) when I do that, I get the desired border but it scalles down my image.
If I make the white border picture by putting a box shadow, white background and a padding of 4px, a square image of let’s say 200×200 with the border it get’s scalled down to 192×192 and a landscape one proportionally with the same 4px / 4px horizontally and only 2px / 2px vertically.
I can put somehow the image border on top of the image, or that is the only way? Tried a plugin but it worked the same way, tried to make use of :before but I guess it was a silly thing. I’m puzzled.
May 17, 2014 at 4:53 am #170446Atelierbram
ParticipantYou could use
outline: 4px
instead ofborder
, or setbox-sizing: border-box
on the element with the border. Can put that one on all elements as well:*, *::before, *::after { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
You can read up on box-sizing on an article on this site
May 17, 2014 at 5:56 am #170448Paulie_D
MemberBox-shadows are not included in element sizes and so will not shrink the image like a border.
The added benefit of box-shadows is that you can use more than one and thus get multiple ‘borders’
May 17, 2014 at 6:16 am #170450Atelierbram
ParticipantMay 17, 2014 at 6:22 am #170452ckubs
ParticipantThanks, I’ll look at that :) Since posting I made a picture too, to see what I want to achieve, I’m not the best person to describe stuff.
May 17, 2014 at 6:24 am #170454ckubs
ParticipantUh forgot about that. So basically I can put 2 box shadows, 4 px for the frame and 1px on the outside? :D
May 17, 2014 at 6:29 am #170455Paulie_D
MemberI’m still not entirely clear what it is you are trying to do….your two ‘I want it’ options are different.
May 17, 2014 at 6:46 am #170458Atelierbram
ParticipantNot clear for me either, opted here for ‘how I want it 2’.
http://codepen.io/atelierbram/pen/cxhjL
which has no box-shadow, so that may not be what you want at all, …
May 17, 2014 at 6:49 am #170459ckubs
ParticipantYes I want to keep the image size and the frame to be wether over my image as in the case one , or outside the image, not to take from it’s width or height, as in the case two.
Now, I’ll take your advices into consideration, and as a second solution I found a function that wraps the images in a defined div when inserted in wordpress editor so donno, I guess the topic can be marked as solved.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.