The navigation bar and fixed floating contact bar now feature a click-to-open function that remains active, along with a font

I'm seeking assistance in making two adjustments to the navigation and floating fixed contact bar on my website:

  1. Changing the font to match the rest of the website
  2. Making it so that clicking opens and closes the navigation menu

This is the HTML code I have:

<!DOCTYPE html> 
<html lang="en"> 

<head> 
<link rel="stylesheet" type="text/css" href="CSS/index.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<title>Website Project</title>
<meta charset="utf-8"/> 
</head>
<body>
... (HTML code goes here)
</body>
</html>

This is the CSS styling I have:

(CSS code goes here)

Answer №1

The fonts problem you are encountering is specifically related to your menu selection:

#menu a:link, #menu a:visited
{
    display: block;
    font-family: Tahoma; /*The issue lies here*/
    font-size: 0.75em;
    font-weight: bold;
    text-align: left;
    text-decoration: none;
    color: #000;
    padding: 5px;
}

You have two options - either remove that line entirely or make it consistent with the following:

#menu a:link, #menu a:visited
{
    display: block;
    font-family: 'Roboto', Tahoma, Arial;
    font-size: 0.75em;
    font-weight: bold;
    text-align: left;
    text-decoration: none;
    color: #000;
    padding: 5px;
}

If you want the menu to stay open when clicked, consider using JavaScript or jQuery. Keep the hover state as is, but add a class like "show" to toggle on click.

As an example, in jQuery:

$('#menu li').click(function(){
  $(this).toggleClass('show');
});

Here's the accompanying CSS:

#menu li:hover, #menu li.show
{
    background-color: #ffd98a;
    border: 1px solid #000;
}
#menu li:hover ul, #menu li.show ul
{
    display: block;
}

Answer №2

To correct the font, make this adjustment in the CSS:

#menu a:link, #menu a:visited
{
    display: block;
    font-family: Tahoma;
    ...
#emergencycontact a:link, #emergencycontact a:visited
{
    display: block;
    font-family: Tahoma;
    ...

Change it to this:

#menu a:link, #menu a:visited
{
    display: block;
    font-family: 'Roboto', Tahoma;
    ...
#emergencycontact a:link, #emergencycontact a:visited
{
    display: block;
    font-family: 'Roboto', Tahoma;
    ...

For styling the contact menu using CSS (no JavaScript needed):

HTML

<aside>
  <ul id="emergencycontact">
    <li>
      <input type="checkbox" id="contact"/>
      <label for="contact" name="contact">Contact</label>
      <ul>
        <h3 class="heading">Emergency Contacts</h3>
        <h4>Assistance Phones</h4>
        ...

CSS

#emergencycontact li:hover,
#emergencycontact input:checked + label {
  background-color: #ffd98a;
  border: 1px solid #000;
}

#emergencycontact li:hover ul,
#emergencycontact input:checked ~ ul {
  display: block;
}

#emergencycontact input {
  display: none;
}

#emergencycontact label {
  display: block;
  padding: 5px; /* or whatever */
}

To keep the navigation menu open:

HTML

<ul id="menu">
    <li><a href="#">About</a></li>
    <li>
      <input type="checkbox" id="events-and-workshops"/>
      <label for="events-and-workshops">Events and Workshops</label>
      <ul>
        <li><a href="#">Upcoming Events</a></li>
        ...

CSS

#menu a:link,
#menu a:visited,
#menu label {
  display: block;
  font-family: 'Roboto', Tahoma;
  font-size: 0.75em;
  font-weight: bold;
  text-align: left;
  text-decoration: none;
  color: #000;
  padding: 5px;
}

#menu li:hover,
#menu input:checked + label {
  background-color: #ffd98a;
  border: 1px solid #000;
}

#menu li:hover ul,
#menu input:checked ~ ul {
  display: block;
}

#menu input {
  display: none;
}

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

Exploring the power of Express.js by utilizing local variables and rendering dynamic views

I am in the final stages of completing an application using node.js and express, even though I am still relatively new to them. Here's my situation: In my app.js file, I have declared a variable app.locals.webLang and set its initial value to "EN". T ...

Leveraging HTML5 as a standalone application with Deskshell integration for seamless connectivity to MySQL

Currently working on a compact HTML5 application with deskshell. I am seeking a way to connect JavaScript directly to a MySQL database without relying on PHP or any server-side language. Any suggestions? ...

What is the reason for the error message saying "The prefix 'h' for the element 'h:head' is not bound"?

Below is the xhtml code I have created: <html> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/> </h:head> <h:body> <view> <h:form> <br/> ...

Ways to display a vertical scrollbar within a select box

I'm currently working with an Angular select box and I'm looking to display a scroll bar if there are more than 5 data entries. <select class="form-control" data-ng-model='projectListData.appVersion' ng-selected ng-options="v.versio ...

Inconsistencies in table row border behavior

I created a table that allows users to set a marker on a specific row by adding a 5px border to the left side of the row. Interestingly, when the border is added to the first row, the table gets padded on the right by a few pixels. However, this padding d ...

Optimize your HTML with Meleze.web's ASP.NET MVC 3 Razor minification and compression features

I came across meleze.web on NuGet, which claims to remove extra white spaces in generated HTML results. However, after adding the necessary configuration to my web.config file and running the application, I have not seen any changes in the result. Are th ...

Centering Images Using CSS Floats

I've got this HTML code featuring images and titles: <div class="container"> <div class="box"><a href="#" class="catname"><img src="image1.jpg" class="thumb"><p>Title 1</p></a></div> <div class="box" ...

The z-index issue with Bootstrap modal is not being resolved on Firefox and Internet Explorer

I am encountering an issue with my bootstrap modal that includes a jquery datepicker. Specifically, the datepicker is styled as follows: .datepicker{ z-index:1000;} Interestingly, it functions perfectly on Google Chrome, displaying like this: However, ...

Utilizing CSS3 to perform multiple 3D rotations

I am attempting to rotate a face of a cube twice in order to have that face fall flat on one side. For reference, please see the illustration of my goal here: https://i.stack.imgur.com/kwO8Z.png I have included my current progress below, using a 45-deg ...

Centering numerous elements on all screen sizes and devices

Is there a way to align elements in the center of the screen both vertically and horizontally without specifying width and height for mobile and desktop views? How can I make it responsive so that it appears centered on all devices? .parent-container{ ...

Convert Jupyter notebook to an executable html file

Looking for a way to export a Jupyter notebook in HTML to get an executable version? Currently, I upload the notebook to a git repository and use binder to obtain its executable form. However, I want to directly upload the notebook to my website without ha ...

What is the best way to ensure that a bootstrap collapse feature is fully

How can I display the collapse button and text only on mobile devices while showing the uncollapsed content on desktop? I am considering using an example to display part of the text initially, with the rest revealed upon clicking a button. This method is ...

What's causing the text not to wrap when using float?

I've tried setting float:left for the image and float:right for the text, but the image is still overlapping the text. What I really want is for the text to wrap around the image - to be on the right side of the image at the beginning and below the i ...

What is the process for displaying a partial view upon clicking an image?

I am reaching out to you because I need some guidance. My goal is to design a webpage featuring 3 clickable images. Upon clicking an image, I want a specific partial view to display on the same page. If another image is clicked, all other partial views ...

What is causing the property to overflow when the tooltip is positioned absolutely there?

While browsing, I stumbled upon this "TryIt" link: https://www.w3schools.com/css/tryit.asp?filename=trycss_tooltip However, I found myself puzzled by... I understand the purpose of position:absolute;, but what confused me was why it wasn't displaying ...

Evolving fashion trends

I'm looking to dynamically change the style of my HTML element based on screen size, similar to this example: <p [ngStyle]="{'color': isMobile() ? 'red' : 'blue'}">Lorem Ipsum</p> The code above triggers a m ...

Maintain the values of radio buttons, dropdowns, and checkboxes using Javascript

When I click on a radio button, it activates a drop down menu. Upon selecting different values from the drop down, various checkboxes become visible. Now, I want to preserve the selection of the radio button along with the selected drop down values and ch ...

Spin around revolving object

Trying to figure out how to animate a solar system using SVG. I've got everything set up except for the moon rotating around Earth. Any suggestions on how to make it work? <svg viewBox="0 0 500 500"> <!-- sun --> <circ ...

Rearrange the sequence of floating elements

Below is the code for a series of divs div { float: left; width: 33.33%; height: 50px; } #container { width: 100%; } #title, #image, #descr { display: inline-block; } #title, #descr { float: right; } @media only screen and (max-width: ...

What could be causing the "keyframes method" in my css to not function correctly?

When working on the keyframes section, my computer seems to be having trouble recognizing the from part. Ideally, it should display in blue with the opacity command appearing in grey. Unfortunately, neither of these styles are appearing correctly and I&apo ...