New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

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

Styling the navigation links for small screens

From: Creating a Responsive Web Design

Video: Styling the navigation links for small screens

Right now, on our small screen device, our navigation links looks like text links. So what we're going to do is write some CSS properties to turn these into links that look more like mobile link buttons. So let's come back to our text editor. After our nav element, nav a, beginning and ending in bracket. Let's split that open. The first thing we're going to do is set the color. That's going to be #a6abc5;. Next, we're going to set display. We're going to set this to block. So, we want to have the anchor links on the small screen behave like blocks, so they'll be more like paragraph or div tags, rather than inline blocks or inline elements from the large screen.

Styling the navigation links for small screens

Right now, on our small screen device, our navigation links looks like text links. So what we're going to do is write some CSS properties to turn these into links that look more like mobile link buttons. So let's come back to our text editor. After our nav element, nav a, beginning and ending in bracket. Let's split that open. The first thing we're going to do is set the color. That's going to be #a6abc5;. Next, we're going to set display. We're going to set this to block. So, we want to have the anchor links on the small screen behave like blocks, so they'll be more like paragraph or div tags, rather than inline blocks or inline elements from the large screen.

Next property, we're going to set margin, 15 pixels for all sides. Let's hit a return. padding we're going to set 9 pixels for all sides. Next, we're going to set border. So border:, we're going to use shorthand style here, which is the size, then style, then color. So for the size it's going to be 1 pixel, hit a space, solid, space, #a6abc5;.

Let's hit a Return. We're going to set background, url beginning and ending parenthesis, ../images/mobile_link_arrow.png, space, set the repeat to no-repeat. Let's set the X property to right and the Y property to center. Now the next property we're going to create is going to be for rounded corners.

These are CSS3 properties, and some browser still require special flags until the CSS3 specification has been finalized. So we're going to target Mozilla and WebKit. Mozilla powers Firefox and WebKit powers Chrome, Safari, Android, and iOS devices. So let's start by typing -moz-border-radius: 12 px. Let's come in here and select and copy that entire property.

Let's hit a return. Let's paste on the next line and replace the moz with webkit. Let's hit a return. Let's paste that rule again, and let's remove the browser flags. So the final CSS3 property will be called border-radius, set to 12 pixels. Now, the next rule we're going to create is going to be for a hover state. So nav a:hover, beginning and ending bracket.

We're going to set color of the type to white, so #fff. Next we're going to set background-color and in here, instead of using a pound sign, we're going to use a color space called rgba. So let's type rgba, beginning and ending parenthesis. Inside the parentheses, we're going to specify the values for red, green, and blue, and the fourth property, which is the a, stands for alpha, or the amount of transparency. So to get white, we want to have 255 for the first value, comma, 255 for the second, 255 for the third.

So red, green, and blue are all set to their maximum values, which gives us white, then a comma, and then .15 for 15% alpha, or 85% transparent. Then outside the parentheses, we'll hit a semicolon. Let's save our work. Let's come back out to our browser. Let's hit Reload. Let's scroll down a little bit, and now we'll see that our anchor links have changed from looking more like text to now looking like mobile link buttons. Now, I do like to specify a hover state on my mobile links, for two reasons. One, if somebody condenses their browser down, like we're doing here, they can get the hover state with their mouse, and second, most touch devices will activate the hover state when somebody taps on that individual link. So this will give the users feedback that they've actually tapped on a specific link.

So now that our navigation is positioned and styled for small screens, next we can work on the promo area.

Show transcript

This video is part of

Image for Creating a Responsive Web Design
Creating a Responsive Web Design

46 video lessons · 37048 viewers

Chris Converse
Author

 
Expand all | Collapse all
  1. 7m 39s
    1. Previewing the final project
      4m 0s
    2. About the exercise files
      1m 15s
    3. Exploring the software you'll need to complete this course
      49s
    4. Beginning your project
      1m 35s
  2. 3m 45s
    1. What to expect with Design view in Dreamweaver
      2m 1s
    2. Accessing code for HTML and CSS in Dreamweaver
      1m 44s
  3. 9m 19s
    1. Planning your layout
      2m 47s
    2. Adding the main HTML containers
      1m 47s
    3. Adding the promo containers
      31s
    4. Adding links and the copyright
      1m 47s
    5. Adding sample content into the HTML containers
      2m 27s
  4. 8m 37s
    1. Creating and slicing multiple-sized banner images
      5m 53s
    2. Exporting content and template artwork
      2m 44s
  5. 7m 27s
    1. Linking CSS files for all screen sizes
      1m 42s
    2. Linking CSS files based on screen size with media queries
      2m 13s
    3. Enabling Internet Explorer 7 and 8 to understand HTML5
      1m 25s
    4. Setting the viewport scale
      2m 7s
  6. 9m 0s
    1. Adding the background pattern and the page container color
      3m 43s
    2. Styling the headings
      2m 17s
    3. Styling the body text and the links
      1m 15s
    4. Styling the footer
      1m 45s
  7. 9m 49s
    1. Understanding compound rules
      2m 58s
    2. Styling the promo links with a CSS sprite
      2m 48s
    3. Styling the promo text
      1m 26s
    4. Adding the promo images with CSS
      2m 37s
  8. 7m 46s
    1. Adding CSS rules for layout
      2m 8s
    2. Styling the header on large screens
      2m 34s
    3. Styling the article on large screens
      3m 4s
  9. 6m 29s
    1. Styling the navigation links
      2m 1s
    2. Styling the navigation for large screens
      1m 16s
    3. Positioning the navigation for large screens
      1m 37s
    4. Clearing the float for the promos
      1m 35s
  10. 2m 47s
    1. Adding CSS rules with inline media queries
      2m 47s
  11. 6m 0s
    1. Styling the header for medium screens
      2m 32s
    2. Styling the navigation for medium screens
      1m 10s
    3. Styling the promos for medium screens
      2m 18s
  12. 12m 7s
    1. Styling the header for small screens
      2m 27s
    2. Styling the navigation for small screens
      1m 12s
    3. Styling the navigation links for small screens
      4m 13s
    4. Styling the promos for small screens
      2m 57s
    5. Styling the footer for small screens
      1m 18s
  13. 13m 12s
    1. Additional exercise files for this chapter
      1m 4s
    2. Creating double-sized graphics for high-definition screens
      4m 45s
    3. Replacing the promo graphics with CSS media queries
      2m 42s
    4. Replacing the logo and banner graphics with CSS media queries
      4m 41s
  14. 57s
    1. Where to go from here
      57s

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

Are you sure you want to delete this note?

No

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.