Tabs not showing on smaller screens - react-bootstrap

I am building a React-Bootstrap page and I want a 3 column layout on big screens, but on smaller screens I want to shift it to tabs showing one column at a time based on the selected tab. On larger screens I indeed get the desired results, but on the smaller screens I can only see my tabs and the content column while the other columns stay hidden.
I have tried several attempts at various className modifiers but none of them seem to work properly.
class HomePage extends Component {
render() {
return (
<Container id='homepage_container' fluid='true'>
<ul className='nav nav-tabs d-md-none' role='tablist'>
<li className='nav-item'>
<a className='nav-link active' href='#controls-col' aria-controls='controls-col' data-toggle='tab' role='tab'>Controls</a>
</li>
<li className='nav-item'>
<a className='nav-link' href='#content-col' aria-controls='content-col' data-toggle='tab' role='tab'>Content</a>
</li>
<li className='nav-item'>
<a className='nav-link' href='#related-content-col' aria-controls='related-content-col' data-toggle='tab' role='tab'>Related</a>
</li>
</ul>
<Row id='homepage_main_row' className='tab-content'>
<Col id='controls-col' className='homepage_col tab-pane active' role='tabpanel' md={3}>
<Row float='left'>
<p>This is the controls</p>
</Row>
</Col>
<Col id='content-col' className='homepage_col tab-pane' role='tabpanel' md={6}>
<Row className='justify-content-center'>
<p>This is the Content Panel</p>
</Row>
</Col>
<Col id='related-content-col' className='homepage_col tab-pane' role='tabpanel' md={3}>
<Row className='float-right'>
<p>This is the related Content Panel</p>
</Row>
</Col>
</Row>
</Container>
)
}
}
And the accompanying scss to modify based on screen size:
#media(min-width: 768px) {
.tab-content > .tab-pane {
display: block;
}
}
My expected outcome should be that the smaller screens show the tabs as full width elements based on the tab selected. Yet I still only get the tabs display showing up with the content-col, but cannot switch. When I click the other tabs I can see the href update in the url bar which indicates they are triggering, but for some reason they are not toggling the 'active' class between the tabs properly.

Your problem is, you are writing active for all nav-link,
<ul className='nav nav-tabs d-md-none' role='tablist'>
<li className='nav-item'>
<a className='nav-link active' href='#controls-col' aria-controls='controls-col' data-toggle='tab' role='tab'>Controls</a>
</li>
<li className='nav-item'>
<a className='nav-link active' href='#content-col' aria-controls='content-col' data-toggle='tab' role='tab'>Content</a>
</li>
<li className='nav-item'>
<a className='nav-link active' href='#related-content-col' aria-controls='related-content-col' data-toggle='tab' role='tab'>Related</a>
</li>
</ul>
For initial render you must have only 1 nav-link as active, so remove the active from other nav-link except first one like,
<ul className='nav nav-tabs d-md-none' role='tablist'>
<li className='nav-item'>
<a className='nav-link active' href='#controls-col' aria-controls='controls-col' data-toggle='tab' role='tab'>Controls</a>
</li>
<li className='nav-item'>
<a className='nav-link' href='#content-col' aria-controls='content-col' data-toggle='tab' role='tab'>Content</a>
</li>
<li className='nav-item'>
<a className='nav-link' href='#related-content-col' aria-controls='related-content-col' data-toggle='tab' role='tab'>Related</a>
</li>
</ul>

Related

Accessibility error with headings out of order in mega menu. They appear above the h1 but need to use h2 to provide context to the ul

How should you handle h tags in the main menu of your site if the main menu renders above the h1?
Is it ok to break heading hierarchy in this case to provide the additional semantics / hierarchy, or should a different element be used instead of heading tags?
For example:
You have menu that shows a secondary menu on hover / focus / click.
It uses a checkbox input to indicate the state of the menu so as to allow the menu to stay open.
The secondary menus use h2 > ul >li > a to organize and provide additional hierarchy to the overall menu.
Third level link lists follow the heading hierarchy, eg., h3 > ul > li > a
CodePen link for more clarity :: https://codepen.io/uxmfdesign/pen/yLBrMmd
<header>
<div class="main-menu__container">
<input
class="main-menu__toggle webaim-hidden"
type="checkbox"
id="main-menu-toggle-block-main-menu">
<!-- toggle open close -->
<label
class="main-menu__label"
for="main-menu-toggle-block-main-menu"
aria-label="Toggle Main menu"
>
Main menu
</label>
<nav class="main-menu__nav">
<div
class="main-menu-group"
data-main-menu-group="">
<!-- toggle open close of menu section -->
<input
id="main-menu-group-toggle-block-main-menu-0"
type="checkbox"
name="main-menu-group"
class="main-menu-group__toggle webaim-hidden"
data-main-menu-group-toggle="">
<label
for="main-menu-group-toggle-block-main-menu-0"
aria-label="Open Our services"
aria-haspopup="true"
data-icon=""
class="main-menu-group__toggle-label">
Section title
</label>
<div class="main-menu-group__wrapper">
<h2 class="main-menu-group__heading">
<span>Section title</span>
</h2>
<ul class="main-menu-nav-list">
<li class="main-menu-nav-list__item">
<h3 class="main-menu-nav-list__title">
<a class="main-menu-nav-list__title-link" href="/ca-domains">
Sub-section title
</a>
</h3>
<ul class="main-menu-subnav-list__menu">
<li class="main-menu-subnav-list__item main-menu-subnav-list__item--with-sub">
<a class="main-menu-subnav-list__link" href="/ca-domains/register-your-ca">
sub-page name
</a>
</li>
<li class="main-menu-subnav-list__item">
<a class="main-menu-subnav-list__link" href="/ca-domains/optimize-your-ca">
sub-page name
</a>
</li>
</ul>
</li>
<li class="main-menu-nav-list__item">
<h3 class="main-menu-nav-list__title">
<a class="main-menu-nav-list__title-link" href="/ca-domains">
Sub-section title
</a>
</h3>
<ul class="main-menu-subnav-list__menu">
<li class="main-menu-subnav-list__item main-menu-subnav-list__item--with-sub">
<a class="main-menu-subnav-list__link" href="/ca-domains/register-your-ca">
sub-page name
</a>
</li>
<li class="main-menu-subnav-list__item">
<a class="main-menu-subnav-list__link" href="/ca-domains/optimize-your-ca">
sub-page name
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div
class="main-menu-group"
data-main-menu-group="">
<!-- toggle open close of menu section -->
<input
id="main-menu-group-toggle-block-main-menu-0"
type="checkbox"
name="main-menu-group"
class="main-menu-group__toggle webaim-hidden"
data-main-menu-group-toggle="">
<label
for="main-menu-group-toggle-block-main-menu-0"
aria-label="Open Our services"
aria-haspopup="true"
data-icon=""
class="main-menu-group__toggle-label">
Section title
</label>
<div class="main-menu-group__wrapper">
<h2 class="main-menu-group__heading">
<span>Section title</span>
</h2>
<ul class="main-menu-nav-list">
<li class="main-menu-nav-list__item">
<h3 class="main-menu-nav-list__title">
<a class="main-menu-nav-list__title-link" href="/ca-domains">
Sub-section title
</a>
</h3>
<ul class="main-menu-subnav-list__menu">
<li class="main-menu-subnav-list__item main-menu-subnav-list__item--with-sub">
<a class="main-menu-subnav-list__link" href="/ca-domains/register-your-ca">
sub-page name
</a>
</li>
<li class="main-menu-subnav-list__item">
<a class="main-menu-subnav-list__link" href="/ca-domains/optimize-your-ca">
sub-page name
</a>
</li>
</ul>
</li>
<li class="main-menu-nav-list__item">
<h3 class="main-menu-nav-list__title">
<a class="main-menu-nav-list__title-link" href="/ca-domains">
Sub-section title
</a>
</h3>
<ul class="main-menu-subnav-list__menu">
<li class="main-menu-subnav-list__item main-menu-subnav-list__item--with-sub">
<a class="main-menu-subnav-list__link" href="/ca-domains/register-your-ca">
sub-page name
</a>
</li>
<li class="main-menu-subnav-list__item">
<a class="main-menu-subnav-list__link" href="/ca-domains/optimize-your-ca">
sub-page name
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
</div>
</header>
<main>
<h1>
The problem heading is here
</h1>
</main>

How to show an ul when a particular li is clicked using jquery?

I want to show the ul class of li which is clicked.
My html is:
<ul id="level1" class="category">
<li class="level1 inactive">
abc
<ul id="level2" style=" display:none;">
<li class="level2 inactive">Level2</li>
<li class="level2 inactive">Level2</li>
<li class="level2 inactive">Level2</li>
</ul>
</li>
<li class="level1 inactive">
xyz
<ul id="level2" style=" display:none;">
<li class="level2 inactive">Level2</li>
<li class="level2 inactive">Level2</li>
<li class="level2 inactive">Level2</li>
</ul>
</li>
<li class="level1 inactive">
bcd
<ul id="level2" style=" display:none;">
<li class="level2 inactive">Level2</li>
<li class="level2 inactive">Level2</li>
<li class="level2 inactive">Level2</li>
</ul>
</li>
</ul>
the js which I use to show the ul is below:
<script>
var $j = jQuery.noConflict();
$j(function() {
$j('li.level1').click(function() {
$j(this).addClass("current").removeClass("inactive");
$j('ul#level2:visible').hide();
$j('ul#level2').toggle();
});
});
</script>
css:
ul.category li.level1.current a{background:url("../images/left_menu_new.png") no-repeat scroll 10px -285px transparent;}
.active{display:block;}
When I click the li.level1 current class design is added to every li of level1 , ul inside the selected li is opened and as it has anchor tag the page is redirected to the url inside the anchor tag .
What I want is when I click the li the current class should be added only to the selected li & the page of respective url in the anchor tag should be opened and ul of selected li should be opened there.
Kindly guide me to resolve this issue.
For you to achieve this, you will have to take advantage of location hash.
Do the following :
On your anchor tags, that toggle your ul, add href to a dummy unique value. Make sure the value is same as the id of the li you are in.
<ul class="level0">
<li class="level1" id="li1">
Toggle.1
<ul class="level1" style="display:none;">
When ever page loads, read window location hash.
var li = window.location.hash;
If hash is found, show the related ul.
if(li!=""){
$(li + " ul").show();
}
This way you will be able to show the last opened ul by the user.
$(function() {
var li = window.location.hash;
if (li != "") {
$(li + " ul").show();
}
$('li.level1 a').click(function() {
$(this).parent().siblings().each(function() {
$(this).find("ul.level1").hide();
});
$(this).siblings("ul.level1").show();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<ul class="level0">
<li class="level1" id="li1">
Toggle.1
<ul class="level1" style="display:none;">
<li class="level2">Level2.1
</li>
<li class="level2">Level2.1
</li>
<li class="level2">Level2.1
</li>
</ul>
</li>
<li class="level1" id="li2">
Toggle.2
<ul class="level1" style="display:none;">
<li class="level2">Level2.2
</li>
<li class="level2">Level2.2
</li>
<li class="level2">Level2.2
</li>
</ul>
</li>
<li class="level1" id="li3">
Toggle.3
<ul class="level1" style="display:none;">
<li class="level2">Level2.3
</li>
<li class="level2">Level2.3
</li>
<li class="level2">Level2.3
</li>
</ul>
</li>
</ul>

Making the Dropdown title in the nav clockable option

I'm using the getbootstrap code for default navbar.
I want the title name of Drop-down (Test2) also to link to a html page. I added the linkage for the href, however when I'm running the page and clicking on the Drop-down text (Text2) nothing happened
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<a class="navbar-brand">Test</a>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="navbar-header" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Home <span class="sr-only">(current)</span></li>
<li>test1</li>
<li class="dropdown">
Test2 <span class="caret"></span>
<ul class="dropdown-menu">
<li>Test21</li>
<li>Create Test22</li>
<li>Test23</li>
</ul>
</li>
<li>Test3</li>
<li>Test4</li>
</ul>
</div>
</div><!-- /.container-fluid -->
</nav>

my drop down menu is horizontal. i need it vertical

please help me i cant make my drop down list vertical. when I hover over a list it is horizontal.
my html code
<div id="header">
<div>
<img src="logo.png" alt="LOGO" height="115" width="115px" />
<ul id="navigation">
<li class="active">
Home
</li>
<li>
What We Offer
</li>
<li>
Solutions
<ul>
<li>
Inbound
</li>
<li>
Outbound
</li>
</ul>
</li>
<li>
About
</li>
<li>
Contact Us
</li>
</ul>
</div>
</div>
css
I can't see your CSS, but did you apply display: inline to both the top-level AND sub-level menu items? This will cause the problem you describe.
The top-level li items should be display: inline, but their children should be display: block.
See this example: https://jsfiddle.net/tLqrrfy0/

Zurb Foundation Two Top Bars

I am fairly new to using Zurb so I was wondering if someone could shed some light for me.
http://www.bitandpiecesvape.co.uk/
This is my website currently (not running Zurb). I am trying to remake this in Zurb but I am having trouble creating two top bars.
As you can see in the link I have the 5 links in the dark blue bar under the banner, and then the categories in the lighter blue area below it. How can I make it so that these will display as they do in the link, but on resizing the browser to small they should all compile into a dropdown menu.
I have tried with the code below, and it does work... But the second menu just floats a little below it. I have tried seperating the two menus using a div row class but it stops the whole thing working... Obviously I need it to be on two rows so I can position the second menu properly below it.
I apologise that I can't upload a current version of my Zurb template, but I am running all this offline on my laptop at the moment because I am having trouble with my FTP.
Any thoughts???
Thank you.
<div style="width: 100%; height: 100px; background: #0d233c">
<div class="row">
<nav class="top-bar" data-topbar role="navigation">
<ul class="title-area">
<li class="name">
<h1>
<span class="show-for-small-only"><B>Bitandpieces Vape</B></span>
</h1>
</li>
<!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone -->
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="left" style='height: 100%'>
<li class="active">Home</li>
<li class="active">Shipping & Postage</li>
<li class="active">Product Support</li>
<li class="active">Contact Us</li>
<li class="active">About Us</li>
</ul>
</section>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="left" style='height: 100%'>
<li class="active">Home</li>
<li class="active">Shipping & Postage</li>
<li class="active">Product Support</li>
<li class="active">Contact Us</li>
<li class="active">About Us</li>
</ul>
</section>
</nav>
</div>
</div>
Create the two top bars with separate instances of topbar rather than adding sections should solve the issue with the navs stacking properly if that is ultimately what you choose to use for this.
<nav class="top-bar" data-topbar role="navigation">
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="left" style='height: 100%'>
<li class="active">Home</li>
<li class="active">Shipping & Postage</li>
<li class="active">Product Support</li>
<li class="active">Contact Us</li>
<li class="active">About Us</li>
</ul>
</section>
</nav>
<nav class="top-bar" data-topbar role="navigation">
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="left" style='height: 100%'>
<li class="active">Home</li>
<li class="active">Shipping & Postage</li>
<li class="active">Product Support</li>
<li class="active">Contact Us</li>
<li class="active">About Us</li>
</ul>
</section>
</nav>
I would also suggest sticking with the foundation grid system and separating out the top banner section completely in it's own row and avoiding those height:100 styles. The site will be responsive and behave well as long as you use all of he built in classes for Foundation.

Resources