User Tools

Site Tools


en:web_development:lists:menus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:web_development:lists:menus [2021/11/29 12:26]
mag created
en:web_development:lists:menus [2023/08/16 09:33] (current)
Line 1: Line 1:
-====== Web Development Lesson - Lists ======+====== Web Development Lesson - Lists ======
 ===== Menus ===== ===== Menus =====
 +==== Objectives ====
 +In this exercise you will display lists as menus, create links to other pages and learn some basic layout properties.
 ==== Setup ==== ==== Setup ====
   * In this activity, we're going to start building a web site.   * In this activity, we're going to start building a web site.
Line 12: Line 14:
 ==== Sidebar ==== ==== Sidebar ====
   * Many web sites use a sidebar for navigation or links. It's essentially a list of links, so a list structure is most effective.   * Many web sites use a sidebar for navigation or links. It's essentially a list of links, so a list structure is most effective.
-  * Let's create a list of the activities we've done so far. Add this code inside the <html><body></html> tags.+  * Let's create a list of the activities we've done so far. Add this code to 'menu.html' inside the <html><body></html> tags.
 <code>    <ul> <code>    <ul>
         <li>Funny Story</li>         <li>Funny Story</li>
Line 44: Line 46:
   * Try these links to make sure they work as expected. Then we'll look at creating lists dynamically.   * Try these links to make sure they work as expected. Then we'll look at creating lists dynamically.
  
-[[en:web_development:lists:javascript|Next: Javascript Lists]]+==== Block vs Inline ==== 
 +  * The other type of menu often used in web pages is across the page below the header. 
 +  * We can keep the list we've been using, but edit the CSS to make it look different. 
 +  * The first thing we need to do is to make the list horizontal. 
 +  * There are two basic modes for all HTML elements. 
 +  * Block elements stack vertically on top of each other. <html><h1></html>, <html><p></html> and <html><li></html> are all examples of block elements. 
 +  * Inline elements sit side by side horizontally. Examples include <html><strong></html>, <html><em></html> and <html><span></html>
 +  * These can be controlled, though, so you can make list items sit side by side. 
 +  * Add the following code to your 'style.css'
 +<code>li { 
 +    display: inline; 
 +}</code> 
 +  * <html>display</html> has many options that all present the element as either block or inline (or not shown) depending on the elements around them. By setting our list items <html>inline</html> we're telling them to display horizontally. 
 +  * Open your 'menu.html' in Live Server and check the results. 
 +  * If you're still seeing the bullets in your menu, it doesn't look as good, so let's remove them again. 
 +<code>ul { 
 +    list-style-type: none; 
 +}</code> 
 +  * Just for fun, let's make it look a little prettier. 
 +<code>ul { 
 +    list-style-type: none; 
 +    background-color: darkgoldenrod; 
 +    padding-top: 10px; 
 +    padding-bottom: 10px; 
 +
 + 
 +li { 
 +    display: inline; 
 +    border-right: solid 1px yellow; 
 +
 + 
 +a { 
 +    text-decoration: none; 
 +    color: #ccc; 
 +    padding: 10px; 
 +    font-weight: 700; 
 +    font-family: arial; 
 +}</code> 
 +  * You might not understand all these styles. We'll look at padding and borders in the next lesson on tables. Similarly, we'll look at different ways of specifying colours later in the course. 
 +  * Feel free to adjust some of these values to see what they do. 
 + 
 +==== Final Code ==== 
 +  * [[https://techschool.murraygunn.id.au/webdev/classes/proyecto/1/en.php|menu.html]] 
 +  * [[https://techschool.murraygunn.id.au/webdev/classes/proyecto/1/style.php|style.css]] 
 +  * [[https://techschool.murraygunn.id.au/webdev/classes/proyecto/1/menu.html|result]] 
 + 
 +[[en:web_development:lists:javascript|Next: Javascript]]
en/web_development/lists/menus.1638217586.txt.gz · Last modified: 2023/08/16 09:33 (external edit)