Reputation: 1
I'm building a website but for some reason my text align is not working. When i type it, it has no affect on it. I need some help. I want the content in my dropdown menu to be aligned to the left.
HTML Code
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Cycle - Home</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<header>
<div id="heading">
<img src="http://i.imgsafe.org/5d32881.png" id="image_symbol"></img>
</div>
<div id="navbar">
<ul id="main_navbar">
<li>
<a href="#" style="z-index: -1" class="active">Home</a>
</li>
<li class="dropdown">
<a class="dropbtn" style="z-index: -1">Rent</a>
<div class="dropdown-content">
<a href="rental/mountain_bikes.html">Mountain Bikes</a>
<a href="rental/hybrid_bikes.html">Hybrid Bikes</a>
<a href="rental/road_bikes.html">Road Bikes</a>
<a href="rental/city_bikes.html">City Bikes</a>
</div>
</li>
<li>
<a href="faq.html" style="z-index: -1">FAQ's</a>
</li>
<li>
<a href="about.html" style="z-index: -1">About</a>
</li>
</ul>
<ul id="sub_navbar">
<li>
<a href="contact_us.html" style="margin-right: 10px">Contact Us</a>
</li>
<li>
<a href="log_in.php">Log In</a>
</li>
<li>
<a href="sign_up.html">Sign Up</a>
</li>
</ul>
</div>
</header>
<section>
</section>
<footer>
</footer>
</body>
</html>
CSS Code:
body {
font-family: 'Open-sans', sans-serif, Helvetica;
text-align: center;
box-sizing: border-box;
}
#main_navbar {
text-align: center;
margin-top: 7px;
float: left;
padding-left: 0;
}
#main_navbar li, #sub_navbar li {
list-style-type: none;
display: inline-block;
min-width: 5em;
}
#main_navbar li a, #sub_navbar li a {
text-decoration: none;
font-size: 1em;
text-align: center;
color: black;
font-weight: normal;
}
#sub_navbar {
float: right;
position: relative;
right: 15px;
bottom: 10px;
}
.dropdown {
position: relative;
}
.dropdown:active {
color: #32673f;
}
.dropdown-content {
display: none;
min-width: 150px;
right: 50%;
transform: translate(90%,0);
position: absolute;
padding: 10px 0;
border-radius: 5px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
.dropdown-content a {
display: block;
font-weight: normal;
text-align: left;
}
.dropdown:hover .dropdown-content {
display: block;
background-color: #f9f9f9;
}
#image_symbol {
position: relative;
float: left;
bottom: 10px;
left: 0px;
}
header {
height: 40px;
width: 100%;
padding-right: 30px;
margin-left: -20px;
margin-top: -20px;
padding-top: 20px;
}
#sub_navbar li a:hover, #main_navbar li a:hover {
color: #FFCC00;
}
#sub_navbar li .active, #main_navbar li .active {
color: #09c;
}
header {
background-color: #f6f6f6;
}
Thank you in advance!
Upvotes: 0
Views: 101
Reputation: 8537
As @Violetluna said, remove text-align: center;
from #main_navbar li a, #sub_navbar li a
#main_navbar li a, #sub_navbar li a {
text-decoration: none;
font-size: 1em;
text-align: center;
color: black;
font-weight: normal;
}
You don't have to put text-align: left;
on it because it is the default property.
Also, the syntax of the <img>
is incorrect, it is not :
<img src="http://i.imgsafe.org/5d32881.png" id="image_symbol"></img>
It is :
<img src="http://i.imgsafe.org/5d32881.png" id="image_symbol" />
Upvotes: 0
Reputation: 163
remove
text-align: center;
from here
#main_navbar li a, #sub_navbar li a {
text-decoration: none;
font-size: 1em;
text-align: center;
color: black;
font-weight: normal;
}
Upvotes: 1