Reputation: 902
I am trying to place Unsorted List in Navigation but I want it to be in the center of header-box.
<div class="header-box">
<nav>
<ul>
</ul>
</nav>
</div>
http://jsfiddle.net/9zWm9/7/ Here is the fiddle I am using same in my code.
Upvotes: 0
Views: 420
Reputation: 1
nav ul li{
float: left;
list-style-type: none;
margin: auto;
padding-left: 20px;
position: relative;
}
Upvotes: 0
Reputation: 16547
First of all, clear your float. EDIT: One of my friend has got real problems with div inside , so lets change this.
<div class="header-box">
<nav>
<ul>
<li>AASD</li>
<li>AASD</li>
<li>AASD</li>
<li style="visibility:hidden;opacity:0;height:0;width:0;clear:both"></li>
</ul>
</nav>
</div>
and the styles:
<style>
.header-box {
width: 400px;
height: 49px;
border: 1px solid green;
position: relative;
}
ul {
margin: 0 auto;
padding: 0;
text-align: center;
height: 100%;
margin: 13px auto;
}
nav li {
float: none;
list-style-type: none;
/* padding-left: 19px; */
/* margin-left: 20px; */
/* line-height: 50px; */
display: inline-block;
/* top: 0px; */
margin: 0 auto;
text-align: center;
}
</style>
Upvotes: 1
Reputation: 99
Please update your css with below code which is with less modification :
.header-box{
width: 400px;
height: 49px;
border: 1px solid green;
text-align:center;
}
nav{
display:inline-block;
}
nav ul{
padding-left:0;
}
nav li{
float: left;
list-style-type: none;
padding-left: 10px;
padding-right: 10px;
}
Upvotes: 0
Reputation: 22643
.header-box{
width: 400px;
border: 1px solid green;
text-align:center;
}
nav ul{
padding:0;
}
nav li{
list-style: none;
display:inline-block;
margin-right: 10px;
vertical-align: middle;
}
Upvotes: 0
Reputation: 324
Replace the CSS with following..
.header-box{
width: 400px;
height: 49px;
border: 1px solid green;
}
nav ul{
padding:0;
margin:0;
list-style:none;
text-align:center;
}
nav li{
display:inline;
}
THANKS
Upvotes: 0
Reputation: 720
Please try this code. Working all Broswer
.header-box{
float:left;
width: 400px;
height: 49px;
border: 1px solid green;
position:relative;
}
.header-box nav {
float: right;
left: -50%;
position: relative;
display:block;
}
.header-box nav ul {
left: 50%;
list-style: none outside none;
margin: 0;
padding: 0;
position: relative;
}
nav li{
float: left;
list-style-type: none;
line-height: 50px;
padding:0 10px;
position: relative;
}
Upvotes: 1
Reputation: 2330
nav ul {
width : 100%;
position:relative;
float:left;
margin-left:-25px;
}
nav li{
position:relative;
float: left;
margin-left:10px;
list-style-type: none;
}
Upvotes: 0
Reputation: 3505
Use text-align:center;
for centering list's and padding for spaces and line-height for vertically center
css
nav ul li{
display: inline;
list-style-type: none;
text-align:center;
padding:0 1px;
line-height:49px;
}
Upvotes: 1
Reputation: 3373
nav ul li{
float: left;
list-style-type: none;
margin: 0px auto;
padding-left: 19px;
}
Upvotes: 0
Reputation: 11112
use margin: 0px auto;
.header-box{
width: 200px;
height: 49px;
border: 1px solid green;
}
nav li{
float: left;
list-style-type: none;
margin: 0px auto;
}
Upvotes: 0