Replicating CSS Border effects in Photoshop. Efficiently.
A recent conversation:
Me (desperately trying to learn the nuances of HTML/CSS in order to fit in with the Kewl Kidz of my personal metaphorical high school. I call it oAk High.): “So…what if I want to put two borders on one of my images with CSS? Can I do that.?”
Steve (a.k.a. Ordered List): “Yeah. Give it a background color, padding and an outline.”
So that’s what I’ve done below.

I hooked this image with class “doubleborder” and then in my style sheet specified the following declaration:
img.doubleborder { border: 1px solid #000; background-color: #dbaea8; padding: 5px; }
This works because the padding reveals five pixels of the background color while the border declaration rings the entire image with one pixel of solid black. Nothing particularly brain busting here, and clearly, I’m not covering anything that hasn’t been discovered and discussed exhaustively elsewhere…but to a designer learning to code, this is cool stuff.
Because I’m an adventurous sort, I wasn’t content to rest on my laurels with this, and I got to thinking that, theoretically, instead of declaring a background color I could just as easily declare a background image and draw some of the ATCO color scheme in to the border area. Assuming I were to use the graphic that is the declared background image of the sidebar, the effect looks like this:

The CSS declaration here reads as follows:
img.doubleborder_alternate { border: 1px solid #000; background: #f8f8f8 url(/wp-content/themes/atimcalledoak/images/sidebarbackcolors.jpg) no-repeat top left; padding: 5px; }
Mocking this up in Photoshop
Until Photoshop allows us to specify a background image instead of a color or gradient for a stroke in Layer Styles (How ’bout it, interwebs? Is this possible?), the second concept would still have to be mocked-up by hand (although the black outline can still be applied with Layer Styles as described below). The first image, with the solid color background can be done very quickly and easily with Layer Styles. The explanation is below.
Layer Styles
These are sets of controls that are accessible through the button bar in the Layers panel panel that looks like an italic “fx” (see image below). Probably the quickest, easiest, most basic Layer Style with which most people are intuitively familiar is the Drop Shadow.

In my example image, the Layer Style button is grayed out because I am working with a flattened JPEG, and the background layer (which is the only layer in the file) is locked. To unlock it I’d simply double click the Background Layer and set it as Layer 0, at which point the Layer Styles button would become available.
Copy and Paste: The Coolest Part of Layer Styles
Once a layer is styled in Photoshop, those settings not only remain fully customizable, the entire group of settings can be copied and pasted to other layers and reapplied exactly as they appear on the original layer. This means, that when we finish with our border effect in the PS mock-up, applying it to other images is as easy as right clicking on the layer, selecting “Copy Layer Style,” then right clicking on the target layer and selecting “Paste Layer Style.”
The ability to copy and paste layer styles makes me think back to all of the hand drawn effects that I used to put together in a previous life, meticulously selecting, expanding, creating new layers, filling with color…etcetera…then redoing it on all other images. Using layer styles allows you to get on with more important things
So…How do we replicate the double border CSS effect in Photoshop using Layer Styles?
As a reminder, here’s what we want our image to look like in photoshop using CSS:

In an actual mock-up, I’d bring this image into Photoshop by using the rectangular marquee tool to draw the shape in the mock-up that I want the image to take up. I then Select All (Cmd+A) in the image file, and Copy (Cmd+V). In the mock-up file, I create a new layer and, with my selection still active, I select “past into” from the Edit menu (Shift+Cmd+V). This pastes the content of my image in a new layer and automatically uses the selection I indicated with the rectangular marquee to create a mask around the image. Then I just resize the image using Cmd+T until I’m satisfied with the crop. The image in place would look something like this:

Applying the black outline is pretty straight forward. Click the layer styles button (”fx”) at the bottom of the Layers panel, and select “Stroke” from the pull-down menu. The stroke settings will appear. The sidebar represents all of the other settings that we can change for this layer. Any or all of these settings can be applied at the same time. (we’ll get to this in a second).

Set the color to black (#000000), the size to “1 px” and the position to “inside.” It’s important to set the position to “inside,” because if the stroke is applied to the outside of the image, it will curl around the corners forming a sloppy looking rounded cornerish kind of thing. We don’t want that. Use “inside” for this setting.
Next we want to apply the inner stroke, on the image (the salmony kind of color in my sample image above). You can’t apply multiple strokes to a layer using styles. What you can do is apply a stroke and an Inner Glow or Inner Shadow to replicate the same effect. The secret is the “Choke” and “Range” settings, which allow you to specify the degree of fade on the effect, or turn it off entirely to get a solid edge.
From the sidebar, select “Inner Glow.” Change the color to #dbaea8. We want to get rid of any transparency, so set Opacity to 100% and make sure Blend Mode is set to “Normal.” Set Choke to “0%” and Range to 1% (which is the lowest setting for Range). Then set the Size to whatever thickness you want for your inner stroke. I’ve used 5 px. This is what my settings look like:

Click “Okay.” Here’s what our layer looks like with the Stroke and Inner Glow applied:

Both of these effects are now contained in the settings for the layer styles as noted by the arrows in the image above. I can turn these effects off one at a time or both at the same time using the Eye icons. I can also double click either of the effects to adjust the settings if I want to, for example, change the colors of the borders or increase the thickness. Finally and probably most importantly, I can right click on the layer styles and select “Copy Layer Style” from the pull down menu that appears, and then Paste all of these settings onto any other layer of my document, or any other layer in another open document without having to manually reset all the settings by hand.
What I Don’t Know How To Do…
It seems like there should be a way to make these settings global across all pasted instances of the same Layer Style so that a change to one is automatically applied to the rest, but I’m not sure how to do this, or even if it’s possible. If so, please comment on this post and let me know, I’d love to figure out if this can be done.
Post questions in the comments, I’ll try to answer them as best I can.
-oAk-


%20.jpg)

