Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Best way to create ...

Featured Replies

Hi Guys,

 

I am wondering what the best way to create the following would be:

 

As seen in the picture (design), there are four 'tabs' on the left that control content in the main box to the right. I need to create it so that when one of the tabs is clicked, their respective content is shown in the box on the right and the tab arrow becomes 'active'.

 

You could say I am a novice in terms of coding, so don't feel bad about dumbing it down for me!

 

Many Thanks,

Ali

post-12504-0-01632700-1349785365_thumb.png

Hi Guys,

 

I am wondering what the best way to create the following would be:

 

As seen in the picture (design), there are four 'tabs' on the left that control content in the main box to the right. I need to create it so that when one of the tabs is clicked, their respective content is shown in the box on the right and the tab arrow becomes 'active'.

 

You could say I am a novice in terms of coding, so don't feel bad about dumbing it down for me!

 

Many Thanks,

Ali

 

Correct me if i'm wrong but you just want to change the main content box with the text of the smaller (left side) box that has been clicked on?

If so I would suggest you to use Javascript/Jquery to do this. Let me know here if i'm right and i'll help you coding it.

  • 2 weeks later...
  • Author

Correct me if i'm wrong but you just want to change the main content box with the text of the smaller (left side) box that has been clicked on?

If so I would suggest you to use Javascript/Jquery to do this. Let me know here if i'm right and i'll help you coding it.

 

Hi Jochemke,

 

I finally have the basics of the site up to start playing about with the coding for this tabbed box. Are you still able to help me with the coding of it?

 

http://silverfernfitness.co.uk

 

Many Thanks!

Ali

Try something like this:

 

Add to your js:

$('.tab').on('click', this, function(){
if (($(this).hasClass('tab-active')) {
 return;
}
$('.tab').removeClass('tab-active');
$('.box').removeClass('box-active');
$(this).addClass('tab-active');

if ($(this)).hasClass('tab-1') {
 $('.box-1').addClass('box-active');
} else if ($(this)).hasClass('tab-2') {
 $('.box-2').addClass('box-active');
} else if ($(this)).hasClass('tab-3') {
 $('.box-3').addClass('box-active');
} else {
 $('.box-4').addClass('box-active');
}
});

 

And add to your CSS:

.tab a:hover,
.tab-active {
background: url(images/tab-bg.png) 0px 100px;
}
.box {
display: none;
}
.box-active {
display: block;
}

 

Remove the visibility styles from the boxes and add a class of "tab-active" to the first tab and a class of "box-active" to the first box.

 

Can't test it but it should be close, at least.

 

Goodluck,

~evu.

  • Author

Try something like this:

 

Add to your js:

$('.tab').on('click', this, function(){
if (($(this).hasClass('tab-active')) {
return;
}
$('.tab').removeClass('tab-active');
$('.box').removeClass('box-active');
$(this).addClass('tab-active');

if ($(this)).hasClass('tab-1') {
$('.box-1').addClass('box-active');
} else if ($(this)).hasClass('tab-2') {
$('.box-2').addClass('box-active');
} else if ($(this)).hasClass('tab-3') {
$('.box-3').addClass('box-active');
} else {
$('.box-4').addClass('box-active');
}
});

 

And add to your CSS:

.tab a:hover,
.tab-active {
background: url(images/tab-bg.png) 0px 100px;
}
.box {
display: none;
}
.box-active {
display: block;
}

 

Remove the visibility styles from the boxes and add a class of "tab-active" to the first tab and a class of "box-active" to the first box.

 

Can't test it but it should be close, at least.

 

Goodluck,

~evu.

 

Thanks Evu!

 

Have put your code in. Will see how it turns out once the CSS updates (cheers Varnish Caching!). I have a feeling I may need you to tinker with it a little if you have the time. (But fingers crossed it works straight out!)

 

Thanks,

Ali

Should really tinker with it yourself dude, we help for free, not work for free :p

 

But there's a typo for starters, remove one of the brackets on the first "if" statement. You'll also need to wrap it in doc ready too.

$(document).ready(function() {
$('.tab').on('click', this, function(){
if ($(this).hasClass('tab-active')) {
return;
}
$('.tab').removeClass('tab-active');
$('.box').removeClass('box-active');
$(this).addClass('tab-active');

if ($(this).hasClass('tab-1')) {
$('.box-1').addClass('box-active');
} else if ($(this).hasClass('tab-2')) {
$('.box-2').addClass('box-active');
} else if ($(this).hasClass('tab-3')) {
$('.box-3').addClass('box-active');
} else {
$('.box-4').addClass('box-active');
}
});
});

 

Goodluck,

~evu.

Edited by evu

  • Author

Thanks Evu. It's only because I have such little knowledge of JS it'd be like a dog chasing it's tail round in circles all day.

 

:)

  • Author

Success! Sort of :)

 

I think I need to get rid of the anchor and fiddle around but hopefully we are pretty much there now!

 

Thanks Evu,

Ali

 

(hopefully you're free now :)

hehe, just looked and saw you changing it as I was refreshing :)

 

Glad you got it working!

 

Changing the anchors into something else is the way to go but just an FYI

nice site, dont forget to change the colour of the links at the bottom, and re-name the title :D

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.