Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make 2 level scrolling tab in CSS like this in HTML 5

Tags:

html

css

I need to make tabs like this which is having horizontal scroll and I'm using HTML 5 figure and figure caption

HTML example

<div class="footernav">
  <a href="javascript:void(0)">
    <figure> <img src="http://lorempixel.com/200/200/fashion/" class="fluid">
        <figcaption>
                <h3>Product Name</h3>
        </figcaption>
    </figure>
  </a>
</div>

CSS

.footernav {white-space;no-wrap; padding-top: 0.2%; border-top: 1px solid white; overflow: auto; white-space:nowrap; padding-bottom: 1.9%;}
.footernav a { text-decoration: none; font-weight: bold; display: inline-block; padding-right: 1.5%; padding-left: 1.5%; text-align: center; margin-top: 1.1em; overflow:hidden; }
.footernav figure:last-child { margin-right: 0; }
.footernav img { min-width: 118px; max-width: 118px; padding:3px;  }
figure{margin:0}
.footernav a:hover,
.footernav a.selected { border-top-left-radius: 15px;
border-top-right-radius: 15px; background:red}
.footernav h3 { color: #000; font-weight: 700; margin-top: 0; margin-bottom: 0.3em; font-size: 1.1em; text-transform: uppercase; margin-top:0.5em }

see here http://jsfiddle.net/jitendravyas/XnAsL/1/ (Link updated)

Now how to 2nd level and make it like the below picture?

Both level should scroll.

enter image description here

like image 794
Jitendra Vyas Avatar asked Dec 31 '11 08:12

Jitendra Vyas


People also ask

How do you make a tab scrollable in CSS?

The basic idea is to make the tabs themselves be inline-block , and have their container have overflow-x: auto . That will put a horizontal scrollbar on the container when the tabs get too big.

How do I change the scroll position in CSS?

We can use the CSS “::-webkit-scrollbar” property which is responsible for changing the shape, color, size, shade, shadow, etc. of the scroll bar. But, here the property which we will use is the direction property of CSS for changing the position of the scroll bar.

How do you make a horizontal overflow in CSS?

To enable horizontal scrolling, we can use the CSS property overflow-x. If we assign the value scroll to the overflow-x property of the container element, the browser will hide horizontally overflowing content and make it accessible via horizontal scrolling.

How do you make a scrolling list in HTML?

(1) List all of your items in individual div s. (2) Put all items into a containing div , and limit the height of that div to a fixed size. (3) Then, style the containing div to set overflow: scroll .


1 Answers

I just used a simplest logic i could think of.

Check the update of your fiddle here.

I just copied your div, gave them a common class to denote as sub item. Then used a rel attribute on the original link to show those boxes.

$(".link").click(function() {
    var rel = $(this).attr('rel');
    $(".subtabs").hide();
    $("#"+rel).show();
});

Update:

Since you want a CSS solution, in order to denote sub items the best(or only) way is too nest them inside. But your current markup pattern, will not allow it. as an inline element will contain a block element. Although this will be valid under HTML5 (which of course is still in experimental phase), does not render as expected (in fact the div will pop right out of the tag). So you have to change the markup style to something fit.

As per our discussion, this fiddle does what is needed.

Update II

Since you said, scripting will be done by someone else. A simple snippet will get the job the job done. A particular row will be selected and will remained selected when the user clicks it... You can check the fiddle of this here

$(".footernav > li").click(function() {
    $(this).toggleClass("selected");
});

P.S. Second row positioning is not working properly inside the fiddle's box. So you might have test in a seperate page.

like image 121
Starx Avatar answered Nov 15 '22 07:11

Starx