Надеюсь, приведенный ниже код поможет. Я прокомментировал места, где я вносил коррективы, но я также предоставил вам более чистую версию вашего кода, чтобы вы могли видеть, как он может выглядеть.
Кроме того, рассмотрите возможность использования CSS Grid, поскольку это может помочь уменьшить избыточность кода.
HTML / CSS Стиль
*{
margin:0;
padding:0;
box-sizing:border-box;
}
#Menu {
width:100%;
}
#Menu ul {
font-size: 100%;
list-style-type: none;
}
#Menu li {
display: inline-block;
width: calc(100%/4);
text-align: center;
padding: 16px 0px;
float: left;
border-right: 1px solid rgb(104, 99, 99);
background-color: rgb(77, 39, 21);
}
#Menu li:nth-child(1){
border-left: 5px solid red;
}
#Menu a {
color: rgb(187, 180, 180);
text-decoration: none;
font-size: 100%;
}
<!--end snippet-->
<!-- begin snippet: js hide: false console: true babel: false -->
<link rel="stylesheet" type="text/css" href= "StylesheetQ.css">
<div id="Menu">
<ul>
<li><a class="active" href="Main Page.html">Home</li></a></li>
<li><a href="About.html">About</li></a></li>
<li><a href="Contacts.html">Contacts</li></a></li>
<li><a href="Testimonials.html">Testimonials</li></a></li>
</ul>
</div>
HTML / CSS - с комментариями
*{
margin:0; /* zero-out MARGINS and PADDING */
padding:0;
box-sizing:border-box; /* helps keep dimensions of any block elements when they resize */
}
#Menu {
/* don't target the Menu as a whole
unless you want ALL the children to
have the same traits you intend for
your menu items (e.g. if you want menu
items to be 25px as well as P elements
throughout the contents of the div)*/
width:100%; /* assuming you want it to expand the entire width of the window*/
/* width:800px; <------ use this method if you want a FIXED size */
}
/* CSS for the Menu background */
#Menu ul {
font-size: 100%; /* Font size of 25 px */
list-style-type: none;
}
/* CSS for Menu Edges*/
#Menu li {
display: inline-block; /*INLINE-BLOCK (otherwise each list item takes up the whole line)*/
width: calc(100%/4); /* 100% width DIVIDED by No. of Elements (list items) */
text-align: center;
float: left; /* Menu is floated to the Left to make it all in one line */
border-right: 1px solid rgb(104, 99, 99); /* right border of ALL OTHER menu items. */
background-color: rgb(77, 39, 21);
padding: 16px 0px; /* the padding is added to each INLINE-BLOCK element (each list item) rather than the anchor (link)*/
}
#Menu li:nth-child(1){ /* left border of FIRST menu item. */
border-left: 5px solid red; /*made it RED so you could see how it works. ALSO because of BOX-SIZING: border-box, the border grows INWARDS rather than make the element larger*/
}
#Menu a {
color: rgb(187, 180, 180); /* Background colour of Text */
text-decoration: none; /* Makes sure there are no underlines */
font-size: 100%;
}
<link rel="stylesheet" type="text/css" href= "StylesheetQ.css">
<div id="Menu">
<ul>
<li><a class="active" href="Main Page.html">Home</li></a></li>
<li><a href="About.html">About</li></a></li>
<li><a href="Contacts.html">Contacts</li></a></li>
<li><a href="Testimonials.html">Testimonials</li></a></li>
</ul>
</div>