Hello I am trying to make a website but my menu bar is not doing what it should. This is what it should look like:
http://i.stack.imgur.com/KDvwo.png
But instead it looks like this:
http://i.stack.imgur.com/Y1Ya8.png
Here is my code:
HTML
<div class="wrapper">
<header>
<h1>Colve</h1></div>
<nav>
<ul class="menu1">
<li><a class="button" href="#">Home</a></li>
<li><a class="button" href="#about">About</a></li>
<li><a class="button" href="#downloads">Downloads</a>
<li><a class="button" href="invasion.html">INVASION</a></li>
</li><li><a class="button" href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<section id="about">
<h1>About-Colve</h1>
<p>Colve is a company that gives you the things you want in one place</p>
<p>Created by Bradley Beeke</p>
</section>
</div>
CSS
html {
font:12pt Lato, sans-serif;
min-height:100%;
background-image:linear-gradient(45deg,#3498db,#2ecc71);
}
body{margin:0px;}
header{
background-color:white;
Color: #FFDF00;
float:left;
padding-left:5px;
display:block;
}
nav {
background-color:white;
float:right;
padding-right:5px;
height:60px;
display:block;
width:100%;
float:right;
}
nav a {
text-decoration:none;
list-style:none;
color:#FFDF00;
font-size:20px;
padding:8px;
}
nav li:hover, a:hover {color:#998100;}
li{display:inline;}
section { margin-bottom: 1000px; padding-top: 150px; float: left; }
Please can you help me!
Working DEMO
<div class="wrapper">
<header>
<h1>Colve</h1> <!-- remove the </div> present here -->
<nav>
<ul class="menu1">
<li><a class="button" href="#">Home</a></li>
<li><a class="button" href="#about">About</a></li>
<li><a class="button" href="#downloads">Downloads</a>
<li><a class="button" href="invasion.html">INVASION</a></li>
</li><li><a class="button" href="contact.html">Contact</a></li>
</ul>
</nav>
In the nav css, make width to be auto
nav {
background-color:white;
float:right;
padding-right:5px;
height:60px;
display:block;
width:auto;
float:right;
}
Add width: 100%; in header {} because currently the header is not properly aligned.
The HTML is not well constructed. Please remove the extra and from the code.
Well, right off the bat your HTML is invalid.. I see two immediate problems.
First, the closing tag after your closing H1 tag cannot be there (it looks like that was just an accident anyway).
<div class="wrapper">
<header>
<h1>Colve</h1></div>
Second, the closing that starts this line doesn't make any sense.. Remove it.
</li><li><a class="button" href="contact.html">Contact</a></li>
Oh, I lied.. there's a 3rd.. There's no closing tag for this element.
<li><a class="button" href="#downloads">Downloads</a>
Other than that, your HTML looks fine to me at a quick look, but in the future you may want to bookmark this site:
http://validator.w3.org/#validate_by_input
After you correct those problems with your HTML, update your question if you're still having problems.
Related
I have been seriously messing with this one thing for over an hour now. Basically I have a navigation bar, there is an icon on the far left, and the links are aligning to the bottom of the image.
I have tried messing with padding, margins, line height, vertical-align and everything else I could think of. I also tried having the image inside and before the ul. I need the ul items (will be links) to be vertically aligned to the center of the icon.
I have put all the code into one file that I will copy here. Also, when you post please explain why a solution will work, not just post code. The other posts I searched for about this before I posted here didn't explain anything, just included code that didn't help when I tried it. Unfortunately, because I have no idea what the solution is or what it relates to I am including all of the code.
body {
margin: 0;
/*background-color: #10f009;*/
font-size: 62.5%;
font-family: sans-serif;
}
img {
margin: 0 0 0 0;
max-width: 100%;
height: 50%;
}
.smallSection {
margin: 100px;
}
.paragraph {
font-size: 2em;
max-width: 500px;
}
.title {
font-size: 2.4em;
}
.list {
list-style: solid inside url("");
font-size: 2em;
}
.nav-link {
list-style-type: none;
display: inline-block;
text-align: center;
font-size: 2em;
width: 200px;
border: 1px solid red;
}
.nav-icon {
display: inline-block;
border: 1px solid red;
}
.largeSection {} #section1 {
background-image: url("../img/placeholder.jpg")
}
#nav {
border: 1px solid red;
margin: 0;
padding: 0;
align: top;
height: 100px;
line-height: 1;
}
/*temporary*/
div {
border: 1px solid red;
}
<!-- Dawn Little -->
<div id="section1" class="largeSection">
<!-- Navigation -->
<div>
<ul id="nav">
<div style="width:70px;height:70px;border: 1px solid red;display: inline-block;">
<!-- The img link is obviously broken so this is here instead. -->
</div>
<!-- <img src="img/herbfalife-icon.png" width="70px" height="70px" class="nav-icon"> -->
<li class="nav-link">Who am I</li>
<li class="nav-link">What I do</li>
<li class="nav-link">3-Day Trial</li>
<li class="nav-link">Challenges</li>
<li class="nav-link">Become a Coach</li>
</ul>
</div>
<div class="smallSection">
<p class="paragraph">
<span class="title">Client Name<br /></span> Hi, I'm a wife, mother, and Personal Wellness Coach with Herbalife Nutrition. My super power - I change lives.
</p>
</div>
</div>
<!-- What I do -->
<div id="section2" class="largeSection">
<div class="smallSection">
<p class="paragraph">
<span class="title">What I do</span>
<ul class="list">
<li>Wellness Evaluations</li>
<li>Nutrition Coaching</li>
<li>Impact Lifestyle</li>
<li>Get Results</li>
<li>Coach Coaches</li>
</ul>
</p>
</div>
</div>
<!-- 3-day trial -->
<div id="section3" class="largeSection">
<div class="smallSection">
<p class="title">
Try Our 3-Day Trial
</p>
<p class="title">
What you get:
</p>
<ul class="list">
<li>Personal Wellness Coach</li>
<li>Wellness Evaluation</li>
<li>Meal Plan</li>
<li>Daily Support</li>
<li>Plan of Action</li>
<li>6 Meals</li>
<li>Metabolism Booster</li>
</ul>
</div>
</div>
<!-- Challenges -->
<div id="section4" class="largeSection">
<div class="smallSection">
<p class="title">
Join a Weight Loss Challenge
</p>
<p class="title">What you get:</p>
<ul class="list">
<li>Personal Wellness Evaluation</li>
<li>Personalized Program</li>
<li>Nutrition Classes</li>
<li>ommunity of Support</li>
<li>Accountability</li>
<li>Opportunity to Win Cash & Prizes</li>
</ul>
</div>
</div>
<!-- Become a coach -->
<div id="section5" class="largeSection">
<div class="smallSection">
<p class="title">
Become a Coach
</p>
<p class="title">
What you get:
</p>
<ul class="list">
<li>Opportunity to Change Lives</li>
<li>Opportunity for Personal & Financial Growth</li>
<li>Training</li>
<li>Potential to Change Lives in Over 90 Countries</li>
<li>Be Part of a Team</li>
<li>Get in the Best Shape You've Ever Been</li>
</ul>
</div>
</div>
This way that you are coding is a bit tricky to align.I will rewrite your code. However, I recommend you to use a CSS framework like bootstrap or zurb.
Firstly, you need to rewrite HTML part like
<!-- Navigation -->
<div class="header clearfix">
<div class="logo">
<!-- The img link is obviously broken so this is here instead. -->
</div>
<div class="nagivation">
<ul id="nav">
<li class="nav-link">Who am I</li>
<li class="nav-link">What I do </li>
<li class="nav-link">3-Day Trial</li>
<li class="nav-link">Challenges</li>
<li class="nav-link">Become a Coach</li>
</ul>
</div>
</div>
I have added header and nagivation
then add these lines to your css to
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-block; }
/* start commented backslash hack \*/
* html .clearfix { height: 1%; }
.clearfix { display: block; }
/* close commented backslash hack */
.header{
min-height:70px;
clear:both
}
.logo{
width:20%;
float:left;
}
.nagivation{
width:80%;
float:right;
}
you need to remove #nav also in your CSS code.
based on your needs, you can change this class
.nagivation #nav{
// add needed adjustment
}
you can have an access to all codes here https://jsfiddle.net/mhadaily/7f152z3r/
The easiest way to accomplish what you want is to simply float the icon as seen in the css below and in this pen.
#nav {
border: 1px solid red;
height:100px;
line-height:1;
display:inline-block;
}
.nav-icon {
display: inline-block;
border: 1px solid red;
float:left;
}
Floats force other elements to flow around the floated element. You just want to be wary of floats because they wreak havoc on your layout if you're not vigilant (they collapse their parent containers). You can read all about it here.
I am not a UI expert. But By looking at the following tag I can asked you few question to understand? Because You are writing non-li tags within ul. Try ti wrap your code with li tag.
Just go to w3cshool link.
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_lists_menu
http://www.w3schools.com/html/html_lists.asp
<ul id="nav">
<div style="width:70px;height:70px;border: 1px solid red;display: inline-block;">
<!-- The img link is obviously broken so this is here instead. -->
</div>
<!-- <img src="img/herbfalife-icon.png" width="70px" height="70px" class="nav-icon"> -->
<li class="nav-link">Who am I</li>
<li class="nav-link">What I do </li>
What about simply moving the li elements up a little bit?
.nav-link {
position: relative;
bottom: 20px;
}
First off, the only elements that should be inside a <ul> are <li>. That <div> (or link or whatever it is in reality) may cause you grief.
The real problem, however, is that you're using the wrong CSS property on the wrong element. You want vertical-align (not "align"), and it should be applied to the list-items (not the container).
Try this:
<ul>
<li class="nav-link"><!-- img here --></li>
<li class="nav-link">Who am I</li>
<li class="nav-link">What I do</li>
<li class="nav-link">3-Day Trial</li>
<li class="nav-link">Challenges</li>
<li class="nav-link">Become a Coach</li>
</ul>
with
.nav-link { vertical-align: middle; }
A few weeks ago I was asked by my church to create a new website for them which I happily obliged to. I've already created a mockup in PS and I'm coding it right now. I created the navigation bar and it is working properly as I had intended.
However I'm running into a glaring problem concerning the spaces in between the menu items. It seems like it may be an easy fix, but I cannot seem to figure it out. The menu bar is set up as unordered and ordered lists. I have them evenly spread out, but in between the empty spaces, the mouse cursor changes from a pointer into an "I" bar, as if there is invisible text.
For me, this is not ideal, and I'd much prefer that when hovering over this empty space between the menu items that it would stay as a pointer for the cursor instead of this "I" bar. Also, if you highlight the entire menue, the spaces also highlight as well and connect with the menu items. That is also not ideal for me, and it makes me confused why the empty spaces are sort of acting like invisible text.
Here is my menu bar CSS code:
<style type="text/css">
nav {
position: relative;
width:960px;
z-index:9999;
margin-left:auto;
margin-right:auto;
padding:0;
background-color:transparent;
text-align:justify;
}
#bar1 {
background-color:transparent;
padding:0;
text-align: justify;
overflow: hidden;
height:39px;
border-top: 1px solid #222222; border-bottom: 1px solid #90908e;
background-color:transparent;
}
#bar1>li {
display:inline-block;
margin-top:8px;
height:100%;
background-color:transparent;
}
#bar1>li>a {
font-family:'Oswald',Verdana, Geneva, sans-serif;
font-size:15px;
color:#464748;
text-decoration:none;
}
#bar1>li>a:hover,#bar1>li>a:active,#bar1>li:hover>a {
font-family:'Oswald',Verdana, Geneva, sans-serif;
font-size:15px;
color:#2b77a0;
text-decoration:none;
}
#bar1>li>ul>li {
border-top: none;
height:33px;
margin-top:8px;
left: 0;
position: absolute;
width: 100%;
text-decoration:none;
background-color:transparent;
padding-top:7px;
}
#bar1>li:hover>ul>li{
display:block;
}
#bar1>li>ul>li{
display:none;
text-decoration:none;
}
#bar1>li>ul>li>a
{
font-family:'Antenna Thin', Arial, Helvetica, sans-serif;
font-size:15px;
color:#222222;
text-decoration:none;
}
#bar1>li>ul>li>a:hover, #bar1>li>ul>li>a:active, #bar1>li>ul>li:hover>a,
{
font-family:'Antenna Thin', Arial, Helvetica, sans-serif;
color:#222222;
}
li {
list-style-type:none;
}
.filler
{
width:100%;
display: inline-block;
height:0px;
cursor:pointer;
}
</style>
And here is my HTML coding (Ignore the comments, I use them so I don't get lost when I take breaks):
<nav>
<ul id="bar1">
<!--Begin About Us-->
<li>ABOUT US
<!--Begin drop down menu items-->
<ul>
<li>
<font color="#2b77a0">•</font> New to Nederland First Assembly
<span style="margin-left:10px;"><font color="#2b77a0">•</font> Our History</span>
<span style="margin-left:10px;"><font color="#2b77a0">•</font> Our Beliefs</span>
</li>
</ul>
<!--End drop down menu items-->
</li>
<!--End About Us-->
<!--Begin Ministries-->
<li>MINISTRIES
<!--Begin drop down menu items-->
<ul>
<li>
<font color="#2b77a0">•</font> Kids
<span style="margin-left:10px;"><font color="#2b77a0">•</font> Youth</span>
<span style="margin-left:10px;"><font color="#2b77a0">•</font> Women</span>
<span style="margin-left:10px;"><font color="#2b77a0">•</font> Men</span>
</li>
</ul>
<!--End drop down menu items-->
</li>
<!--End Ministries-->
<!--Begin Events-->
<li>EVENTS
<!--Begin drop down menu items-->
<ul>
<li>
<font color="#2b77a0">•</font> Latest News
<span style="margin-left:10px;"><font color="#2b77a0">•</font> Monthly Calendar</span>
</li>
</ul>
<!--End drop down menu items-->
</li>
<!--End Events-->
<!--Begin Listen Online-->
<li>LISTEN ONLINE
<!--Begin drop down menu items-->
<ul style="background-color:red;">
<li>
<font color="#2b77a0">•</font> Sermons
<span style="margin-left:10px;"><font color="#2b77a0">•</font> Teachings</span>
<span style="margin-left:10px;"><font color="#2b77a0">•</font> Archive</span>
</li>
</ul>
<!--End drop down menu items-->
</li>
<!--End Listen Online-->
<li>CONTACT US</li>
<li class="filler"></li>
</ul>
And here is hopefully a working JS Fiddle:
http://jsfiddle.net/Broli/yemze0je/1/
Inline block assigns a font size based on the default, what you want is the hand icon on a link, and the arrow when it's not a link:
DEMO: http://jsfiddle.net/yemze0je/3/
nav {
position: relative;
width:960px;
z-index:9999;
margin-left:auto;
margin-right:auto;
padding:0;
background-color:transparent;
text-align:justify;
font-size:0px; /* due to inline-block on children */
}
Because your font size is specified in the children, this does just that.
First off, comments are good for you! :-)
My immediate thought looking at your HTML is that you should be wrapping each anchor within its own list item.
Change this and the markup will probably behave in the way that you would like it to.
http://www.w3schools.com/html/html_lists.asp
Alternatively, if you would like to keep the same markup, you could mask the issue by setting the cursor with CSS, like this;
ul, li{cursor: default;}
I am presuming that the li or ul will need the curser set (I'm on my smartphone!)
I'm trying to make a horizontal list where each of the <li>s in the list have a height of 385px and a width of 400px.
I tried making the list horizontal by using inline-block, but that doesn't seem to be working.
By which, I mean the list is still vertical. The <li>s are the right size, but the list is not horizontal.
How can I make this list horizontal? (Preferably without flexbox)
Here is my CSS:
html, body{
margin:0;
padding:0;
font-family:'Open Sans', sans-serif;
font-size:16px;
}
#slides{
list-style:none;
list-style-type:none;
}
#slides li{
height:385px;
width:400px;
display:inline-block;
}
and my HTML:
<form action="" method="get">
<fieldset>
<ul id="slides">
<div id="first">
<li>
1
</li>
</div>
<div id="second">
<li>
2
</li>
</div>
<div id="last">
<li>
3
</li>
</div>
</ul>
</fieldset>
</form>
You are making it totally wrong, you are using div which are block level element, also you cannot use any other element except li inside ul, so your markup is invalid, instead do it like this
<ul>
<li><div>A</div></li>
<li><div>B</div></li>
</ul>
<style>
ul li {
display: inline-block;
}
</style>
Add a float:left to #slides li
#slides li{float:left;}
Hope this helps.
Remove the divs and float the lis to the left:
HTML
<form action="" method="get">
<fieldset>
<ul id="slides">
<li id="first">1</li>
<li id="second">2</li>
<li id="third">3</li>
</ul>
</fieldset>
</form>
CSS
html, body{
margin:0;
padding:0;
font-family:'Open Sans', sans-serif;
font-size:16px;
}
#slides{
list-style:none;
list-style-type:none;
}
#slides li{
height:385px;
width:40px;
display:inline-block;
float: left;
}
http://jsfiddle.net/X6LkZ/1/
I'm making a navigation where the children will be showed in a different box, much like http://www.boffi.com/EN/Collections/bathrooms/b14.aspx . I managed to separate the child using absolute positioning, but can't get the child elements background to have a 100% height. it's a list element, so if I put height: 100% , the bottom two main navigation elements dissapears. Please help! Here's my html:
<ul id="mainmenu">
<li id="liHome" class="active">
Home
</li>
<li id="liServices" class=" ">
Services
<div class="child">
<ul style="" id="SubMenuY2" class="submenu">
<li>Sub-item 1</li>
<li>Sub-item 2</li>
</ul>
</div>
</li>
<li id="liEnvironment">
Environment
</li>
<li id="liCareer">
Career
</li>
<li id="liContact">
Contact
</li>
</ul>
and the css
body, html{
height:100%;
}
#mainmenu{
background:black;
color: white;
width:130px;
position:relative;
top:0;
height:100%
}
#mainmenu li a {
color:white;
}
ul.submenu{
position:absolute;
background:blue;
width:130px;
}
div.child{
position:relative;
margin-left:130px;
}
Thanks a lot for the help.
I simplified your code a little.. well I actually just removed the div with class="child", as you don't really need it.
Then, all I did was this:
ul.submenu{
position:absolute;
left: 130px; top: 0;
background:blue;
width:130px;
height: 100%;
}
Take a look at the fiddle: http://jsfiddle.net/joplomacedo/rqqju/
Was this what you were looking for?
I've created a jsfiddle http://jsfiddle.net/zkLav/ showing the code in action. what's happening is the images and text alignment are step stacking and not aligning vertically. Can anyone explain why this is happening?
CSS markup:
.outList {
display:table;
}
.outList span {
display:table-cell;
vertical-align:middle;
width:10%;
}
.outList h4 {
display:table-cell;
vertical-align:middle;
width:50%;
padding-left: 10px;
}
.outList p {
float:right;
display:table-cell;
vertical-align:middle;
/*width:30%;*/
text-align:right;
}
.outList img {
width:100%;
}
HTML markup:
<ul>
<li data-theme="c">
<a href="detail.html">
<div class="outList">
<span><img src="simgs/listview_chk.png" /></span>
<h4>Warmup</h4>
<p>5 Minutes</p>
</div>
</a>
</li>
<li data-theme="c">
<a href="detail.html">
<div class="outList">
<span><img src="simgs/listview_chk.png" /></span>
<h4>Machine Press</h4>
<p>3 sets of</p>
</div>
</a>
</li>
<li data-theme="c">
<a href="detail.html">
<div class="outList">
<span><img src="simgs/listview_chk.png" /></span>
<h4>Lateral Pulldowns</h4>
<p>3 sets of</p>
</div>
</a>
</li>
</ul>
A proper image of the problem:
Ok, take a look at this update
Just remove the width in the next .css class:
.outList img {
width: 100%;
}
UPDATE
For the text at the right to be fully align, remove the float:right; from the p class:
.outList p {
float:right;
display:table-cell;
vertical-align:middle;
/*width:30%;*/
text-align:right;
}
Check this new update
Get rid of the divs, you don't need them given that you have the li's.
Also, why span the img? Get rid of that too.
When you did that, put the ul as the table, the li's as the rows and then the stuff in the a as the columns.