HTML/CSS on making a website menu [closed] - html

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
First attempt on doing a website after a online course on HTML and CSS. I'm struggling with the horizontal menu.
I have three elements in the "header": img1; img2; ul/li elements
I want to make them stick together so i have a logo on the left, a triangule in the middle and the menu on the righ, all stick together, with no spaces beetween them and centered.
Can you help me out ?!
Here's the CSS:
* {
border: 1px solid white;
background-color:#000;
color: white;
}
#header {
border: 1px solid blue;
height: 60px;
}
#logo {
float: left
}
#logo img {
display:inline-block;
width: 300px;
height: 50px;
}
#triangulo {
display:inline-block;
}
#triangulo img {
display:inline-block;
width: 50px;
height: 50px;
}
#menu {
display:inline-block;
border: 1px solid pink;
float: right
}
#menu li {
display: inline-block;
text-color: white;
font-weight: bold;
font-family: Arial;
}
Thank you so much for the patience
edit: html
<div id="header">
<div id="logo"><img src="images/Olympic-logo.png" width=300 height=50 /></div>
<div id="triangulo"><img src="images/Triangle(shape).jpg" width=50 height=50 /></div>
<div id="menu">
<ul>
<li>Quem Somos</li>
<li>Soluções</li>
<li>Instalações</li>
<li>Contactos</li>
<li>X</li>
<li>X</li>
</ul>
</div>
</div>
edit2: fiddle link i want the 3 elements sticked toghther with no spaces between them and make it all the same row, with enough space to li/ul elements

Check thIS FIDDLE :DEMO
1) I have added a wrapper for the header and given it width and margin:auto , so that the menu is centered to the width (since you wanted the menu to be centered.)
2) and all the menu's are in a single line with equal spacing , this is done by applying display:inline-block;
HTML:
<div id="header-wrapper">
<div id="header">
<div id="logo"><img src="images/Olympic-logo.png" width=300 height=50 /></div>
<div id="triangulo"><img src="images/Triangle(shape).jpg" width=50 height=50 /></div>
<div id="menu">
<ul>
<li>Quem Somos</li>
<li>Soluções</li>
<li>Instalações</li>
<li>Contactos</li>
<li>X</li>
<li>X</li>
</ul>
</div>
</div>
</div>
CSS:
#header-wrapper{
width:800px;
margin:0 auto;
}
}
#header {
border: 1px solid blue;
height: 60px;
}
#logo {
display:inline-block;
}
#triangulo {
display:inline-block;
}
#menu {
display:inline-block;
border: 1px solid pink;
height: 50px;
width: 400px;
}
#menu li {
display: inline-block;
color: white;
font-weight: bold;
font-family: Arial;
}
Let me know if this is what you wanted.

There are many problem with your CSS Code. For example not wisely use float:left and float:right and second thing is there is no such property text-color: white; it should be color: white;.
Have a look at DEMO first . this is achieve by using display:inline-block;
CSS Code:
ul{margin:0; padding:0; vertical-align:top; list-style-type:none;}
#header {
white-space:nowrap;
border:1px solid #c6c6c6;
}
#logo {
display:inline-block;
}
#triangulo {
display:inline-block;
}
#menu {
display:inline-block;
border: 1px solid pink;
}
#menu ul li ,#menu ul li a
{
color: black;
font-weight: bold;
font-family: Arial;
display:inline-block;
text-decoration:none;
}

You need to float all of those inline divs left.
#header {
border: 1px solid blue;
height: 60px;
margin:0 auto 0 auto;
}
#logo {
float: left;
}
#triangulo {
display:inline-block;
float:left;
}
#menu {
display:inline-block;
border: 1px solid pink;
float:left;
height: 50px;
width: 400px;
}
#menu li {
display: inline-block;
color: white;
font-weight: bold;
font-family: Arial;
}

This should do it.
<style>
* {
border: 1px solid white;
background-color:#000;
color: white;
}
#header {
border: 1px solid blue;
height: 60px;
}
#logo {
display:inline-block;
padding:0px;
margin:0px;
width: 300px;
height: 50px;
float:left;
}
#triangulo {
display:inline-block;
width: 50px;
height: 50px;
padding:0px;
margin:0px;
float:left;
}
#menu {
display:inline-block;
border: 1px solid pink;
float:left;
}
#menu ul {
float:left;
padding:0px;
margin:0px
}
#menu li {
display: inline-block;
text-color: white;
font-weight: bold;
font-family: Arial;
}
</style>
<div id="header">
<img id="logo" src="images/Olympic-logo.png" width=300 height=50 />
<img id="triangulo" src="images/Triangle(shape).jpg" width=50 height=50 >
<div id="menu">
<ul>
<li>Quem Somos</li>
<li>Soluções</li>
<li>Instalações</li>
<li>Contactos</li>
<li>X</li>
<li>X</li>
</ul>
</div>
</div>

Related

can't get rid of list items height in menu

hi i just wanted to code a site like BBC just for practice while doing this i got an error in li item of a ul i don't know the problem but when i give it a border-right the border take more height then the original menu, i'm pasting my code here please check it and help me??
in simple words i want list item's border to be equal to the borders of "Signin" and "logo" div
<html>
<head>
<title>BBC</title>
<style>
body{
margin:0;
font-family:Arial,Helvetica,freesans,sans-serif;
}
#top{
width:100%;
height:50px;
}
.keepcenter{
width:1100px;
margin: 0 auto;
}
#logo{
border-right:1px solid #CCCCCC;
float:left;
padding-right:5px;
height:100%;
}
#signin{
font-weight:bold;
font-size:0.9em;
border-right:1px solid #CCCCCC;
width:200px;
height:100%;
float:left;
}
#signin img{
position:relative;
top:5px;
margin-left:15px;
}
#signin p{
display:inline;
position:relative;
top:1px;
padding-left:5px;
}
#menutop{
float:left;
}
#menutop ul{
list-style-type:none;
margin:0;
padding:0;
}
#menutop li{
padding:15px 20px 10px 20px;
display:inline;
font-weight:bold;
font-size:0.9em;
float:left;
border-right:1px solid #CCCCCC;
height:100%;
}
</style>
</head>
<body>
<div id="container">
<div id="top">
<div class="keepcenter">
<div id="logo">
<img src="images/logo.jpg" />
</div>
<div id="signin">
<img src="images/signicon.png" /><p>Sign In</p>
</div>
<div id="menutop">
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
Simply remove the top and bottom padding from the list items.
body {
margin: 0;
font-family: Arial, Helvetica, freesans, sans-serif;
}
#top {
width: 100%;
height: 50px;
}
.keepcenter {
width: 1100px;
margin: 0 auto;
}
#logo {
border-right: 1px solid #CCCCCC;
float: left;
padding-right: 5px;
height: 100%;
}
#signin {
font-weight: bold;
font-size: 0.9em;
border-right: 1px solid #CCCCCC;
width: 200px;
height: 100%;
float: left;
}
#signin img {
position: relative;
top: 5px;
margin-left: 15px;
}
#signin p {
display: inline;
position: relative;
top: 1px;
padding-left: 5px;
}
#menutop {
float: left;
}
#menutop ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#menutop li {
padding: 0 20px;
display: inline;
font-weight: bold;
font-size: 0.9em;
float: left;
border-right: 1px solid #CCCCCC;
height: 100%;
}
<div id="container">
<div id="top">
<div class="keepcenter">
<div id="logo">
<img src="http://lorempixel.com/40/40" alt="BBC" />
</div>
<div id="signin">
<img src="http://lorempixel.com/g/10/10" alt="" />
<p>Sign In</p>
</div>
<div id="menutop">
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
</div>
</div>
</div>
</div>
The list is floating though, which means that its baseline is not necessarily the same as the #signin div. In my snippet, the img in the div is small enough to not have an effect, but depending on its size, the baseline of the div (and therefore the position of the p) will move down. You may have to compensate for that in the ul.

Recreating Google Homepage (html/css): Questions regarding positioning

I'm doing a project on recreating the Google homepage with html and css. I am for the most part finished with the project, but I've noticed a few quirks that are irritating me. I've spent a great deal of time on each of these quirks, but can't get things to way I want them to look. These are the following quirks:
The icon in the top right-hand corner isn't inline with the rest of the text.
For some reason I can't center the buttons properly.
Not sure how to handle the white space surrounding the grey footer.
JSFiddle of The Code
If you have any input on any of the above issues, I would forever be thankful!
<body>
<div id="wrapper">
<div id="header">
<ul class="navbar">
<li class="navli"> +You
</li>
<li class="navli">Gmail
</li>
<li class="navli">Images
</li>
<li class="navli" id="icon">
<img src="http://bit.ly/1NHEwTW" height="auto" width="30" />
</li>
<li class="navli">theonlybrianlie#gmail.com
</li>
</ul>
</div>
<div id="body">
<div class="logo">
<img src="https://www.google.com/images/srpr/logo11w.png" />
</div>
<div class="searchbar">
<input type="text" id="search1" />
</div>
<div id="buttons">
<input class="button" id="googlesearch" value="Google Search" type="submit">
<input class="button" id="secondbutton" value="I'm Feeling Lucky" type="submit">
</div>
</div>
<div id="footer">
<div id="leftfoot">
<ul>
<li class="lf"> Advertising
</li>
<li class="lf"> Business
</li>
<li class="lf"> About
</li>
</ul>
</div>
<div id="rightfoot">
<ul>
<li class="rf"> Privacy
</li>
<li class="rf"> Terms
</li>
<li class="rf"> Settings
</li>
</ul>
</div>
</div>
</div>
.button {
font-family:Arial;
font-size:11px;
font-weight:bold;
display:inline;
height:30px;
border:1px solid #dcdcdc;
background:#f2f2f2;
padding-left: 10px;
}
body, html {
height:100%
}
#wrapper {
min-height:100%;
position: relative;
padding:0;
margin:0;
}
.logo img {
display:block;
width: 269px;
height:95px;
margin:auto;
margin-top: 80px;
padding-top: 112px;
}
#header {
width:100%;
height:100px;
/*background-color:green*/
;
}
.navbar {
/*background-color: red;*/
float: right;
}
.navli {
display: inline-block;
font-family: Arial;
}
.navli a {
text-decoration:none;
color: #404040;
font-size: 13px;
padding-left: 15px;
}
.navli a:hover {
text-decoration:underline;
}
#icon {
margin-top:10px;
padding-left:15px;
bottom:0;
position:relative;
}
.searchbar {
width:400px;
height:28px;
margin: auto;
display:block;
/*background-color:red;*/
padding-top:10px;
}
#search1 {
width:400px;
height:28px;
margin: auto;
}
#buttons {
display:block;
/*background-color:blue;*/
height: 22px;
width:250px;
margin: auto;
margin-top: 10px;
}
#footer {
position: absolute;
bottom:0;
height:60px;
width:100%;
background-color:#f2f2f2;
clear:both;
display:block;
border-top: 1px solid #e4e4e4;
}
#leftfoot {
width:300px;
left:0;
/*background-color:blue;*/
display: inline-block;
}
.lf {
display: inline-block;
}
.lf a {
text-decoration:none;
color: #404040;
font-size: 13px;
font-family: Arial;
padding-left: 15px;
}
.lf a:hover {
text-decoration: underline;
}
#rightfoot {
width:250px;
float:right;
/*background-color:blue;*/
padding:0;
margin:0;
}
.rf {
display: inline-block;
margin:auto;
}
.rf a {
text-decoration:none;
color: #404040;
font-size: 13px;
padding-left: 15px;
font-family: Arial;
}
.rf a:hover {
text-decoration: underline;
}
For your top right icon not inline with the rest of the menu, i would alter the CSS like this
.navli {
display: inline-block;
font-family: Arial;
float: left;
height: 30px;
line-height: 30px;
}
#icon {
/* margin-top: 10px; */
padding-left: 15px;
/* bottom: 0; */
/* position: relative; */
}
For your buttons not centering:
Add text-align:center; to #buttons
And for the white space on footer:
There's a margin on your body, so change your body,html to this:
body, html {
height: 100%;
margin: 0;
}
UPDATE
Here's the JSFiddle - Full Screen Preview - JSFiddle View
I'll try to answer these as concisely as possible:
1- the heading is inline, and your icon is taller than the rest of the inline elements. play with the margin and padding for your text elements there.
2- place your buttons in a div or section element of their own, and use text-align: center to center them on the page
3- add a class="container-fluid" to your footer element.

Text gets pushed down by menu

I want a vertical menu to the left side of my site, but the text is getting pushed down and is not to the side of the menu. Please ignore text in the paragraphs and headers. I am sorry for the poor organization or any small mistakes I have made, This is my first language and I am still learning.
<style>
body
{
background-color:#333;
color:#999
font: 12px/1.4em Arial,sans-serif;
}
#wrap
{
margin-left: 10px auto;
background: black;
padding:10px;
width: 100px;
}
#header
{
background-color:black;
color: #fff;
}
#logo
{
float: center;
font-size: 30px;
line-height:400px;
padding: 500px
}
#navWrap
{
height:15pxpx;
}
#nav ul
{
margin: 1px;
padding:1px;
}
#nav li
{
float:center;
padding: 5px;
background-color: black;
margin: 0 5px;
color: white;
list-style-type: none
}
#nav li a
{
color:white;
text-decoration: none;
font-size: 15px;
}
#nav li a:hover
{
text-decoration: underline;
}
br.clearLeft
{
clear: left;
}
h1
{
color:cyan;
text-align:center;
border-bottom: double 5px;
}
h2
{
color:red;
}
h3
{
color:cyan;
}
p.2
{
color:black;
font-size:22px;
text-align:left;
}
p
{
color:#DBDBDB;
font-size:22px;
text-align:left
right: 500px;
}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="logo"></div>
<div id="navWrap">
<div id="nav">
<ul>
<li>Home</li>
<li>About</li>
<li>link1</li>
</ul>
<br class="clearLeft"/>
</div>
</div>
</div>
</div>
<p>lalalallalalalalalallalalala</p>
You just need to float your #wrap div to the left using the following CSS and that'll solve the issue:
#wrap {
float: left;
}
Here's a demo:
body {
background-color:#333;
color:#999 font: 12px/1.4em Arial, sans-serif;
}
#wrap {
margin-left: 10px auto;
background: black;
padding:10px;
width: 100px;
}
#header {
background-color:black;
color: #fff;
}
#logo {
float: center;
font-size: 30px;
line-height:400px;
padding: 500px
}
#navWrap {
height:15pxpx;
}
#nav ul {
margin: 1px;
padding:1px;
}
#nav li {
float:center;
padding: 5px;
background-color: black;
margin: 0 5px;
color: white;
list-style-type: none
}
#nav li a {
color:white;
text-decoration: none;
font-size: 15px;
}
#nav li a:hover {
text-decoration: underline;
}
br.clearLeft {
clear: left;
}
h1 {
color:cyan;
text-align:center;
border-bottom: double 5px;
}
h2 {
color:red;
}
h3 {
color:cyan;
}
p.2 {
color:black;
font-size:22px;
text-align:left;
}
p {
color:#DBDBDB;
font-size:22px;
text-align:left right: 500px;
}
#wrap {
float: left;
}
<div id="wrap">
<div id="header">
<div id="logo"></div>
<div id="navWrap">
<div id="nav">
<ul>
<li>Home
</li>
<li>About
</li>
<li>link1
</li>
</ul>
<br class="clearLeft" />
</div>
</div>
</div>
</div>
<p>lalalallalalalalalallalalala</p>
The padding on your logo is pushing the text down, and your line-height is huge. I would suggest adjusting those two values.
#logo {
float: center;
font-size: 30px;
line-height:400px; // pushing it down
padding: 500px; // pushing it down
}
Also, you're setting the height on #navWrap, which is also causing your navigation to look weird. Finally, floating your #wrap element puts your content in the right place.
Here is a fiddle that resolves your situation:
http://jsfiddle.net/cywb70ds/2/
I adjusted the padding and line-height on the #logo element.

How to adjust img and ul tags in Header?

I have a little bit confusion, i want to put img and ul tag in header and i put it like this:
HTML
<div class="header">
<div class="container">
<ul>
<li> Help </li>
<li> About Us </li>
</ul>
<div class="img01">
<img src="images/vfp logo.png" alt="LOGO" height="127" width="177">
</div><!-- .img01 -->
</div><!-- .container -->
</div><!-- .header -->
CSS
.header{
height: 135px;
background-color: #CCC;
border-bottom: 2px solid #000;
position:relative;
}
.header a{
color:#000;
font-size: 25px;
font-weight:bold;
text-decoration:none;
float:right;
padding: 14px 10px;
position:relative; top:40; right:40;
margin: 0px 30px 0px 0px;
}
.header li {
display: inline;
}
.header img01{
text-align:left;
}
The problem is I have adjust ul and li tags, and they are fine for my page, but the img can't move.. and don't know where should i put padding and margin for img?
Your CSS as it is now is not valid.
I think you probably want this:
.header img{
text-align:left;
}
Or, if you are trying to style a specific img that doesn't have an ID:
.header img:nth-of-type(1){
text-align:left;
}
However, if your img tag has an ID, you can just specify it:
.header #someID{
text-align:left;
}
EDIT
Based on your updated comment, you are trying to style a class named img01, which looks like this:
.header .img01 {
text-align:left;
}
You can also style the img specifically:
.header .img01>img {
text-align:left;
}
Try this:
.header{
height: 135px;
background-color: #CCC;
border-bottom: 2px solid #000;
position:relative;
}
.header > a{
color:#000;
font-size: 25px;
font-weight:bold;
text-decoration:none;
float:right;
padding: 14px 10px;
position:relative; top:40; right:40;
margin: 0px 30px 0px 0px;
}
.header > li {
display: inline;
}
.header > ul {
}
.header > img{
text-align:left;
padding: 1em;
margin: 1em;
}

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