blogging, CSS, wordpress

Better Blogging: CSS Image Swap on Hover

Just in case you ever want to display one image and have it swap to another one when someone hovers on it, here’s how! Hover your mouse over the image below (Yay, Bitmoji!) and you’ll see what I mean. I came across this method for swapping images on hover here and it worked better (and on more browsers) than methods I’ve previously tried, so it’s the one I’d use for now.

(Note: The directions here work if your site is on WordPress.com and has an upgrade that allows Custom CSS.)

In the Text Editor on a page or post or a Text Widget, paste the following HTML where you want your image to appear:

<a class="imghoverswap" href="#"><img src="Insert_First_Image_URL_Here" /><img src="Insert_Second_Image_URL_Here" /></a>

Edit the HTML to include the URLs to your images in the two spots designated in the code above. Save/publish.

Then go to Customize > CSS and add this:

.imghoverswap img:last-child{display:none}
.imghoverswap:hover img:first-child{display:none}
.imghoverswap:hover img:last-child{display:inline-block}

(If you’re using your own install of WordPress, you can do this with the Jetpack plugin with the Custom CSS module activated. Once activated, paste the CSS in Appearance > Edit CSS.)

You can change the imghoverswap part to whatever you want, just make sure all four instances are changed to the same thing so they match and work together.

Happy swapping!

More CSS tips can be found here.

event notes, events, technology & web, wordpress

Additional Notes for my Session at NTC’s WordPress Day

Hi, WordPress Day-ers! As promised, here are the additional notes to accompany my slides from my session, “From Sharing to Hashtags: Social Media Musts for Your WordPress Site.” Slides are shared here. (And thanks for joining me!)

Everyone else: I made this presentation for WordPress Day at the Nonprofit Technology Conference in San Jose on March 22. Some of the information is geared specifically toward nonprofits, but lots of it is pretty universal for using WordPress & social media together, so enjoy! 🙂

Note: I’m not rehashing all of the text on the slides, so look at those for the main ideas and images. These notes include the additional things I said and things I wish I would’ve had time to say.

Click to see the notes!

about sarah, events, wordpress

Achievement Unlocked

WordPress Day was a success!

I talked about social media and WordPress:

And then I celebrated with a milkshake for dinner:

Celebratory milkshake for dinner! Also: fries & hotel lounging. #mymilkshakesj

A post shared by Sarah Blackstock (@sarahblackstock) on

 

It feels good to be flying home tomorrow having accomplished a goal I set for 2016. And it’s only March! 😀

events, technology & web, wordpress

NTC’s WordPress Day

I’m speaking at the Nonprofit Technology Conference’s WordPress Day tomorrow (March 22) in San Jose, California.

11:30-12:10pm
From Sharing to Hashtags: Social Media Musts for Your WordPress Site – Social media is a must for every organization in 2016. We’ll check out the sharing features built right into WordPress, as well as top plugins, apps, and tips, to update your social media strategy and extend your reach even further this year.

 

My slides are posted here. Additional notes to accompany them will be up by Wednesday.

Wish me luck! 🙂

blogging, CSS, wordpress

Better Blogging: Notes on a Design Change

Today I’ve got more notes on my blog’s recent theme change. This time, we’ll be checking out how to add a credit to the footer, and also change the look of the existing credits down there too.

If you missed a previous CSS post, browse my blogging tips tag, or check out these posts:

Add a Credit to the Footer

I added CSS so I could have my own credit down in the footer next to the existing two.

See:

Example of credit added to footer of Edin theme

Here’s the CSS I used to make that happen:

.site-info:before {
	content: "© Sarah Blackstock. | ";
}	

Notes:

  • Different themes label the footer credit area differently, but Edin (and several others) will use this selector to target it. Use the right-click Inspect method again (here!) in Chrome to find the correct selector for your theme.
  • Switch “before” to “after” to move your credit to the end.

Edit the Size & Color of the Footer Credits

You can also use CSS to adjust the size and color of the credits, as pictured below, where I made mine orange and a bit smaller:

Example of changing color and size of credits in footer of Edin theme

Here’s the CSS I added to adjust the color & size:

.site-info {
	color: #fa7f77;
	font-size: 12px;
}

.site-info a {
	color: #fa7f77;
	font-size: 12px;
}

Notes:

  • The first section of code above targets the plain text, while the second batch (with the “a” added in) targets the linked text.
  • Change the hex color code from the orange I’ve used (#fa7f77) to one that matches your site.
    • You can also use simple color words there, so try putting “black” in place of the color code if that’s the color you want.
  • Adjust the font size from 12px to any other number you’d like.

Tweet, comment, or email with any questions. And let me know if there are any other CSS topics you’d like me to cover here. I’m totally willing to temporarily break my blog for you to figure things out. 😉

blogging, CSS, wordpress

Better Blogging: Notes on a Design Change

Continuing on with the notes on my blog’s recent theme change, I’ve got more tips for customizing your blog and CSS today. Last time, I shared how I used CSS to take the header from this:

My header before CSS in the Edin theme

to this:

My header after CSS in the Edin theme

I’ve also previously discussed how to customize your text highlight color and style your blockquotes to make your blog more personalized.

This time, we’ll see how to turn a photo from square to round with CSS, and learn some simple adjustments that can be made to the Social Media Icons Widget on WordPress.com.

Round a Photo’s Corners

I added a photo of me to my about page. It started out cropped as a square, then I used CSS to make it display as a circle on the page. Here’s the code I added:

.wp-image-3932 {
	border-radius: 50%;
}	

Notes:

  • Using Chrome Inspect to find selector for imageI figured out how to target the image (with the wp-image-3932 selector) seen in line one by right clicking on it on my about page, then clicking Inspect in Chrome. (See the screenshot to the right.)
  • Change the border radius number until you see a look you like.
    • Changing it to 100% will also make a circle.
    • Changing it to 10% will give you rounded corners.
  • If your image is not a square, results will vary.
    • PicMonkey is great for quickly cropping images for the web.
  • Different browsers handle CSS differently, so it might not be universal. I don’t know what Edge or Internet Explorer will do, but if this CSS doesn’t work in a particular browser, your image will simply display as originally intended, which in my case would be a square. No big deal.

Adjust the Social Media Icons Widget

I was feeling too lazy to go find or make my own social media icons, so I decided to use the WordPress.com Social Media Icons Widget. But then of course I couldn’t just leave it as-is.

Here’s how it looks before (left) and after (right) along with the widget directly above it for reference:

Notice how the social media icons are larger and centered beneath the text? Here’s how I did that:

/*change alignment & spacing of social media icons in sidebar*/
#wpcom_social_media_icons_widget-2 {
 font-size: 200%;
 text-align: center;
}
/*change size of social media icons in sidebar*/
.genericon {
 font-size: 40px;
}	

Notes:

  • To replicate, add the Social Media Icons Widget to your WordPress.com site, then use the right-click Inspect method (remember?) to find which selectors to use to target the widget and icons.
  • In the first batch of code (lines 1-5):
    • The font-size number is controlling the spacing I added in between the icons. (I discovered that completely on accident, so who knows why it’s happening but I like it.)
    • The text-align is centering them within the sidebar.
  • In the second batch of code (lines 6-9):
    • Font-size increased the size of the icons themselves. (Play around with the number until they’re a nice size for your sidebar width and in relation to how many icons you’re using.)
    • You may have to get more specific than “genericon” for your selector, because if you have any other genericons on your site this code will change those too. I only have them in this one spot though, so it works for me.

Tweet, comment, or email with any questions. 🙂 Next time we tackle the footer credits!

blogging, CSS, wordpress

Better Blogging: Notes on a Design Change

I switched the theme of this blog from Singl to Edin recently. They’re both free themes by Automattic on WordPress.com, and are also available for download to use on self-hosted WordPress sites. (Not sure of the difference? See here.)

I’ve shared some CSS tips here before, on styling blockquotes and changing the color of your highlighted text. And since changing themes means changing CSS, I thought I’d share a few details on some adjustments I’ve made to the Edin theme so far. If you’re a WordPress.com user (like me!), you’ll need the Premium or Business upgrade to add CSS under Customize > CSS.

Note: I’ve left the blockquotes as-is (but the same CSS would work on this theme) and made my highlighting color match the new orange with the same method I shared before, so those directions remain the same.

The masthead area in Edin includes the site title and two menus, so of course I had to tweak those a bit to get a more customized look (while still leaving it super simple and not using a Header Image — because I haven’t made one and who knows if I will).

Adjust the Site Header

Here’s how it looked when I first added the theme onto my blog and put the menus in place:

My header before CSS in the Edin theme

In the Edin theme, when the Menu Style is set to Classic under Theme Options, the Primary Menu is the horizontal one under the site title (reading, my house, etc.), while the Secondary Menu is the one you see at the top right corner (about, now, contact). It all looks pretty standard and clean, but I like a little more color, so here’s how it looks right now:

My header after CSS in the Edin theme

It’s still basically the same. Nothing has moved anywhere, but with some slight adjustments it better fits my style.

Note: Your theme’s selectors (like .primary-navigation) for targeting a specific spot with CSS may vary, so you might need to find the correct ones for your theme. I explained how to do that under the “Here’s how I figured out what to target in Chrome” section in this post.

Here’s how I did it:

Change the Site Title’s Color & Size

.site-title {
 color: #fa7f77;
 font-size: 75px;
}

Alter the Primary Menu’s Colors

/*color of nav bar*/
.primary-navigation {
 background-color: #fa7f77;
}
/*color of links in bar*/
.primary-navigation a {
 color: #ffffff !important;
}

Notes:

  • See the notes I’ve added in between /* & */ ? Those comments can be really helpful in remembering what each bit of CSS is for and won’t interfere with how the code works on your site.
  • Change the colors to your own choices for the background color (the horizontal bar) and the text link color for the items in your menu.

Alter the Secondary Menu’s Colors

/*color of menu bar at very top*/
.secondary-navigation {
 background-color: #ffffff !important;
}

/*color of links in menu bar at very top*/
#menu-top a {
 color: #7ACCC8;
}

Notes:

  • Again, the comments (between /* & */) are helpful here, so feel free to use them too!
  • As with the other menu, change the colors to fit your own color needs. The first piece adjusts the color of the bar across the top, while the second handles the text link color.

Tweet, comment, or email with any questions. 🙂 Next time we’ll go over making a square photo round with only CSS and editing the look of the Social Media Icons Widget.