While I navigate up and down using a mobile device, my abilities chart remains fixed and does not vanish

const skillsLink = document.querySelector(".page-header li:nth-child(1) a");
const skillsClose = document.querySelector(".skills-close");
const windowOpened = "window-opened";

skillsLink.addEventListener("click", (e) => {
  e.preventDefault();
  document.body.classList.toggle(windowOpened);
});

skillsClose.addEventListener("click", () => {
  document.body.classList.toggle(windowOpened);
});
.title {
  text-align: center;
  margin: 10px;
  font-family: 'Mansalva', cursive;
}

/* Define color variables */
:root {
  --black: #1a1a1a;
  --white: rgb(255, 255, 255) ;
  --red: #e93451;
  --transition-delay: 0.85s;
  --transition-delay-step: 0.3s;
}

/* Reset CSS Styles */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

ul {
  list-style: none;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  outline: none;
}

.d-flex {
  display: flex;
}


...
...

    <small class="position-absolute creator">Made with <span>❤</span> by <a href="http://georgemartsoukos.com/" target="_blank">George Martsoukos</a>
    </small>
  </section>
</body>
    <script src="script.js"></script>
  </body>
</html>

Seeking advice from experienced web developers as I explore the creation of a portfolio app. When clicking on the 'Skills' tab on mobile devices, it only moves instead of disappearing. How can I make the tab completely disappear when the X is clicked?--------------------------------------------------------------------------------------------------------------------------------------------

Answer №1

To hide and show your skill page (the page that appears and disappears), you should toggle the display property to none and block when the user clicks.

Here is a simple example I coded for you to better understand what I mean.

HTML:

<div id="change">Helllllllllo man</div>

<button type="button" onclick="change()">Change</button>

CSS:

.close{
  display: none;
}

JavaScript:

const change = () => {
  document.getElementById("change").classList.toggle("close")
}

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

Looking for a Horizontal Layout?

@foreach (var item in APModel) { <div class="row row-cols-1 row-cols-md-2 g-4"> <div class="col"> <div class="card" style="width: 18rem;"> <img src="h ...

Is it possible to retain various delimiters after dividing a String?

In the code below, the someString gets split into an array using specified delimiters in separators var separators = ['\\.', '\\(', '\\)', ':', '\\?', '!&apos ...

Unable to set selected property in React Material-UI menu item

One issue I'm facing is setting the selected prop using react mui menu item. In a multiple select menu list, there's a field called allValues that, when clicked, should toggle the selection of all menu items. The code for this functionality looks ...

Using dryscrape for web scraping: encountering an issue when selecting a radio button with CSS

I am attempting to extract data from a dynamically updated table on a webpage using dryscrape. The web page in question is located at . My code functions correctly with tables that are generated when the page is loaded initially. However, I now need to upd ...

Switch out the current R shiny htmlwidget data for updated data

Recently, I encountered an issue with a htmlwidget in one of my R shiny applications. Each time the widget render function was called multiple times, it failed to replace the existing data with new data. This bug caused the old data to linger and the new d ...

Swapping the identifiers in the array with the corresponding names from the second array

I am facing an issue with linking two arrays containing objects based on their id and then replacing that id with the corresponding NAME from a second array. For instance, consider the following arrays: array1 = [ {id: [1, 2], info: "xxx"}, {id: [2, 3 ...

Is it possible to retrieve the complete source HTML code of a webpage that is dynamically generated by JavaScript using Java and WebDriver?

I'm new to the world of programming and I've encountered a challenge that I need to overcome. I'm attempting to retrieve the HTML source code of a webpage using the Java / Webdriver method getPageSource(). However, the page seems to be dynam ...

JavaScript Canvas - Preserve Image Transparency

I have been trying to download a snapshot of a canvas using the code below: var strMime = "image/png"; var canvas = document.getElementsByTagName('canvas')[0]; var link = document.createElement("a"); link.href = canvas.toDataURL( ...

Unable to keep button contained within form's card design

Currently enhancing my Bootstrap skills and seeking assistance with a card and form alignment issue. Struggling to properly place a form within a card. Any suggestions or insights on resolving this? <div class="row row-content col-sm-8"> &l ...

instructions for creating a hover effect where one div vanishes when hovering over another div

Is there a way to make the line visible when hovering over my circular div? #line { display: none } <div id='circle'> <div id= 'line'> ...

The FB API does not request permission to manage_pages

When logging in as the user who created the app, they are prompted to grant both manage_pages and publish_stream permissions. However, when logging in as a different user, only the publish_stream permission is requested and granted; manage_pages access is ...

Tips for transmitting and utilizing information in ejs or jade with a node js server

I'm currently working on a project where I need to send data stored in localstorage from an ajax call to a node js server. The goal is to use the retrieved data to customize an html page using ejs or jade templates. I've attempted to send my data ...

Guide on comparing an object against an array and retrieving a specific output

If I were to create a data structure like this: const carObj = {"1234":"Corvette","4321":"Subaru","8891":"Volvo"}; And also have an array that contains the IDs: const myArray = [1234, 4321, 8891, ...

Steps to eliminate pre-chosen alternatives upon loading select control?

When using react-select with pre-selected options and multiple select enabled, the issue arises where clicking on the Select box still displays the already pre-selected options. How can I remove these duplicate options from the list? Below is a snippet of ...

What is the best way to display text from one text field onto another text field?

Here's a challenging question that I've been pondering... Issue: I am using a virtual keyboard that needs to interact with different text fields on various pages. Every time I click on a text field, the keyboard should appear, and every key I pr ...

Add several converted links as variables in each section

The title may not be the clearest, but I am facing a challenge with an ecommerce site that has unmodifiable HTML. My goal is to include additional links for each product displayed on a page showcasing multiple products. Each link should be unique to its re ...

Is it impossible to use CSS for absolute positioning of text?

I am currently learning CSS and HTML, as I'm working on a project for my final school assignment. My goal is to position the text "Welcome" absolutely within a specific div that I've created. However, despite multiple attempts, I can't seem ...

When you apply margins in CSS and HTML, it can cause elements to break out of the row alignment

I'm struggling with my html code that contains elements arranged in rows: <div class = "row"> <div class="col-sm-3 cont-box"> <h1>Title1<h1> </div> <div class="col-sm9 cont-box"> <img src="onepic.jpeg" class=" ...

What is the best way to add elements with two attributes to an array in JavaScript?

Imagine trying to create the array structure shown below programmatically using the push() function in JavaScript: var arr = [ {id: 1, txt: "First Element"}, {id: 2, txt: "Second Element"}, {id: 3, txt: "Third Element"} ]; My initial attempt was as follo ...

Updating deeply nested document in Mongoose

Is it possible to change the value of array1.array2.status, according to the schema provided below? const SomeSchema = new mongoose.Schema({ status: Boolean, array1: [{ array2[{ status: boolean }] }] }) ...