Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,987 courses, including more Design and personalized recommendations.Start Your Free Trial Now
- View Offline
One of the more remarkable new features in Photoshop 13.1 is its ability to automatically generate CSS code. So you can take a text layer or a shape layer or entire group and copy the CSS code associated with it and then paste it into your web document. So it's a chance to have Photoshop do some of the work for you, instead of having to code everything by hand. Now this example that I am about to show you comes from my buddy Justin Seeley, who does the course Photoshop for Web Design at lynda.com.
So a brief shout out to him. I am going to switch over to this document, and you can see that it's got this solid blue header, and there's no button around Buy Now. Whereas, if we go ahead and switch over to the mockup inside of Photoshop, you can see that Buy Now has a button around it and both it and the header have these red to dark red gradients. So what I am going to do here, the first thing you've got to do is confirm that Photoshop is ready to export the clipboard. This is very important. So press Ctrl+K or Command+K on the Mac to bring up the Preferences dialog box and turn on this check box right here, Export Clipboard.
Now it's on by default, but I normally recommend people turn it off, because otherwise you're copying these massive pixel-based images in Photoshop and then it's trying to offload those images to the clipboard, your system slows down, all kinds of problems can occur. But if you want to be able to copy and paste CSS, this check box has to be on. So go ahead and turn it on and then click OK. Then I'll go over to the Layers panel here, twirl open the header layer, and I got this shape layer right here called Header Bar. I am going to right-click on it. Your shortcut menu won't be such a mess. It's just that my screen is so short.
You'll find this command called Copy CSS. It's only available in the RGB mode, by the way, so if you happen to be working inside of CMYK document, it will be dimmed. Most of you aren't, but just so you know. I will go ahead and choose Copy CSS, and then I'll switchover to Dreamweaver where I have that source file open, the index.html file. Notice that it references this file called style.css. I'll go ahead and switch over to it, and what I want to do is edit this code down here that says header.
Currently, you can see background is set to the solid shade of blue. That's not what I want. Now we've already got our header tag in place here, so I just need to replace this background information. Photoshop has copied too much code for my purposes. So what I'm going to do is edit it down a little bit inside of a new document by going up to the File menu and choosing New. Then I want to create a new CSS document. So I will go ahead and select it and then click Create. Then I'll press Ctrl+V or Command+V on a Mac to paste all of that code. Notice in addition to this header bar tag there, I've got the background information which is what I want. I also have this positioning information.
It's very unlikely you're ever going to find this useful. So you will probably want to take it out. However, it does represent Photoshop's best guess for positioning info. Anyway, I am going to go ahead and just select these two lines right there. Then I'll copy by pressing Ctrl+C or Command+C on the Mac, then I'll switch back to my index.html file. I'm still actually looking at the contents of style.css. I'll go ahead and select the existing background information, and I'll press Ctrl+V or Command+V on the Mac in order to paste it in there, and then I'll go up to the File menu, and I'll choose the Save command.
Now if I switch back to my browser, which happens to be Chrome, and I go ahead and update the contents of this page, you will see that I've now got the gradient header. Now let's take care of the Buy Now button. I will go ahead and switch back to Photoshop, and I'll twirl open the Content group in this case. Scroll my way down to this item right here called button, right-click on it, and once again choose Copy CSS. Now I'll return to Dreamweaver, and I need to scroll all the way to the bottom of my CSS document, down here to line 123.
So I'm clicking after this existing btn_text tag, and I'll press Ctrl+V or Command+V on a Mac to create an entirely new tag, as you can see, right here. The thing is I don't want that position info. I'll go ahead and show you what that looks like just so you know. I'll go up to the File menu and choose the Save command and then I'll switch over to Chrome, and I will go ahead and reload the page, and you can see that Photoshop's best guess for where the Buy Now button goes is entirely wrong. So let's go ahead and strip out that information by grabbing these three lines right here, position, left, and top.
Then I'll press the Backspace key or the Delete key on the Mac to get rid of them, and I'll switch over for a final time to Chrome, and I will click on the Refresh button, and you can see that the Buy Now button is now where it needs to be. That friends is how you copy and employ CSS code that's automatically generated by Photoshop 13.1.
- Enabling auto recovery and background saving
- Filtering layers in the Layers panel
- Modifying multiple layers at once
- Applying layer effects to groups
- Working with the Content-Aware tools
- Redeveloping photos in Camera Raw 7
- Creating depth of field with the Blur Gallery
- Correcting wide-angle panoramas
- Filling and stroking shape layers
- Editing videos in the Timeline panel
- Previewing 3D shadows and reflections