Full-width Nav bar centered-right with content area - html

I'm having trouble with centering my full-width navbar with my fixed content area. The ul changes with browser or resolution.
here is a fiddle with my problem:
http://jsfiddle.net/fwyNy/
subject site
css:
#topribbon{
width: 100%;
height: 30px;
background-color: #AA1119 ;
margin: -11px 0px 1em 0px;
position: fixed;
z-index: 9999;
}
#topribbon ul{
width:auto;
padding-top:5px;
margin:0px 385px 0px auto;
float:right;
}
#topribbon ul li{
float:right;
color:white;
padding:0 10px 0 10px;
list-style:none;
display:block;
line-height:20px;
text-align:center;
cursor:pointer;
width:auto;
}
#topribbon ul li:hover{
color:#5C8FA5;
}
and here is the html:
<div id="topribbon"> <ul>
<li>Free Ground Shipping on all orders over $99!</li>
<li>Why Us?</li>
<li>Account</li>
<li>Cart</li>
<li>+1-800-555-5555</li>
</ul>

You should give the inner ul a position:relative, a width and then use margin: 0 auto
position:relative;
margin:0 auto;
width:980px; (for example)
http://jsfiddle.net/fwyNy/2/
(stretch the space of the 'result')

try
http://jsfiddle.net/Xxm76/34/
.lContent {width: 200px; border: 2px solid #000; border-right: none; float: right; position: relative;}
.rContent {width: 300px; border: 2px solid #000; border-left: none; float:left; position: relative;}
it d be cross-browser stable ??

Here is a basic example of how I would do it:
<div id="wrapper">
<div id="outer">
<div id="nav">
<ul>
<li>Free Ground </li>
<li>Why Us?</li>
<li>Account</li>
<li>Cart</li>
<li>555-5555</li>
</ul>
</div>
</div>
</div>
And the css:
#wrapper{
height: 5em;
background: #000090;
padding-top: 2em;
}
#outer{
width: 100%;
height: 3em;
background: #000;
}
#nav{
height: 3em;
background: #ccc;
width: 70%;
margin: 0 auto;
float: right;
}
#nav>ul>li{
width: auto;
list-style: none;
display: inline-block;
margin: 0 0 0 1em;
}
Fiddle: http://jsfiddle.net/fqTwN/

Related

Fixed UL Menu in Fixed Div

Am new to ASP.NET and CSS.
I Need to Show Fixed Div and fixed menu in header. And Fixed Header Div have bottom border line and its also have another ul in top of bottom ul like this
Admin
New image 1 image 2 image 3 image 4
---------------------------------------------------------
so I tried Like this
CSS
#DivHeader
{
width: 100%;
height: 125px;
top: 0px;
left: 0px;
position:fixed ;
z-index: 2;
border-bottom: 1px solid #00e5e6;
}
#DivShow
{
height: 30Px;
width: 350px;
position:fixed;
float:left;
margin-left: 20px;
margin-top: 95px;
}
#DivRight
{ height: 80Px;
width: 150px;
position:fixed;
left: 85%;
margin-top: 10px;
}
#DivShow ul
{
position: relative;
height: 20px;
width :200px;
display:inline-block ;
font-size: 14px;
color: #1570a6;
list-style:none;
top: 50%;
margin-top: -10px;
margin-left: 129px;
margin-right: 10px;
margin-bottom: 0px;
padding: 0px;
}
#DivShow li{float:left;position:relative; cursor:pointer;}
#DivMenuRight
{
height: 30Px;
width: 500px;
position:fixed;
right:15%;
margin-top: 95px;
}
#DivRight ul { position:absolute;
width :100px; margin-left:5px; }
#DivShow li{float:left;position:relative; cursor:pointer;}
#DivRight ul
{
height: 100%;
text-align:center;
color: #1570a6;
list-style:none;
text-decoration:none;
table-layout:fixed;
display:table;
}
#DivRight li{cursor:pointer; display:table-cell;
margin-top:40px; height:20px; float:left;}
#UlIcon
{
height: 100%;
list-style:none;
text-align:center;
padding-left: 5px;
text-decoration:none;
}
#UlIcon li {float:right; margin-left:25px; width : 40px; height:100%;}
img {
display:inline-block;
width:40px;
height:100%;
cursor:pointer;
}
ASP.NET
<div id="DivHeader">
<div id="DivShow">
<ul> <li> Show All </li></ul>
</div>
<div id="DivRight">
<ul> <li > Admin </li></ul>
</div>
<div id="DivMenuRight">
<ul id="UlIcon">
<li id="LiLog"> <img src="IMG/New.png" alt="" /></li>
<li id="LiDelete"> <img src="IMG/Delete.png" /></li>
<li id="LiSave"> <img src="IMG/Save.png" /></li>
<li id="LiNew"> <img src="IMG/New.png" /> </li>
</ul>
</div>
</div>
But bottom border line overlap with images only so how can i get the solution?
What am doing wrong here?
am using Visual Studio 2008 and CSS 2.1
Fiddle https://jsfiddle.net/e6LvsLh2/

HTML center image in the header

I'm trying to make a header like this:
HOME ABOUT (LOGO HERE) CONTACTS LOGISTICS
l want everything to be in the middle of the page.
If anyone can help me or link me to a helpful website I would really appreciate it
You can use margin:0 auto for centering element in the page. Try the below code for develop your design.
http://codepen.io/ogzhncrt/pen/mJggdd
header {
width:700px;
margin:0 auto;
background-color:#999;
padding:10px;
height:20px;
color:#f4f4f4;
}
header ul {
list-style:none;
margin:0 auto;
}
header ul li {
display:inline-block;
float:left;
margin-left:20px;
}
The most simple, basic solution I can think of is using the <center> tag, and put the same padding trait for each of the elements. Play with the amount of padding to achieve exacly the distance you want between them. Example:
.distanced
{
padding:20px; /*will control the distance between the spans*/
}
<center style="background-color:#aaaaaa">
<span class="distanced"> HOME </span> <span class="distanced"> ABOUT </span> <span class="distanced"> LOGO </span> <span class="distanced"> CONTACTS </span> <span class="distanced"> LOGISTICS </span>
</center>
Using divs you can set up defined widths and place them into a container.
.container{
width:500px;
margin:auto 0;
}
.item{
margin-left:20px;
border:black solid 1px;
width:50px;
height:50px;
float:left
}
.search{
margin-left:20px;
border:black solid 1px;
width:100px;
float:left;
height:50px;
}
https://jsfiddle.net/bLxk96pq/ working example i just created
I recommend using tables in your script, they're easy to use and you can make some really cool things with them. You can use the answers above to make this centered. For example put this in the body:
<div id="menu">
<table>
<tbody><tr>
<td><b>HOME</b></td>
<td><b>ABOUT</b></td>
<td>*Put the logo here*</td>
<td><b>CONTACTS</b></td>
<td><b>LOGISTICS</b></td>
</tr></tbody>
</table>
</div>
And then this in the head/CSS (Border is optional, but it's really cool. Also, color and amount of padding is you choice):
div#menu {
background:red;
height:35px;
padding: 20px;
}
table {
width:100%;
border:3px solid black;
}
td, th {
border:3px solid black;
}
It follows the code is very simple, you simply use the logo as a menu item.
HTML
<div class="container">
<nav id="navbar" style="z-index: 100000" >
<ul>
<li> Home </li>
<li> About </li>
<li><img src="http://neows.com.br/nav-center-logo/logo.png" width="250" height="100" alt=""/></li>
<li> Contact </li>
<li> Logistc </li>
</ul>
</nav>
</div>
CSS
body {
width: 100%;
height: 100%;
font-family: 'Ariar', sans-serif;
color:#828282;
font-size: 18px;
max-width: 100%;
padding-left: 0;
padding-right: 0;
margin: auto;
clear: none;
float: none;
margin-left: auto;
}
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
width: 960px;
}
#navbar {
height: auto;
float: left;
position: relative;
top: 20px;
right: 0;
z-index: 100000;
width: 100%;
text-align: center;
}
#navbar ul {
padding: 0;
margin-bottom: 0;
margin-top: 0;
list-style: none;
margin: 0 auto;
}
#navbar ul li {
display: inline-block;
height: 22px;
}
#navbar ul li a {
font-size: 16px;
float: left;
color:#828282;
padding: 0 15px 0 15px;
line-height: 1.1;
text-decoration: none;
vertical-align: central;
font-weight: bold
}
#navbar ul li a:hover {
text-decoration: none;
color: #363636;
}
.space-item {
margin-top: 40px;
}
http://jsfiddle.net/furlanj1/zku320q3/

How to move the text in li inside the #nav instead of changing the size of the block of the li

In the #nav ul li, i cant seem to fix the position of the text without changing the size of the block. Whenever I try to use padding, the size of the block changes. How can I move the text without changing the size of the block? Here is the code.
<!DOCTYPE html>
<html>
<head>
<style>
body
{
padding: 0;
background-color: #FFC0CB;
}
#container
{
margin: 0 auto;
width:100%;
height: 1500px;
padding: 0px;
}
#header
{
overflow: auto;
background-color: red;
margin: 0px;
}
#headTable
{
float:right;
}
#logo
{
background-color: green;
margin: 5px 0px 5px 70px;
float: left;
width:150px;
height:100px;
}
#headTable ul
{
list-style-type: none;
margin: 0;
}
#headTable ul li
{
font-size: 35px;
padding-top: 20px;
color: black;
float: left;
margin: 20px 50px;
}
#headTable ul li:hover
{
background-color: blue;
color:red;
}
#nav
{
clear: both;
width:100%;
height: 95px;
background-color: purple;
}
#nav ul
{
overflow: auto;/*
background-color: yellow;*/
margin: 0px;
padding: 0px;
}
#nav ul li
{
background-color: black;
color:white;
font-size: 30px;
list-style-type: none;
text-decoration: underline;
margin: 20px;
padding: 10px 10px 10px 20px;
float: left;
/*text-indent: 0px;
*/}
#page
{
float: left;
margin: 10px;
height:700px;
width:700px;
background-color: #FFC0CB;
}
#page p
{
padding:100px 0px 0px 50px;
font-size: 20px;
color: navy;
}
#content
{
height: 1000px;
width: 1334px;
position: absolute;
margin:0px;
background-color: #00B2EE;
}
#top
{
float: right;
position: relative;
margin: 10px;
background-color: #7A67EE;
width:500px;
height:300px;
}
#low
{
position: relative;
clear: both;
float: right;
margin:-300px 10px 10px 10px;
background-color: #7A67EE;
width:500px;
height:300px;
}
</style>
</head>
<body>
<div id="container">
<div id="header">
<div id="logo">
<img src="plane.jpg" width="150" height="100">
</div>
<div id="headTable">
<ul>
<li>Google</li>
<li>Google</li>
<li>Google</li>
</ul>
</div>
</div>
<div id="nav">
<ul>
<li>Menu</li>
<li>Blog</li>
<li>Ins</li>
<li>BBC</li>
<li>Contact</li>
<li>Wow</li>
<li>Doge</li>
<li>Such fun</li>
</ul>
</div>
<div id="content">
<div id="page">
<p>This is a paragraph that should
stay intact inside the id of Page.
</p>
</div>
<div id="top">
<p>THis is a paragraph that should
stay intact inside the id of top.
</p>
</div>
<div id="low">
<p>This is a paragraph that should
stay intact inside the id of bottom.
</p>
</div>
</div>
</div>
</body>
</html>
You need to set the width for an li element, and wrap the nav text in span tags. Then you can move them left or right and the width of the nav li will not change.
<li><span>Menu</span></li>
<li><span>Blog</span></li>
<li><span>Ins</span></li>
<li><span>BBC</span></li>
<li><span>Contact</span></li>
<li><span>Wow</span></li>
<li><span>Doge</span></li>
<li><span>Such fun</span></li>
#nav ul li{width:70px;background-color: black;color:white;font-size: 30px;list-style-type: none;text-decoration: underline;margin: 20px;padding: 10px 10px 10px 20px;float: left;}
#nav ul li span{margin-left:70px;}
See a working solution here: http://jsfiddle.net/mtruty/73uav/

CSS nav bar disappear under the other div

I have this html code
<div id="navbar">
<ul>
<li>Page1</li>
<li>page2</li>
<li id="NavItem">
page3
<div id="PopOver">Some text here<br>Some text here<br>Some text here<br>Some text here<br>Some text here<br>Some text here<br>Some text here</div>
</li>
<li>page4</li>
</ul>
</div>
<div id="banners">
<div class="wrap">
<div class="left"><img src="http://www.mountainecho.bizland.com/banex1.jpg"></div>
<div class="right"><img src="http://www.mountainecho.bizland.com/banex1.jpg"</div>
</div>
</div>
And CSS code
#navbar { position: relative; margin: 3px; }
#navbar ul { padding: 0; margin: auto; background: #f0f0f0 url(../images/1px.png) repeat-x 0 -441px; padding: 4px 0 4px 0; }
#navbar li { display: inline; margin-right: 80px; }
#navbar li a { font-family: EqualSansDemo; font-size: 1.6em; color: #555555; text-shadow: 1px 1px 0px #fff; }
#navbar li a:hover { color: #0071e4; }
#PopOver {
position:absolute;
border:2px solid #07B1F1;
width:170px;
height:auto;
padding:15px 5px 10px 5px;
display:none;
top:30px;
left:229px;
background-color:#FFFFFF;
border-radius:8px;
-moz-border-radius:8px;
-webkit-border-radius:8px;
}
#NavItem:hover #PopOver {display:block}
#banners { padding-top: 25px; padding-bottom: 25px; position: relative; }
.wrap { width: 1000px; margin: 0 auto; }
.left { float: left; }
.right { float: right; }
The problem :
In many of cases the nav bar will disappear under the other div
For example i have added "#banners" div and i think the problem because of "position: relative;"
But as i said "#banners" div is just for the example and if i need to fix this, i should in #navbar #NavItem:hover #PopOver
Any idea please ?
Thank you.
#PopOver {
position:absolute;
border:2px solid #07B1F1;
width:170px;
height:auto;
padding:15px 5px 10px 5px;
display:none;
top:30px;
left:229px;
background-color:#FFFFFF;
border-radius:8px;
-moz-border-radius:8px;
-webkit-border-radius:8px;
z-index:1;
}
Set z-index:2; or greater in #PopOver
Set a z-index value on the #navbar item. http://www.w3schools.com/cssref/pr_pos_z-index.asp

horizontal menu coloring goes wrong

<div id="header">
<div id="logo">
<h1>Look Around You</h1>
</div>
<div id="horNav">
<ul class="horNav">
<li class="horNav">HOME</li>
<li class="horNav">SUBMIT-CONTACT</li>
</ul>
<ul class="horNav-last">
<li class="horNav">TAGS</li>
</ul>
<ul class="advertisment">
<li>ABOUT</li>
<li>ADVERTISEMENT</li>
</ul>
</div>
</div>
css is:
#wrapper{
width:80%;
margin:0 auto;
min-width:920px;
}
#header, #logo{
width: 100%;
float:left;
}
#horNav{
background:black;
width: 80%;
color:white;
margin: 0 auto;
}
#horNav a{
background: black;
}
.horNav li{
float:left;
border-right:1px solid #828282;
}
.horNav-last li{
float:left;
}
.advertisment li{
float:right;
border-left:1px solid #828282;
}
#horNav a{
display:block;
padding:5px 10px;
color:white;
font-size: 13px;
}
#horNav a:hover{
background:#828282;
}
what happens is that unordered lists are colored black in separate corners and middle of #horNav is white as you can see it HERE but of course it needs to be all black. how to fix this?
#horNav {
overflow: hidden;
display: block;
width: 100%;
}
#horNav can be whatever width you want e.g. 80% as it is now, and if you want it to be centred you can reintroduce the margin: 0 auto;.