Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Making the welcome message responsive

From: WordPress 3: Building Child Themes

Video: Making the welcome message responsive

So far, we've added a new feature at the top of our index page that shows a featured image and a welcome message. Now we need to realign this so it looks little bit better. I mentioned before that I want that featured image to float on the right and then have a text on the left so it takes up less space of the top here. To do that, I need to apply some CSS so that I can align these elements. But I don't like to add extra code unless I absolutely have to, and I have a feeling that this theme, the twentytwelve theme, might already have the layout styles I need. I just need to apply those styles rather than writing my own.

Making the welcome message responsive

So far, we've added a new feature at the top of our index page that shows a featured image and a welcome message. Now we need to realign this so it looks little bit better. I mentioned before that I want that featured image to float on the right and then have a text on the left so it takes up less space of the top here. To do that, I need to apply some CSS so that I can align these elements. But I don't like to add extra code unless I absolutely have to, and I have a feeling that this theme, the twentytwelve theme, might already have the layout styles I need. I just need to apply those styles rather than writing my own.

So I'm going to do some experimentation here. I know there's a page template in twentytwelve that's called Front Page and have a feeling that page may have the layout I need. So I am going to apply that one to the page that this content is coming from so I see if it floats the image the way I want it to. So I'll go back to my Dashboard, under Pages,. Then I'll find Front Page. I am just going to do a Quick Edit here. And I'll change the Template from Default Template to Front Page Template. Now I am going to view to Front Page.

I know this is getting a little confusing, because this is the page that has the name Front Page, so it's not actually the front page of the site. And I have applied the Front Page Template meant to be on a Front Page, but currently not on the Front Page, to the page called Front Page. What matters here is that you can now see that the layout is the layout I want. I have image on the right and I have text on the left, which means the work has already been done, and all I need to do is make my Front Page, the welcome.php file, call in the same styles.

So I am going to use my Developer tools here. I'll right-click on the image and click Inspect Elements to see what's going on. And Here I very quickly see that the div that contains the image has a class "entry-page-image". So if I go and copy this class, jump to my Front Page or the Index Page, scroll down, find the image, inspect the element, and then simply apply that class to the "figure" so now it says just figure class entry-page-image, the image magically shifts over to the right just like I want it to.

So I don't need to write any style code here. All I need to do is apply a class to the existing code. I'll go into my child theme, open welcome.php, find my figure, and just paste in class "entry-page-image". And I am going to put in a comment here now. I'll save this, turn off my Developer tools, and reload the Index Page. The text is on the left and the image is on the right, but I am not quite done yet.

First of all, I want to separate the welcome message from the rest of the content by making more space and also adding a line here, so it's clear that these two things don't go together. But more importantly, the twentytwelve theme is fully responsive. By responsive I mean the theme reorganizes and reshapes to fit with whatever size screen you are using. So if someone is using a cell phone, they have a smaller screen and the content reorganizes so you don't have to scroll left and right to read things. You can see what I'm talking about if you resize your window.

You see here that as I resize the window, the content shifts around. But it looks really weird up here because currently everything is kind of jammed together. So I need to add some style to make sure that there is space here and everything is aligned properly. To save you some time, I have already created all the styles necessary and put them in the code snippets for this movie. So if you go up to your code snippets, under movie 7.4, you find all the styles necessary. So I'll start by copying this batch of styles here, go to my style.css file in my child theme, and just paste that in.

I'm doing several different things. First I am adding a border to the bottom, and I am also making some space so that that welcome message is spaced separate from the rest of the content. Then I am taking the text and floating it to the left and giving it the same amount of space as the image has on the right. And then I'm giving some extra space for the intro text paragraph, so that there's a nice breathing space between the image and the text. I'll save my new style.css file and reload the page in my browser, and you'll see now things align much better.

So when I resize this, you see there is nice breathing space between the text and image. However, I am not quite done, because if I take this down even more, you will see the image pops at the top, but the text keeps squishing in, because we are still telling the browser that this text should take up 49.7% of the space. To fix this I need to use a media query. A media query basically asks the browser how big is the window currently, and then if the window is of a current size, it uses a different style.

If you go back to your code snippets, you'll see here it's a very small media query just to fix that problem with the text. So I'll paste that in at the very bottom of my style sheet, and you can see that what it says is if the screen has a max width of 600 pixels--means it's smaller than 600 pixels--set the intro element floats to none and the width to 100%. If you look up here, you'll see that currently the intro element is set to left and the width is 47.9%.

If I save that and reload my skinny browser, you'll see that the text now flows over all the page, but if I scale it up, it pops over and only takes up 47.9%. So now, we have a welcome message with the featured image on the right, a line that separates the welcome message from the rest of the content, and things are really starting to look good. You also got a sneak preview of how to build a responsive WordPress theme.

If you want to know more about how to build responsive WordPress themes, you should go and check out my other course in the lynda.com library called WordPress: Building Responsive Themes.

Show transcript

This video is part of

Image for WordPress 3: Building Child Themes
WordPress 3: Building Child Themes

45 video lessons · 33106 viewers

Morten Rand-Hendriksen
Author

 
Expand all | Collapse all
  1. 6m 59s
    1. Welcome
      1m 6s
    2. Using the exercise files
      1m 34s
    3. What you need to know before watching this course
      1m 29s
    4. Getting the right tools for theme creation
      2m 50s
  2. 17m 2s
    1. What is a WordPress child theme and when should you use it?
      2m 38s
    2. Picking a parent theme
      3m 55s
    3. Making sure you have the Twenty Twelve parent theme
      1m 50s
    4. Creating and activating a basic child theme
      4m 20s
    5. Importing parent theme styles
      4m 19s
  3. 16m 2s
    1. Using the developer tools
      3m 53s
    2. Modifying existing styles
      4m 24s
    3. Adding space between paragraphs
      4m 7s
    4. Changing font family styles
      3m 38s
  4. 31m 47s
    1. Understanding the WordPress template hierarchy
      3m 12s
    2. Modifying existing templates
      2m 33s
    3. Moving the header image
      4m 29s
    4. Adding Related Posts feature to posts
      6m 26s
    5. Creating custom page templates
      5m 43s
    6. Using conditional statements for customized effects
      5m 41s
    7. Creating custom header, footer, and sidebar templates
      3m 43s
  5. 17m 5s
    1. Understanding the different index pages and what they do
      4m 6s
    2. Adding author, date, and time information to the index loop
      7m 15s
    3. Changing the appearance of category index pages
      5m 44s
  6. 43m 5s
    1. Introducing functions.php
      3m 24s
    2. Overriding existing functions
      3m 23s
    3. Adding pagination to index pages
      5m 49s
    4. Adding to existing functions
      3m 21s
    5. Adding a new footer menu to Twenty Twelve
      6m 24s
    6. Adding a new widgetized area to pages
      4m 9s
    7. Adding static content to the sidebar
      7m 44s
    8. Replacing existing functions
      2m 36s
    9. Adding a Google font through a function
      6m 15s
  7. 10m 24s
    1. Adding new featured image sizes
      5m 41s
    2. Adding featured images to posts and pages
      4m 43s
  8. 31m 1s
    1. Adding a welcome message to the front page
      1m 22s
    2. Displaying page content in an index page
      7m 42s
    3. Hooking in a featured image
      4m 34s
    4. Making the welcome message responsive
      6m 27s
    5. Restricting content to the first page of the blog
      4m 22s
    6. Adding a jQuery function to show or hide the welcome message
      6m 34s
  9. 10m 23s
    1. Adding a custom favicon
      3m 58s
    2. Adding a custom screenshot
      2m 29s
    3. Adding footer information
      3m 56s
  10. 7m 14s
    1. What to do when a child theme crashes your website
      4m 38s
    2. Updating parent and child themes
      2m 36s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed WordPress 3: Building Child Themes.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.