I have a problem with putting an img for hover background.
It should look like this : Navigation
These 2 lines, represent the hover transparent image, and the text "home" should be in center of that img.. I have no idea how to do that... Anyone ?
Sorry if my english is bad
.page-container {
width: 980px;
margin: 0 auto;
text-align: center;
}
header {
margin: 0;
padding: 0;
width: 100%;
height: 220px;
background-color: #EAEAEA;
}
.logo {
text-align: center;
}
.logo img {
margin: 30px 0 0 0;
}
nav {
height: 136px;
}
ul {
list-style-type: none;
display: inline-block;
margin: 70px 0 0 0;
padding: 0;
}
nav li {
float: left;
text-align: center;
}
nav li a {
margin-right: 165px;
text-decoration: none;
float:left;
font-size: 22px;
letter-spacing: 3px;
text-transform: uppercase;
font-family: font91477;
color: #9E9E9E;
background-size: 75px;
}
a:focus {
text-decoration: none;
color: #9E9E9E;
}
a:hover {
height: 75px;
text-decoration: none;
color: #9E9E9E;
background: url(http://i.imgur.com/P5tF09r.png) no-repeat center;
}
<header>
<div class="logo">
<img src="img/logo.png"/>
</div>
<nav>
<div class="page-container">
<ul>
<li>Home</li>
<li>O Podjetju</li>
<li>Produkti</li>
<li><a class="last-child" href="#">Kontakti</a></li>
</ul>
</div>
</nav>
</header>
just add the following css styles
a:hover {
height: 75px;
text-decoration: none;
color: #9E9E9E;
background: url(http://i.imgur.com/P5tF09r.png) no-repeat center;
/*****************here they are ************/
display:flex;
align-items: center;
}
Why you don't make it in css ? Something like this
.menu{
list-style: none;
background-color: #EAEAEA;
margin: 0;
padding: 20px 0;
overflow: hidden;
}
.menu__item{
float: left;
margin: 0 20px;
position: relative;
}
.menu__item a{
background-color: #EAEAEA;
text-transform: uppercase;
position: relative;
z-index: 1;
}
.menu__item::after{
content:'';
width: 1px;
height: 1px;
background-color: #000;
position: absolute;
top: 50%;
left: 50%;
margin: 0;
transform: rotate(-45deg);
z-index: 0;
transition: all .25s ease;
}
.menu__item:hover::after{
width: 50px;
margin: -1px 0 0 -25px;
}
<ul class="menu">
<li class="menu__item"><a>Home</a></li>
<li class="menu__item"><a>test</a></li>
<li class="menu__item"><a>very long title for test</a></li>
<li class="menu__item"><a>test</a></li>
</ul>
Related
The navbar I created overlaps when I switch my site to a mobile view.
I tried making it fit-content, but it still overlaps. The part that overlaps is the listed items
#navBar {
overflow: hidden;
text-align: center;
border-top: double black 2px;
}
#navBar ul {
padding: 0;
list-style: none;
width: fit-content;
}
#navBar li {
display: inline;
padding-top: 23px;
position: relative;
}
#navBar a {
font-size: 20px;
padding-right: 20px;
text-decoration: none;
text-align: center;
border: 4px solid lime;
padding-bottom: 10px;
padding-top: 20px;
padding-left: 10px;
font-family: American Typewriter, serif;
color: #262626;
text-transform: uppercase;
border-radius: 0px 0px 25px 25px;
}
#navBar a:hover {
color: lime;
}
#navBar a::before {
content: '';
display: block;
height: 5px;
width: 100%;
background-color: lime;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
#navBar::hover::before {
width: 100%;
}
<nav id="navBar">
<div class="bar">
<ul>
<li>Tab1</li>
<li>Tab2 </li>
<li> Tab3</li>
</ul>
</div>
</nav>
I expect the navbar items to be side by side but the actual result in them overlapping.
You can use inline-flex for that
change
#navBar ul {
padding: 0;
margin: 0; /* reset margin */
list-style: none;
width: fit-content;
}
#navBar li {
display: inline-flex; /* change to inline-flex and remove the padding */
position: relative;
}
#navBar {
overflow: hidden;
text-align: center;
border-top: double black 2px;
}
#navBar ul {
padding: 0;
margin: 0;
list-style: none;
width: fit-content;
}
#navBar li {
display: inline-flex;
position: relative;
}
#navBar a {
font-size: 20px;
padding-right: 20px;
text-decoration: none;
text-align: center;
border: 4px solid lime;
padding-bottom: 10px;
padding-top: 20px;
padding-left: 10px;
font-family: American Typewriter, serif;
color: #262626;
text-transform: uppercase;
border-radius: 0px 0px 25px 25px;
}
#navBar a:hover {
color: lime;
}
#navBar a::before {
content: '';
display: block;
height: 5px;
width: 100%;
background-color: lime;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
#navBar::hover::before {
width: 100%;
}
<nav id="navBar">
<div class="bar">
<ul>
<li>Tab1</li>
<li>Tab2 </li>
<li> Tab3</li>
</ul>
</div>
</nav>
I am trying to set up the footer, but I'm unable to remove the lines under the text. I also would like to change the color of the text. I tried using text decoration:none under .footer ul, but that was unsuccessful.
h2 {
text-align: center;
font-family: "Courier New";
color: beige;
font-size: 50px;
font-weight: 200;
text-shadow: -2px -2px black;
margin-bottom: -50px;
position: relative;
}
.head-link {
text-decoration: none;
color: aliceblue;
}
.head-link:hover {
margin: 20px auto 20px;
position: relative;
color: darkgoldenrod;
}
header {
background-image: url(https://i.imgur.com/xD3POCF.jpg);
position: absolute;
background-position: center;
max-width: 2000px;
width: 100%;
height: 100%;
top: 0;
background-repeat: no-repeat;
background-size: cover;
display: inline-block;
bottom: 40px;
}
.header-image {
background-size: cover;
}
.dropbtn {
background-color: transparent;
color: darkblue;
padding: 10px;
cursor: pointer;
font-family: monospace;
top: 0;
font-size: 15px;
width: 120px;
height: 50px;
border-color: black;
border-style: double;
align-content: center;
text-align: center;
margin-top: -10px;
}
.dropdown {
display: inline-block;
position: relative;
margin-left: 15px;
}
.dropdown-content {
padding: 12px;
position: absolute;
font-family: monospace;
background-color: transparent;
z-index: 1;
display: none;
min-width: 10px;
text-align: left;
left: 0;
}
.dropbtn:hover {
color: white;
}
.dropdown-content a {
color: #04116f;
padding: 12px 16px;
text-decoration: none;
display: block;
font-size: 13px;
}
.dropdown-content a:hover {
color: white;
}
.dropdown:hover .dropdown-content {
display: block;
text-decoration: underline;
}
.sidebar {
display: block;
position: relative;
top: -650px;
bottom: 0px;
left: -30px;
width: 120px;
padding: 10px;
background: transparent;
z-index: 0;
}
.sidebar ul {
cursor: pointer;
list-style: none;
color: white;
line-height: 2;
}
body {
margin: 0px;
top: 0;
width: 100%;
max-height: 10%;
background-image: url(http://i.imgur.com/yiMoYpV.jpg);
background-size: cover;
background-repeat: no-repeat;
background-position: 20px 50px center;
background-attachment: fixed;
}
.content {
display: block;
margin-right: 0px;
padding: 0px;
margin-bottom: 700px;
position: relative;
max-width: 1500px;
max-height: 500px;
}
p {
display: block;
padding: 40px;
position: relative;
max-width: 500px;
max-height: 500px;
width: 100%;
left: 50%;
height: 200px;
top: 120px;
font-family: monospace;
font-size: 15px;
line-height: 2;
margin-bottom: -70px;
color: goldenrod;
text-align: left;
}
.footer {
margin: 100px 0 0 0;
display: flex;
flex-flow: row;
justify-content: center;
padding-bottom: 2px;
align-content: space-between;
background: transparent;
overflow: hidden;
}
.footer ul {
text-align: center;
list-style: none;
display: inline-flex;
color: white;
text-decoration: none;
}
<!DOCTYPE html>
<html>
<header>
<h2 style="bottom: -130px">
<a href="#" class=h ead-link> A B E L</a>
</h2>
<div class="dropdown" style="float;right">
<button class="dropbtn">Menu</button>
<div class="dropdown-content" style="right;0">
About
Portfolio
Contact
</div>
</div>
<div class="title"></div>
<title>A B E L </title>
</header>
<body>
<div id="hl-content" class="content"></div>
<p>
<span style="color:navajowhite">
<b>Hello, Welcome to my website.</b>
</span>
<BR></BR>
My name is Abel, a senior college student currently residing in the Bay Area. This portfolio will give you a good background about me including my specialties, expertise and even hobbies. As you can probably tell from the background pictures, I like traveling
and taking photos!
</p>
<p>This is my first ever website that I created using HTML and CSS, and it's a pleasure to finally be able to share it with you. I am happy to receive any feedback, recommendations or opportunities from you, so don't hesitate to contact me.</p>
<div class="footer">
<ul>
<li> About</li>
<li>Portfolio</li>
<li> Contact </li>
</ul>
</div>
</body>
</html>
As you can see text decoration and color doesn't work.
How can I fix this?
.footer > ul > li > a {
color: white;
text-decoration: none;
}
Try this.
You need to style the links in your footer explicitly.
.footer ul a {
text-decoration:none;
}
You need to add this css :
.footer ul li a {
text-decoration:none;
}
I've tried my best, this might help as per your requirement(underline and color):
add this in your code,
.footer ul li a {
text-decoration: none;
color: tan;
padding: 5px;
}
.footer ul li a:hover {
text-decoration: underline;
}
appreciate if it is useful enough.
I'm having trouble with the header div of this website I'm making. There is padding or something appearing underneath my horizontal menu bar even though my padding is set to 0. I know that similar posts have been made about the but I have read quite a few and none of the answers seemed to do the trick for me. I have changed the background of the header div to yellow to make it more visible. There is also a pixel or two on either side of the menu bar which are unwanted. I'll put my css and html code below. screenshot
<div class="big header">
<img src="Images/headerphoto.jpg" alt="header_photo">
<div class="navbar">
<ul>
<li><a class="active" href="default.asp">Home</a></li>
<li>Contact</li>
<li>About Us</li>
<ul class="logo">
<li><a class="logo" href="http://www.linkedin.com"><img alt="in" src="Images/linkedinlogo.png"></a></li>
<li><a class="logo" href="http://www.facebook.com"><img alt="fb" src="Images/facebooklogo.png"></a></li>
<li><a class="logo" href="http://www.twitter.com"><img alt="tw" src="Images/twitterlogo.png"></a></li>
<li><a class="logo" href="http://www.rss.com"><img alt="rs" src="Images/rsslogo.png"></a></li>
</ul>
</ul>
And here is the relevant CSS. (The 'Big' class is what I'm using for all the major elements on the page.)
body {
background-image:url("Images/background.png");
background:tile;
}
.header img {
width: 100%;
}
.header {
background-color: yellow;
height: auto;
padding-top: 30px;
padding-left: 0px;
padding-bottom: 0px;
margin-top: 10px;
}
.big {
width: 80%;
margin-left: auto;
margin-right: auto;
box-shadow: 0px 0px 20px #C5C5C5;
}
Here is the css for my navbar.
.button {
background-color: #3EB5F5;
border: none;
color: white;
transition: all 0.5s;
cursor: pointer;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '»';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.navbar {
width: 100%;
margin-top: 15px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
}
.navbar ul {
list-style-type: none;
margin: 0px;
padding: 0;
overflow: hidden;
background-color: #828080;
height: 38px;
}
.navbar li {
float: left;
}
.navbar li a[href$=".asp"]{
display: block;
color: white;
text-align: center;
padding: 16px;
padding-bottom: 10px;
padding-top: 10px;
text-decoration: none;
height: 100%;
}
.navbar li a[href^="http"] {
padding-top: 6px;
padding-right: 5px;
padding-left: 5px;
padding-bottom: 5px;
}
.navbar li a:hover {
background-color: #111;
}
.logo img {
width: 25px;
}
.logo {
float:right;
list-style-type:none;
padding-bottom: 0px;
padding-top: 0px;
vertical-align: middle;
}
.active {
background-color: #106AAA
}
I have added an example to show http://codepen.io/simondavies/pen/jWjoBy
It working please check out the css, html etc
I have guestimated some stuff... Hope it will be a help
<div class="big header">
<div class="header-img"><img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=1000%C3%97150&w=1000&h=150" alt="header_photo"></div>
<div class="navbar">
<ul>
<li><a class="active" href="default.asp">Home</a></li>
<li>Contact</li>
<li>About Us</li>
<li><!--<ul class="logo"></ul>--></li>
</ul>
</div>
</div>
CSS
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.header {
background-color: yellow;
height: auto;
margin: 0;
padding: 0;
box-sizing: border-box;
}
.header-img{
width: 100%;
height: 150px;
padding: 30px 0 15px 0;
margin: 0;
}
.header-img img {
width: 100%;
height: 150px;
padding: 0;
margin: 0;
}
.big {
margin: 0 auto;
padding: 0;
margin-top: 10px;
width: 80%;
box-shadow: 0px 0px 20px #C5C5C5;
}
.button {
background-color: #3EB5F5;
border: none;
color: white;
transition: all 0.5s;
cursor: pointer;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '»';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.navbar {
width: 100%;
margin: 0;
padding: 0;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #828080;
height: 38px;
}
.navbar li {
float: left;
}
.navbar li a[href$=".asp"] {
display: block;
color: white;
text-align: center;
padding: 16px;
padding-bottom: 10px;
padding-top: 10px;
text-decoration: none;
height: 100%;
}
.navbar li a[href^="http"] {
padding-top: 6px;
padding-right: 5px;
padding-left: 5px;
padding-bottom: 5px;
}
.navbar li a:hover {
background-color: #111;
}
.logo img {
width: 25px;
}
.logo {
float: right;
list-style-type: none;
padding-bottom: 0px;
padding-top: 0px;
vertical-align: middle;
}
.active {
background-color: #106AAA
}
You have an error in your HTML:
<ul>
<li><a class="active" href="default.asp">Home</a></li>
<li>Contact</li>
<li>About Us</li>
<ul class="logo">
The only descendants of either <ul> or <ol> should be <li>. It is possible that this could be the issue.
I corrected the markup in two ways, without reproducing your issue:
By wrapping <ul class="logo"> inside of an <li> (essentially assuming it was a sublist in your list
By closing your first <ul>, and then letting the second list sit adjacent to it
But I also could not reproduce your issue by leaving the markup alone
So, the issue may be:
You need to use a CSS reset to remove default margins and paddings that the browser is providing
There is another ruleset that is adding padding to your .header
That other ruleset may have a higher specificity
That other ruleset may have an !important declaration
I am designing simple horizontal menu with html/css, see jsfiddle.net. The problem is that after hovering on li childrens i can not hold parent li background. See print screens below:
in this state, after hover on menu childrens, such as Settings or Applications, i can't hold background of parent block, such as Options :
You had added :hover effect for a tag and when you leave the a tag :hover is lost you can just add :hover to li tag and the :hover by using this you will not loose the :hover effect of the parent
.nav {
background: #C2E2EC;
height: 50px;
display: inline-block;
width: 100%;
margin: 0 0 10px 0;
padding: 0;
}
.nav li {
float: right;
list-style-type: none;
position: relative;
}
.nav li a {
font-size: 11px;
color: #000;
display: block;
line-height: 50px;
padding: 0 26px;
text-decoration: none;
font-family: Tahoma;
text-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
}
/* changed :hover to li:hover */
.nav li:hover {
background-color: #2e2e2e;
}
#settings img {
margin: 0;
padding: 0;
}
#settings a {
height: 50px;
font-size: 11px;
}
#settings img {
width: 48px;
margin: 0px;
padding: 0px;
font-size: 11px;
}
#search {
width: 338px;
margin: 4px;
}
#search_text {
width: 297px;
padding: 12px;
font-size: 11px;
font-family: tahoma;
border: 0 none;
height: 34px;
direction: rtl;
text-align: right;
margin-right: 0;
color: white;
outline: none;
background: #1f7f5c;
float: right;
box-sizing: border-box;
transition: all 0.15s;
}
#search_text:focus {
background: rgb(64, 151, 119);
}
#search_button {
border: 0 none;
cursor: pointer;
float: left;
height: 34px;
margin-left: 5px;
margin-top: 5px;
padding: 0;
text-align: center;
width: 34px;
}
#options a {
border-left: 0 none;
}
#options > a {
background-position: 85% center;
background-repeat: no-repeat;
padding-right: 42px;
color: #fff;
}
.subnav {
visibility: hidden;
position: absolute;
top: 110%;
right: 0;
width: 200px;
height: auto;
opacity: 0;
transition: all 0.1s;
background: #232323;
margin: 0;
padding: 0;
}
.subnav li {
float: none;
}
.subnav li a {
border-bottom: 1px solid #2e2e2e;
color: #fff;
}
#options:hover .subnav {
visibility: visible;
top: 100%;
opacity: 1;
}
<ul class="nav">
<li id="options">Options
<ul class="subnav">
<li>Settings
</li>
<li>Application
</li>
<li>Board
</li>
<li>Options
</li>
</ul>
</li>
</ul>
The drop-down menu wont work for my navigation. It gets hidden with display:none but upon hovering nothing is shown even though i specified that when the anchor tag containing the UL is hovered over display the child elements as blocked.
html:
<body>
<header id = "M_head">
<h2><ul>MC</ul></h2>
</header>
<div id="container">
<nav id="M_nav">
<ul>
<a>NEWS<img class="Nav_down1" src="Nav_down1.png">
<ul>
<li><a>ting1</a></li>
</ul>
</a>
<a>STORE<img class="Nav_down1" src="Nav_down1.png"></a>
<a>BLOG<img class="Nav_down1" src="Nav_down1.png"></a>
<a>CONTACTS<img class="Nav_down1" src="Nav_down1.png"></a>
<a>ABOUT<img class="Nav_down1" src="Nav_down1.png"></a>
</ul>
</nav>
<section id="M_section">
<div id=Side_sec></div>
<div id="Side_sec2"></div>
</section>
<footer id="M_footer">
</footer>
</div>
</body>
css:
* {
box-sizing: border-box; }
body {
max-width: 100%;
margin: 0px;
display: block; }
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat; }
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em; }
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em; }
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-left: -2.6%;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table; }
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black; }
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none; }
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none; }
#M_nav ul ul {
display: none; }
#M_nav ul > a:hover > ul {
display: block; }
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right; }
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white; }
here is the Jsfiddle link:http://jsfiddle.net/va06bfav/
* {
box-sizing: border-box;
}
body {
max-width: 100%;
margin: 0px;
display: block;
}
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
}
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em;
}
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em;
}
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table;
}
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black;
}
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none;
}
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none;
}
#M_nav ul li {
float: left;
position: relative;
}
#M_nav ul ul {
display: none;
position: absolute;
width: 157px;
top: 34px;
left: 0px;
list-style: none;
}
#M_nav ul a:hover + ul {
display: block;
}
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right;
}
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white;
}
<div id="container">
<nav id="M_nav">
<ul>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
If you see your code in dev tool you can see that Ul which is your drop down menu is not immediate children of your anchor tag it is placed after anchor tag immediately. The selector you are using is X > Y which selects direct children (please see the link for more detailed information about css selector.)
Changes i have made
Changed your markup structure added li in it which was not there earlier and causing the weird behavior of drop down menu which i have mentioned above.
Changed your css selector from X > Y to X X + Y what this selector will do ,It will select only the element that is immediately preceded by the former element.
* {
box-sizing: border-box;
}
body {
max-width: 100%;
margin: 0px;
display: block;
}
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
}
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em;
}
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em;
}
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-left: -2.6%;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table;
}
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black;
}
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none;
}
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none;
}
#M_nav ul ul {
display: none;
}
#M_nav ul a:hover + ul {
display: block;
}
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right;
}
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white;
}
<div id="container">
<nav id="M_nav">
<ul>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a></li>
</ul>
</li>
</ul>
</nav>
</div>