07.04.2018 Views

Web_Designer_UK__May_2018

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

LightBox<br />

Brand Love Score<br />

Create an interactive navigation<br />

controlled image caption<br />

Employ the power of attributes to tell your story with the help of captions<br />

1. Get started<br />

The first step is to define the document architecture that<br />

will be used to present the page content. This consists of<br />

a definition of the HTML document, which stores a head<br />

and body section. While the head section is used to load<br />

the JavaScript and CSS resources, the body section is<br />

used to store the content created in step 2.<br />

<br />

<br />

<br />

Picture Caption Navigationr<br />

<br />

<br />

<br />

<br />

*** STEP 2 HERE<br />

<br />

<br />

2. Body content<br />

The page content consists of two child containers; an<br />

article container that stores a navigation and a figure for<br />

storing text corresponding to the navigation options. The<br />

navigation contains the interaction options, and each<br />

have a unique title attribute. The figure stores the caption<br />

text that corresponds to the equivalently positioned<br />

option located within the navigation container.<br />

<br />

<br />

Page 1<br />

Page 2<br />

Page 3<br />

<br />

<br />

Caption 1<br />

Caption 2<br />

Caption 3<br />

<br />

<br />

3. JavaScript listening<br />

Create a new file called 'code.js'. There’s a need to set the<br />

value of the article’s 'data-theme' attribute to match the<br />

navigation option being highlighted by the user.<br />

JavaScript will wait until the page has loaded, upon which<br />

it will find all of the navigation links in order to apply a<br />

'mouseover' event listener. This listener will update the<br />

article’s 'data-theme' attribute to match the hovered<br />

navigation option’s title attribute.<br />

window.addEventListener("load", function()<br />

{<br />

var nodes = document.<br />

querySelectorAll("[data-theme] nav > *");<br />

for(var i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!