Navbar Menu Trouble shoot - html

So I wanted to create the fixed nav bar on top of the page. Instead of creating nav bar with ordered list, I used the following approach:
<header>
<div class="nav">
<img src="images/logo_ab.png" alt="AurinBioTech Logo"/>
Home
About
Team
Science
Need
Pipeline
Contact
</div>
</header>
CSS:
header .nav {
margin-top:100px;
width:100%;
height:10%;
text-align:center;
padding-top:2%;
margin:0 auto;
position:fixed;
top:0;
}
header .nav a {
font-size: 2em;
padding-left: 15px;
padding-right: 15px;
color:rgb(1, 1, 1);
text-decoration: none;
font-family: 'Bebas';
}
header .nav a:hover {
color:white;
background-color: #404040;
border-radius:5px;
padding:0 auto;
}
header .nav a:active{
background-color: #404040;
border-radius:5px;
text-decoration:overline;
}
header .nav img {
width:260px;
height:65px;
padding-right:4em;
}
The reason I used this approach is because I wanted to use logo image next to the nav bar so it would align properly in the same line. Now the problem is that I need to add sub-menus under Science and Pipeline heading. Since I didn't use UL or LI, how can I add sub-menus under those heading.
OR, can you tell me any other way to create a NAV bar that shows the logo as well.
so it would be LOGO and MENUS on the same line.
Great thanks in advance.

Use the normal ul li structure.
If you set the height and line-height of top level li tags to be equal to the height of the image it will align the text to the center of the image.

I can suggest you to use a tool.
CSSMENU where you can create a menu without writing the code.You can also change the code or add images as your wish if needed. There are some inbuilt images where you can use them too.

have a two column structure in your nav bar one column for the logo and other for the nav-bar options.
<header>
<div class="nav">
<img src="images/logo_ab.png" alt="AurinBioTech Logo"/>
</div>
<div class="options">
<ul>
<li>Home</li>
<li>About</li>
<li>Team</li>
<li>Science</li>
<li>Need</li>
<li>Pipeline</li>
<li>Contact</li>
</ul>
</div>
</header>
and
with css give them appropriate width and align them using padding or margin properties

Related

div float a part on the left, list on the right (but this must be at the far right) and no reverse in HTML?

i am trying on a footer to put an element on the far left:
--MY WEB SITE (aligned on the right)--
On the far right (the end of the list must be aligned with the right border of the browser), i want to put in order:
twitter, facebook, newsletter
By floating left, what i get is the opposite of the html file
Thanks all
jsfiddle
<div class=footer>
<UL><H4>MY WEB SITE (aligned on the right)</H4>
<LI><a href=https://www.linkedin.com/pub/ric style='border-bottom: 0px'></A><LI>
<LI>twitter</LI>
<LI>facebook</LI>
<LI><font color='#0894D2 '>NEWSLETTER</FONT></LI>
</UL>
</DIV>
.footer {
border: 2px solid grey;
width:90%;
height:auto;
text-align: center;
}
.footer:after {
content: '';
display: inline-block;
width: 100%;
}
.footer ul {
margin: 0;
padding: 0;
list-style: none;
}
.footer ul li {
margin: 0;
padding: 0;
list-style: none;
display:inline-block;
font-size:12px;
float:right;
}
.footer h4{
margin: 0;
padding: 0;
list-style: none;
display:inline-block;
font-size:12px;
float:left;
}
If you want to change an order of your list items on the right side, just try to change an order of list items tags in html...
<div class="footer">
<ul>
<h4>MY WEB SITE (aligned on the right)</h4>
<li><a href="https://www.linkedin.com/pub/ric" style='border-bottom: 0px'></a></li>
<li><font color='#0894D2 '>NEWSLETTER</font></li>
<li>facebook</li>
<li>twitter</li>
</ul>
</div>
Change your HTML as such:
<div class="footer">
<H4>MY WEB SITE (aligned on the right</H4>
<ul>
<li><font color="#0894D2 ">NEWSLETTER</font></li>
<li><img src="images/facebook.png" />Facebook</li>
<li><a href="https://www.linkedin.com/pub/ric" style='border-bottom: 0px'><img src="images/linkedin.jpg" />LinkedIn</a><li>
<li>twitter<div id="logo_twitter"></div></li>
</ul>
</div>
First things first....
In order to achieve what you are looking for (hope I understood corectly), you should put the H4 tag outside UL. Then, in CSS, set the UL (footer ul) to float:right and the the LIs (footer ul li) to float:left.
See this example: https://jsfiddle.net/w6pa3L30/4/
.footer ul{float:right;}
.footer ul li {float:left;}
Now, you should also review your code. FONT tag is not supported in HTML5. You should also avoid using divs for displaying social icons (I guess that is what you wanted to do inside Twitter LI), instead use span tag. I would also recommend you to avoid using inline styling; style them inside your stylesheet.

horizontal nav bar items with different number of lines of text

Simple horizontal nav bar for artist portfolio website. I am in the process of changing it from a jpg based site to actually coded, and need to match the nav bar on the following page:
http://cynthia-shaffer.com/animal.html
Notice "Natural Elements", "Animal Photos", and "Henna Tattoos" the text is stacked (2 lines as opposed to 1). I want to replicate this in my ul, but can't seem to figure it out.
my code
<div id="nav">
<ul>
<li>Home</li>
<li>About</li>
<li>Natural Elements</li>
<li>Animal Photos</li>
<li>Henna Tattoos</li>
<li>Murals</li>
<li>Supplementary</li>
<li>Non-Profit</li>
</ul>
</div>
CSS:
#nav ul
{
margin: 0;
padding: 0;
list-style-type: none;
text-align: center;
}
#nav ul li { display: inline; }
#nav ul li a
{
text-decoration: none;
font-family:"Lithos";
font-size:12px;
color:c0944d;
padding: .3em 1em;
}
So the question is how to get the word "elements" to appear below "natural", without breaking the integrity of the list.
thanks in advance!!
Apply display:inline-block for the <a> tags and set the maximum desired width of a menu item using the max-width property, this will cause the text to automatically wrap when it exceeds the specified max-length
#nav ul li a {
text-decoration: none;
font-family:"Lithos";
font-size:12px;
color:c0944d;
padding: .3em 1em;
display:inline-block;
max-width:50px;
}
side note: it's better to apply display:inline-block while changing display from block, for aligning items horizontally - if you apply display:inline like you've applied to the <li> , the element will not accept width and height properties...
JSFiddle

Center text within a div [duplicate]

This question already has answers here:
How can I horizontally center an element?
(133 answers)
Closed 9 years ago.
I am having difficulty trying to center my navigation text on my page. I want all my links to be in the center of my page the whole time, even if I re-size my window.
Thanks for your time.
HTML:
<div id="navcont">
<div id="navigation">
<ul>
<li class="home">Home</li>
<li class="about">About me</li>
<li class="portfolio">Portfolio</li>
<li class="contact">Talk to me</li>
</ul>
</div>
</div>
CSS:
#navcont{
height: 80px;
background-color: #ebebeb;
width: 100%;
padding-top: 10px;
}
#navigation{
font-size: 15px;
font-family: "TYPOGRAPH PRO" arial;
}
#navigation ul li{
list-style:none;
display:inline-block;
background-color:red;
width:120px;
}
#navigation ul li a{
text-transform:uppercase;
text-decoration:none;
color:black;
}
#navigation ul li a:hover{
color:#217c7e;
}
You want to use
text-align:center;
for this example. But if you make it more complex you may want to look at margin:0 auto; on the parent div. Also worth noting that in order for it to actually look center you will need to adjust the margins automatically applied to UL and LI
JS Fiddle: http://jsfiddle.net/W4eF3/
You should be able to just add text-align: center to your ul.
#navigation ul{
text-align: center;
}
This will center all the li elements, as well as the text inside them. If you don't want the text to center you could add a text-align: left to the li elements.
http://jsfiddle.net/ctCKg/
EDIT: But like others have said, this should be an easy search or trial and error for you. Lots of ways to do it too.
Add one property to your div CSS my friend
#navigation {
font-size: 15px;
font-family: "TYPOGRAPH PRO" arial;
text-align:center;
}
like this

Body overlaps fixed, horizontal nav bar up top - CSS/HTML

I have to make a website for an assignment, and I'm having a bit of trouble. I've created a navbar up the top, and it's in a fixed position. However, when I scroll, everything shows through it. What I want, is essentially for the webpage to start under the navbar, so it's there at the top, and when I click 'About Me', it doesn't have the title under the navbar, like in the second image.
http://i.imgur.com/oTkXlWx.png
Does anyone know how to do this? Thanks.
#top-bar
{
border-top:#fff dashed 1px;
width:100%;
height:32px;
background:black;
opacity:0.8;
text-align:center;
position:fixed;
top:0;
padding-bottom:12px;
}
#top-nav li
{
display: inline-block;
line-height: 49px;
padding: 0px 14px;
}
#top-nav li a
{
display:block;
color: #ddd;
font-weight: 700;
letter-spacing: 0.08em;
text-decoration: none;
text-transform: uppercase;
}
#top-nav li:hover, #top-nav li:hover a
{
background-color:#333;
color:#fff;
}
and the html:
<nav id="top-bar">
<ul id="top-nav">
<li>
About Me
</li>
<li>
Programming
</li>
<li>
Hometown
</li>
<li>
Swinburne
</li>
<li>
Acheivements
</li>
</ul>
</nav>
Basically, I don't want the webpage to 'scroll through' the nav bar.
Also, my class hasn't done javascript yet, so if there is a solution not using javascript that would be great.
Thanks guys.
P.S. Here is the code for the div for the about:
<div id="about-text" class="box">
<h3>About Me</h3>
<p>My name is , I'm 18 years old, and a Computer
Science student at Swinburne University of Technology, Hawthorn.
I've always been interested in computers, there is something
beautiful about technology working to do so many things the human
brain cannot possibly do.</p>
</div>
and the css:
#about-text, #programming-text, #home-text, #achievement-text
{
border-style : solid;
border-width:0.2em;
opacity:0.5;
width : 70%;
transition: opacity 0.2s;
-webkit-transition: opacity 0.2s;
}
I believe you simply need to give the .boxes enough of a margin-top for it to clear the fixed navbar.
Update:
Discovered that the root cause of the issue was the use of in-page links, which always scrolled right to the top of the viewport (under the fixed nav) when clicked.
The best solution ended up being adding empty a elements before each div.box to use as the target of the links, and give those a large enough size that the .box would fall into place below the navbar:
<div class="box"> ... </div>
.button {
display: block;
padding: 25px;
}
One trick that you can use is to put nav within the header tag and give background color for header, white or whichever color you are using. Scrolling down will go below the nav bar but it wont be seen due to the background color which overlaps it.

Can't center a ul inside a div

I am trying to center my navigation links inside the div but no matter what I've tried it won't work. I've tried margin-left:auto, margin-right:auto, but nothing...
Here is the section of CSS code:
#nav {
display:block;
background-color:#505050;
height:17.5px;
box-shadow: 0px 0px 15px 5px #CCCCCC inset;
border:1px solid #EEEEEE;
border-radius:20px;
padding:1.5%;
}
#nav li {
padding:0px 20px 0px 20px;
display:inline;
/*float:left;*/
list-style:none;
position:relative;
}
#nav li a {
padding:0px 0px 20px 0px;
color:#FFFFFF;
text-decoration:none;
}
and here is my ul code:
<ul id="nav">
<li>Home</li>
<li>About Us</li>
<li>Current Litters</li>
<li>Gallery
<ul>
<li>Bandi</li>
<li>Studs Used</li>
<li>Test Dog2</li>
<li>Test Dog3</li>
</ul>
</li>
<li>Contact Us</li>
</ul>
Here is the rest of my code
actually without it i noticed that my drop down menu under (gallery) doesn't display correctly, ...here is the rest of that css file...that shows what happens to the drop down...maybe you can tell me why the float screws it all up...
...and the text align did great....but only after removing the float...
#nav li a:hover {
text-decoration:underline;
}
#nav li ul{
padding:10px;
font-size:medium;
display:none;
position:absolute;
left:0px;
top:30px;
background-color:rgba(50,50,50,0.8);
}
#nav li:hover ul {
display:block;
border-radius:20px;
border:1px solid;
width:150px;
}
This is actually quite simple, since your list items are display:inline. Add this style:
#nav {
text-align:center;
}
Demo: http://jsfiddle.net/fH6f5/
There are many other ways to do it, but this appears to be all you need. Just make sure not to float the <li>s (I see you have it commented out).
Adding text-align: center to the nav unordered list seems to work for me in chrome
#nav {
text-align: center;
}
To center a block element, you also need to explicitly set the width to some value, like this:
#nav {
width: 50%;
margin: 0 auto;
}
There are quite a few changes you're going to need to make to your code in order for it to display properly. Your list elements are currently inline elements. inline elements have a lot of restrictions, including not being able to explicitly set their width, height, and their top and bottom margin. Keep in mind that per the W3 spec:
Generally, inline elements may contain only data and other inline elements.
That being said, you can use display: inline-block with no problems for your current code. There is one very important thing to keep in mind about using inline-block elements: whitespace. Any space between inline-block elements in your code will be shown as a space on your browser. So, if you want the elements to be touching, their tags must be touching also:
<!-- Version A: This will produce a gap between the two elements -->
<li>Home</li>
<li>About Us</li>
<!-- Version B: This will not produce a gap between the two elements -->
<li>
Home
</li><li>
About Us
</li>
If you choose Version A from the code above, I'd recommend you float the elements rather than relying on inline-block for positioning. Centering a floated list is a bit more difficult than centering an inline list. Here's a way that I like to center floated elements:
<nav>
<ul>
<li>Home</li>
<li>About Us</li>
</ul>
</nav>
CSS:
nav { overflow: hidden; }
nav ul {
position: relative;
float: left;
left: 50%;
list-style: none;
padding: 0; }
nav ul li {
position: relative;
float: left;
right: 50%;
margin: 0 5px; }
nav ul li a { display: block; }
Preview: http://jsfiddle.net/Wexcode/rsDbY/
You should post the design that you want for your dropdown menu, I don't really know what you want your final result to look like so I can't really help you with that.
You need to set a fixed width on your ul for margin-right:auto and margin-left:auto
Have you tried to add margin: 0 auto; to #nav style? You also have to set the ul width to get this working.
It's a bit more complicated then simply "text-align" as you have the text inside of a . You need to add "margin: 0px auto;" to your element in your css file. This will then center the divider on the screen first, then center the next element within the divider and so on.