Embed a physical entity within another physical entity

On my webpage, I have 2 toggle buttons - "Leaderboard" and "MedalTally". The layout looks like this: https://i.sstatic.net/IohqA.png

Here are the codes for the above page:


*, *:before, *:after {
  box-sizing: border-box;
}

html {
  overflow-y: scroll;
}

body {
  background: #c1bdba;
  font-family: 'Titillium Web', sans-serif;
}

a {
  text-decoration: none;
  color: #1ab188;
  -webkit-transition: .5s ease;
  transition: .5s ease;
}
a:hover {
  color: #179b77;
}

<!-- More CSS code here -->



<!-- HTML code here -->


Additionally, here is the leaderboard code snippet:

https://i.sstatic.net/MiCXA.png


/* CSS code for leaderboard */

<!-- More CSS code for the leaderboard -->



<!-- HTML code for leaderboard -->


Now, the task is to insert the leaderboard (from the second picture) inside the first picture at the location "Display Leaderboard here".

When the user clicks on the "Leaderboard" tab in the first picture, the leaderboard should be displayed. The functionality for the "MedalTally" tab can be ignored for now.

If you have a solution to this issue, please kindly provide assistance.

Answer №1

Sure thing! You have a few options to achieve this - you can use bootstrap tab, Js tabs, or even create a custom jQuery code.

Give this a try: For example, add an id attribute to the leaderboard div just like the Login div:

<div class="leaderboard" id="leaderboard">

Then, hide the leaderboard div and use a custom jQuery code like this:

$('.tab a').on('click',function(e){
    e.preventDefault();
    var _this = $(this);
    var block = _this.attr('href');
    if(block == "#leaderboard"){
        $(block).fadeIn();
        $('#login').hide();
    }
    if(block == "#login"){
        $(block).fadeIn();
        $('#leaderboard').hide();
    }
});

Check it out live on Jsfiddle. I've used your code there for reference.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Updating the object does not result in the interpolation value being updated as well

I am facing an issue with this v-for loop: <tr v-for="(product, index) in products" v-bind:key="products.id"> <div v-on:click="decrementQtd(index)" class="action-qtd-button-left"> <strong>-</strong> </div> < ...

JSON string inside a string-type in AWS model

My goal is to create a basic model that can accept a JSON string instead of defining all variables/elements upfront. The model will have an "options" element which will hold a JSON string. Below is the structure of my model. { "$schema": "http://json-sch ...

Using MySQL to format queries - Defining the column results as the header of a table

I have a task of creating a report in MySQL that displays the number of Traded Shares by Client and Market. Although I have managed to retrieve the desired results from multiple tables, I am facing a challenge in transforming the output table to have the ...

Using jQuery to send a post request to a servlet and then refreshing the parent

As I dive into the world of ajax jQuery documentation, my goal is to send a post call to a servlet that I have created in order to save an entry in my database. Once the post is successful, I aim to reload the parent of the iFrame responsible for rendering ...

Animating drop-right feature in a horizontal navigation menu

I want to design a horizontal menu with an animated effect that activates when hovering over first-level items. Here is the code snippet: .nav { float: right; } .nav ul { list-style: none; padding: 0; margin: 0; } .nav ul li { position: relat ...

Controlling numerous websockets using React

I am currently developing a single-page application using React.js with a JSON RPC 2.0 backend API that relies on websockets. Managing multiple websocket connections simultaneously across different React.js components has been a challenge. Initially, I th ...

What is the best way to utilize jQuery in order to present additional options within a form?

Let's consider a scenario where you have an HTML form: <form> <select name="vehicles"> <option value="all">All Vehicles</option> <option value="car1">Car 1</option> <option value="car2">Car 2< ...

Converting integer data to string in CodeIgniter's Datatables: a step-by-step guide

I am working on an application using the CodeIgniter framework with Ignited Datatables as the table libraries for server-side functionality. I want to create a table and have written the code in the CodeIgniter controller, like this: $this->datatables- ...

Optimal practices for naming divs in XHTML/CSS

Is it acceptable to use spaces in div names like this? <div class="frame header">Some content here</div> Having a space in the name might require separate CSS classes such as: .frame { display: block; } .header { background-color: #efefef; } ...

Is Sending an Object to a Function in the Same Scope Inefficient?

Is there a noticeable delay when passing around an object within the same scope? Let's explore Option 1 and Option 2. In Option 1, we work directly with the object, while in Option 2 we follow better encapsulation practices. However, if we were to sti ...

Adding text after a div in React-JS using Bootstrap: A quick guide

Just starting out with website development and I have a question. As I practice making this website, I am struggling to figure out how to add the text "To know more about us click here" below the 'Get started' button. I tried adding a simple < ...

Sending Form Data to Server using AJAX

Hello everyone, I have encountered an issue with my code. I am unable to process the data to the back-end. When I enter data into the Register form and submit it, the data is not being passed. Instead, the page simply reloads. Could someone please help ...

Retrieving data from MongoDB and presenting it neatly in Bootstrap cards

I have successfully retrieved data from MongoDB and displayed it in Bootstrap 5 cards. However, I am facing an issue where all the cards are appearing in a single row if there are multiple entries in the database. What I want to achieve is to utilize the ...

Utilizing Angular to augment existing items in local storage

Hey everyone, I'm facing an issue with localStorage that I can't seem to figure out. I have a form where the first step collects name and gender, and the second step asks for weight and height. The data from step 1 is saved in localStorage, but ...

Displaying a blank column in a table using JavaScript

I am trying to write a JavaScript function that will add a new column to a table. I want this new column to be displayed at the index where it is added, and then hidden once the addition is complete. Here is the code for my method: function addColumnToTa ...

What is the most effective way to delete a single value from a key with multiple values stored in local storage?

This question has come up before, but the solutions provided didn't work for me, which is why I am asking it again. Currently, I am storing values in an array that is then stored in local storage. Here is the object: data.items - 0: {id: 190217270, ...

Creating a hierarchical data structure in MongoDB by defining parent-child relationships and efficiently retrieving the stored information

Looking for assistance in designing and retrieving data from MongoDB. The goal is to create a category schema where each category can have multiple child categories, and each child category can have further child categories and so on. In MySQL, the design ...

Navigating Between Pages with Parameters in Ionic 2 (starter app)

I have an Ionic 2 project with a blank template containing a page that displays a list. Upon clicking on an item in the list, the user should be able to view more details about that specific item. Below are the files related to the list: list.html: <i ...

Issue with unit testing a ViewportRuler in Angular 2 Material Library

I am currently working on an Angular2 component that includes a tab control from @angular/material. During testing of my component (refer to the simplified code below), I encountered the following error: Error: Error in ./MdTabHeader class MdTabHeader - ...

I'm perplexed by the inner workings of infinite ajax scroll in fetching additional posts

As someone who is new to JavaScript, I find it challenging to grasp the concept, especially when incorporating it with HTML. Despite this, I decided to experiment with infinite ajax scroll functionality. Below is my code snippet: var ias = jQuery.ias({ ...