Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think what you're trying to achieve has to be done with Javascript...just to make sure I know what you're asking:</p> <ul> <li>You have a bar that when you hover over a link in your navigation, it animates to the active anchor and is the same size as the anchor.</li> </ul> <p>Here's the fiddle I created to demonstrate what I think you're asking:</p> <p><a href="http://jsfiddle.net/Dm9Eu/2/" rel="nofollow">http://jsfiddle.net/Dm9Eu/2/</a></p> <p>If you take a look at your browser's web inspector when you visit Fully Illustrated, you'll see that the navigation has a gutter element that contains a span#highlight that is the full width of the navigation ul that contains the anchors.</p> <p>When you hover over an anchor, the left position changes of the span#highlight.</p> <p>You could use javascript to setup a function that on hover, get the left position of the anchor, set that position on span#highlight and using css3 you could set transition to 'left', and it should emulate your desired effect.</p> <p>HTML:</p> <pre><code>&lt;div id="header"&gt; &lt;ul id="menu"&gt; &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Portfolio&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="gutter"&gt; &lt;span id="highlight"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>#header { position: relative; } #menu { width: 100%; height: 120px; background: #181818; list-style: none; margin: 0; padding: 0; } #menu li { margin: 0; padding: 0; float: left; } #menu li a { color: #FFF; margin: 0; padding: 50px; display: block; } #highlight { position: absolute; top: 0; left: 0; height: 5px; background: #f00; transition: all .5s; } </code></pre> <p>JS:</p> <p>var doc = document;</p> <pre><code>var anchors = doc.getElementById('menu').getElementsByTagName('a'); var highlight = doc.getElementById('highlight'); for(var i = 0, len = anchors.length; i &lt; len; i++) { anchors[i].addEventListener('mouseover', function(e) { var target = e.target; highlight.style.width = target.offsetWidth + 'px'; highlight.style.left = target.offsetLeft + 'px'; }); anchors[i].addEventListener('mouseout', function(e) { var target = e.target; var storeNeg = '-' + highlight.style.width; console.log(storeNeg); highlight.style.left = storeNeg; }); } </code></pre> <p>Just a few notes:</p> <ul> <li><p>I did this with vanilla JS, so if you're concerned with browser compatibility, you might use a library like jQuery &lt;= 1.9.</p></li> <li><p>I would inject the gutter on the page with js, because if js is disabled, no need in having it.</p></li> </ul> <p>Hope that helps/answers your question!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload