Align the "link text" vertically in the middle of the list item and resize the text to fit the list container proportionally

Hey there, I hope the title of my page makes sense!

I created a full-page navigation menu wrapped in a list as it should be... I think. Now, I have a few queries:

1. How can I vertically center the links within the list items?
2. Is it possible to make sure the text fits properly inside the list items when the viewport is scaled up or down?
3. And why are the changes I made to link:visited not showing?

Jquery solutions are welcome ;)

I've tried various online solutions like using vertical-align and wrapping links in paragraph tags or using display:table, but nothing seems to work for me.

Here's my code, I hope it's somewhat understandable (please don't laugh at my newbie coding style):

Greetings from Djlzz

You can check out the full site @ http://codepen.io/DJLZZ/pen/BeLHl to understand my coding logic visually :)

All kinds of help are appreciated

HTML:

    <div class="nav">
    <ul id="navsound">
        <li> <a href="index.html"       >     Home   </a> </li>
        <li> <a href="music.html"       >     Music  </a> </li>
        <li> <a href="about.html"       >     About  </a> </li>
        <li> <a href="pics.html"        >      Pics  </a> </li>
        <li> <a href="video.html"       >     Video  </a> </li>
        <li> <a href="guestbook.html"   > Guestbook  </a> </li>
        <li> <a href="agenda.html"      >    Agenda  </a> </li>
        <li> <a href="store.html"       >     Store  </a> </li>
        <li> <a href="contact.html"     >   Contact  </a> </li>
        <li> <a href="links.html"       >     Links  </a> </li>
    </ul>        

Css

.nav  {     
    z-index:10;
    display:block;
    position:absolute;
    height:75%;
    width:90%;
    margin-top:0.5%;
    margin-left:5%;
    margin-right:5%;
    margin-bottom:2%;
}

.nav ul { 
    display:block;
    height:100%;
    list-style-type:none;
}

.nav li { 
    display:inline-block;
    height:9%;
    margin-bottom:0.5%;
    width:100%;
    float:left;
    clear:both;
    background:rgba(0, 0, 0, 0.33); 
}

.nav a:link {
    display:inline-block;
    height:100%;
    width:100%;
    cursor:pointer;
    color:#ff9900;
    text-decoration: none;
    text-align:center;
    vertical-align: middle;
}   

.nav a:hover{
    display:inline-block;
    background:rgba(0, 0, 0, 0.5);
    color: #ffffff;
    transform: scale(1.05,1);
    -ms-transform: scale(1.05,1); /* IE 9 */
    -webkit-transform: scale(1.05,1); /* Safari en Chrome */
    transition-property:transform;
    transition-duration:0.4s;
}

.nav a:visited {
    display:inline-block;
    color: #ff9900;
    background:rgba(0, 0, 0, 0.5) 
}

Thanks to all my fellow "Code-junkies"

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

Guide on using jquery to validate a form field against a json document

Hi there! I am looking for some guidance on how to create a form that only allows submission of values from a specific list stored in a JSON file. The JSON file contains data like {"1","2","3",......}. I have been searching high and low for a solution, but ...

The sidebar momentarily shrinks before expanding again when the page is loaded

There is a sidebar on my website that can expand or collapse when a button is clicked. I have successfully saved its state in the localStorage, but there is a small issue that I need help with. When the page loads and there is no saved state in the localS ...

Can you explain the distinction between using inline-block and inline-table display properties?

It appears that these display selectors are indistinguishable based on my assessment. According to the Mozilla CSS documentation: inline-table: The inline-table value doesn't have a direct HTML equivalent. It functions like a <table> HTML elem ...

File-loader mistakenly generates 2 images and associates them with the incorrect one

I have encountered an issue with file-loader where it is creating two separate images in my build folder. One image is named correctly and saved in the correct path, while the other one is named [hash].png (default) and is stored directly in the build dire ...

Tips for utilizing flexbox with lists in HTML

As I was building my portfolio page, I included 4 main subheadings: About, Resume, Blog, and Portfolio. To neatly organize these headings at the top center of my div, I decided to create an unordered list with a display inline property. This successfully ...

The process of deserializing JSON in an API function is successful when initiated from Visual Studio or a browser, but encounters issues when

In my VB project, I have the following class within an ASMX service: Public Class cName Public Property nameOrAlias As String Public Property nameType As String Public Property isVerified As String Public Property nameID As String Publ ...

Django is indicating that the path is not reachable

I've been struggling with a seemingly silly issue in my code. I can't figure out why it's not working properly. Here is the directory structure of my Django Project: https://i.sstatic.net/0tVo4.png The HTML file I'm targeting (index.h ...

Issue with Angular Datatable: Table data is only refreshed and updated after manually refreshing the page or performing a new search query

Having trouble updating Angular Datatable after selecting different data? The API response is coming in but the table data is not being updated. Can anyone suggest how to properly destroy and reinitialize the table for the next click? Below is a snippet ...

Choose the component in the event that we are unaware of its name

Can you help me with applying this code: $( "#prev ~ div" ).css( "border", "3px groove blue" ); I am unable to select #prev directly because in my code, I only have var myDiv = $(this).parent(); Is there a way to select all sibling elements that come af ...

The Kendo element's DataSource becomes null if accessed outside of a function

There is an issue with the behavior of Kendo MultiSelect's dataSource that I have noticed. When I trigger a function through an event on an element, such as a button click: function fillForm() { var ms = $("#selector").data('kendoMultiSelec ...

Creating dynamic websites with Razor C# programming

After attempting to integrate code from the Microsoft website into a project created with the "web application" template ASP.NET Core, it seems that the code is not functioning properly. The code in question is for a simple calculator designed to add two ...

The form reappears on the screen once the value has been successfully transferred to the PHP script through AJAX

My main challenge was sending data from an HTML form to PHP code to compare the selected value with database information and display the result. I managed to get everything working correctly, but now I am facing a peculiar issue where the drop-down box is ...

How can I retrieve the current page URL with Thymeleaf?

Trying to highlight the current element in the menu using Bootstrap and the "active" class, but unsure how to retrieve the value of the current page. Below is my navigation bar: <nav class="navbar navbar-expand-md sticky-top navbar-light bg-faded"> ...

Is there a way to update an array element by clicking on it?

I've come across mentions of using Ajax to achieve this, but I'm a bit unsure about how to incorporate it with the arrays while keeping the system functional. My goal is to update the values of $place and $title each time a user clicks the button ...

Randomly swap out background images in multiple divs using JavaScript

I want to create a script that changes the background image of several divs every 3000ms with a fadeIn/fadeOut effect. I have 4 divs, each with their own background image All images are sourced from one array How can I achieve this? Here is the link to ...

The nestedSortable plugin fails to detect elements once the HTML has finished rendering

If I add multiple elements to a nested sortable list, they automatically go to the root and can be dragged around normally. When I drag a parent element, the child moves along with it as shown in the image below. https://i.sstatic.net/l1l1m.png After savi ...

Struggling to establish a consistent header on every page in AngularJS

I've been attempting to implement a header that appears on all my pages using AngularJS. Here is the current setup I have: In my HTML file, I've included the following code: <html ng-app="webApp"> <script src="/vendor/angular.min.js"& ...

HTML: Base64 image not displaying properly due to incorrect height specification

I have a straightforward base64 image that I am having trouble with. The issue is that only the upper half of the image is displaying. If I try to adjust the height using the "style" attribute in the img tag: style="height: 300px;" it shows correctly. Ho ...

Angular - Slow rendering of views causing performance degradation

I am currently developing a cutting-edge Ionic Angular App. One of the pages in my app displays a spinner while waiting for data to be fetched from an API REST service. However, I'm facing an issue where even after the spinner disappears, it takes ar ...

Tips for coordinating external asynchronous JavaScript retrieval

Within my app.js file, I have the following code snippet: load(src) { var script = document.createElement('script'); script.src = src; script.async = true; document.head.appendChild(script); } for (var i=0; scripts.length; i++) { loa ...