skip to Main Content

I hope someone can give some pointers on how to achieve navigation like khan academy for the video lessons (see screenshot: left-side navigation). I think I can do the hover effect (where the background of the hovered video title is highlighted with the brown color for example) – basically by using a :hover in css. however, I am not sure how to add that “play” sign, circle and lines you see. If i can figure this out with your help, I would also consider changing the “play” shape with a sequence number (1, 2, 3 etc.). The effect is nice because it shows the videos are connected in a series. I am using twitter bootstrap 3.3.5 for css.

Thanks!

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    I used Akorn's answer as a baseline to achieve what I needed. This was a nice exercise for me (new to css). I fiddled with the css and html, removed a bunch of properties that seemed to do nothing, and came up with a way to use this in a table instead of an un-ordered list - the way I need it: open (first item), line (throughout) then close (last item). Here's the fiddle. I hope this gets improved or reworked and if anybody does please update this page, thanks!

    CSS

    /******************************************
    
    Subway navigation (by sOltan stackoverflow.com)
    
    *******************************************/
    
    .subway-station {
      color: rgb(255, 255, 255);
      height: 100%; 
      width: 100px;
      position: relative;
    }
    
    .subway-open {
        top: 60px;      /* start with a margin from the top of the table cell */     
        height: 100%;   /* draw through the circled number */
        left: 40px;     /* indent this much */
        width: 10px;
        position: absolute; /* position relative to ancestor subway-station */
        z-index: 10;
        color: rgb(68, 68, 68);
        background: rgb(205, 205, 205) none repeat scroll 0% 0% / auto padding-box border-box;
    }
    
    .subway-close {
        top: 0px;       /* start from the top of the table cell */  
        height: 50px;   /* draw line this much from top */
        left: 40px;     /* indent this much */
        width: 10px;    /* width of the line */
        position: absolute; /* position relative to ancestor subway-station */
        z-index: 10;
        color: rgb(68, 68, 68);
        background: rgb(205, 205, 205) none repeat scroll 0% 0% / auto padding-box border-box;
    }
    
    .subway-line {
        bottom: 0px;    /* this indicates to start drawing line from the bottom */
        height: 100%;   /* draw all the way to the top of the table cell */
        left: 40px;     /* indent this much */
        width: 10px;
        position:absolute; /* position relative to ancestor subway-station */
        z-index: 10;
        color: rgb(68, 68, 68);
        background: rgb(205, 205, 205) none repeat scroll 0% 0% / auto padding-box border-box;
    }
    
    .number {
        font-family: 'Lato';
        z-index: 20;
        position: absolute;
        left: 0px;
    }
    
    .circled {
        display:inline-block;
        margin: 10px;
        border-radius: 50%;    
        padding: 10px 20px; 
        background: #fff;
        border: 8px solid #CDCDCD;
        color: #CDCDCD;
        text-align: center;
        font: 32px Arial, sans-serif;
        z-index: 20;
        position: absolute;
    }
    .circled:hover {
        background-color: #586CEF !important;
        color: white;
    }
    

    HTML

        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css">   
    
    <table class="table table-condensed task-table">
      <tbody>
        <tr class='active'>
          <td class="subway-station">
            <div class="subway-open"></div>
            <div class="circled number">1</div>
          </td>
          <td class="serie">
            <div>
              <h1>
                <a href="">The Alphabet Part 1</a>
              </h1>
              <p>In the beginning, there was A, B, C. Exposing yourself to foreign language can change the way you look at the world and create comprehensive avenues that would otherwise be unavailable.</p>
            </div>
          </td>
        </tr>
        <tr class='active'>
          <td class="subway-station">
            <div class="subway-line"></div>
            <div class="circled number">2</div>
          </td>
          <td class="serie">
            <div>
              <h1>
                <a href="">The Alphabet Part 2</a>
              </h1>
              <p>Domestic confined any but son bachelor advanced remember. How proceed offered her offence shy forming. Returned peculiar pleasant but appetite differed she. Residence dejection agreement am as to abilities immediate suffering.</p>
            </div>
          </td>
        </tr>
        <tr class='active'>
    
          <td class="subway-station">
            <div class="subway-line"></div>
            <div class="circled number">3</div>
          </td>
          <td class="serie">
            <div>
              <h1>
                <a href="">The Alphabet Part 3</a>
              </h1>
              <p>zzZZZZZZ Agreement distrusts mrs six affection satisfied.</p>
            </div>
          </td>
        </tr>
        <tr class='active'>
    
          <td class="subway-station">
            <div class="subway-close"></div>
            <div class="circled number">4</div>
          </td>
          <td class="serie">
            <div>
              <h1>
                <a href="">The Alphabet Part 4</a>
              </h1>
              <p>Sigh view am high neat half to what. Sent late held than set why wife our. If an blessing building steepest. Agreement distrusts mrs six affection satisfied. Day blushes visitor end company old prevent chapter.</p>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
    

  2. CSS Path and Circle can be used. Refrences here: http://www.w3schools.com/svg/svg_path.asp

    HOWEVER, Lets look at how Khan coded this UI Feature:

    I used SnappySnippet to extract just one line item.

    SnappySnippet is a DevTools extension that allows you to extract CSS
    and HTML from selected DOM subtree (last inspected element). Then,
    with just one click, you can send selected code to CodePen, jsFiddle
    or JS Bin.

    This generates a JS Bin that I only began to clean up and rename the generic jargon. Use this code to understand how the CSS generates these objects. Continue to clean up the code, then insert this sub-nav-item into a repeating list.

    enter image description here

    #li-container {
        background-position: 50% 100%;
        color: rgb(255, 255, 255);
        height: 80px;
        position: absolute;
        text-align: left;
        top: 0px;
        width: 40px;
        perspective-origin: 20px 40px;
        transform-origin: 20px 40px;
        background: rgba(0, 0, 0, 0) none repeat scroll 50% 100% / auto padding-box border-box;
        border: 0px none rgb(255, 255, 255);
        list-style: none outside none;
        outline: rgb(255, 255, 255) none 0px;
    }/*#DIV_1*/
    
    #line-top {
        top: 1px;
        color: rgb(255, 255, 255);
        height: 40px;
        left: 18px;
        position: absolute;
        text-align: left;
        width: 4px;
        z-index: 10;
        perspective-origin: 2px 21px;
        transform-origin: 2px 21px;
        background: rgb(104, 155, 81) none repeat scroll 0% 0% / auto padding-box border-box;
        border: 0px none rgb(255, 255, 255);
        list-style: none outside none;
        outline: rgb(255, 255, 255) none 0px;
        padding: 2px 0px 0px;
    }
    
    #line-bot {
        bottom: -1px;
        color: rgb(255, 255, 255);
        height: 40px;
        left: 18px;
        position: absolute;
        text-align: left;
        width: 4px;
        z-index: 10;
        perspective-origin: 2px 21px;
        transform-origin: 2px 21px;
        background: rgb(104, 155, 81) none repeat scroll 0% 0% / auto padding-box border-box;
        border: 0px none rgb(255, 255, 255);
        list-style: none outside none;
        outline: rgb(255, 255, 255) none 0px;
        padding: 2px 0px 0px;
    }
    
    #circle {
        background-position: 50% 100%;
        color: rgb(255, 255, 255);
        height: 25px;
        left: 8px;
        position: absolute;
        text-align: left;
        top: 40px;
        width: 25px;
        z-index: 20;
        perspective-origin: 12.5px 12.5px;
        transform-origin: 12.5px 12.5px;
        background: rgba(0, 0, 0, 0) url("https://www.khanacademy.org/images/progress-icons/subway-sprites-article-cs.svg") repeat scroll 50% 100% / 25px 75px padding-box border-box;
        border: 0px none rgb(255, 255, 255);
        font: normal normal normal normal 13px / 18px 'Proxima Nova Semibold', sans-serif;
        list-style: none outside none;
        margin: -12px 0px 0px;
        outline: rgb(255, 255, 255) none 0px;
        overflow: hidden;
    }
    
    /* if you develop this further, please share your progress with me, stack-user: 'akorn'*/
    <div id="li-container">
    	
    	<div id="line-top"></div>
    	<div id="circle"></div>
            <div id="line-bot"></div>
    </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search