I'm trying to make a responsive menu for the cellphone-size.
What I want is a collapseable navigation-menu, for example:
(not expanding) BUTTON A
(not expanding) BUTTON B
(expandable) BUTTON C
BUTTON C option A
So when you see the menu first, you only see button A,B and C.
When you click on Button C, below it appears (by clicking on it) the option A.
What I have so far is a button with a three-lines nav icon.
When you click on it, you see button a,b,c .
But when you click on Button c, the whole list collapse back, and when re-opening, you see the full list. This is not what I had in mind...
My coding:
HTML
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$(".text").hide();
$(".accordeon div:first-child").addClass("expand_first");
$(".expand").click(function() {
$(".text").slideUp(500);
if ($(this).next(".text").is(":visible")) {
$(this).next(".text").slideUp(500);
} else {
$(this).next(".text").slideToggle(500);
}
});
});
$(window).load(function() {
$('.flexslider').flexslider();
});
$('ul li a').click(function() {
$(this).parent().find('ul.sub-menu').toggle();
return false;
});
</script>
<div id="nav-small">
<div class="accordeon">
<div class="expand"><img src="http://localhost:8080/wordpress/wp-content/uploads/2016/06/navicon.png" alt="Navigation" width="50%" height="auto" />
Navigation
</div>
<div class="text">
<ul>
<li>Home</li>
<li>Library</li>
<li class="sub-menu">Lifestyle▼
<ul>
<li>Cleaning & Organizing</li>
<li>Health & Beauty</li>
<li>Travel</li>
</ul>
</li>
</ul>
</div></div></div>
My CSS:
#nav-small{
width:100%;
height:auto;
}
#nav-small img{
width:50%;
max-width:30px;
max-height:30px;
}
#nav-small ul{
list-style:none;
padding:0;
margin:0;
font-family:verdana;
}
#nav-small ul li{
text-align:center;
text-decoration:none;
padding: 2% 0;
border-bottom:1px solid black;
}
#nav-small ul li a{
text-decoration:none;
}
#nav-small ul li.sub-menu{
border-bottom:none;
padding-bottom:0;
}
.accordeon{
text-align:center;
background-color: rgba(104,144,192,1.00) ;
width:100%;
}
.accordeon .expand {
display:inline-block;
width:30%;
height:auto;
margin:auto;
font-family: Verdana;
background-color: rgba(104,144,192,1.00) ;
cursor:pointer;
padding:1% 0;
border-left:1px solid #ccc;
border-right:1px solid #ccc;
}
.accordeon .text{
display:none;
float:left;
width:100%;
height:auto;
margin:auto;
border-top:0px;
border-bottom:1px solid #ccc;
background-color: rgba(211,196,213,1.00);
text-align:left;
}
SOLUTION:
Wrap your icon in a span to add a selector and add a click event listener to it.
Also I added a class that uses display: none for your nested ul.
JSFiddle
CODE SNIPPET:
$(document).ready(function() {
$(".text").hide();
$(".accordeon div:first-child").addClass("expand_first");
$(".expand").click(function() {
$(".text").slideUp(500);
if ($(this).next(".text").is(":visible")) {
$(this).next(".text").slideUp(500);
} else {
$(this).next(".text").slideToggle(500);
}
});
$("#trigger").on("click", function() {
$(".sub-menu > ul").slideToggle(500, function() {
$(this).toggleClass("is-not-visible");
});
});
});
$(window).load(function() {
$('.flexslider').flexslider();
});
$('ul li a').click(function() {
$(this).parent().find('ul.sub-menu').toggle();
return false;
});
#nav-small {
width: 100%;
height: auto;
}
#nav-small img {
width: 50%;
max-width: 30px;
max-height: 30px;
}
#nav-small ul {
list-style: none;
padding: 0;
margin: 0;
font-family: verdana;
}
#nav-small ul li {
text-align: center;
text-decoration: none;
padding: 2% 0;
border-bottom: 1px solid black;
}
#nav-small ul li a {
text-decoration: none;
}
.accordeon {
text-align: center;
background-color: rgba(104, 144, 192, 1.00);
width: 100%;
}
.accordeon .expand {
display: inline-block;
width: 30%;
height: auto;
margin: auto;
font-family: Verdana;
background-color: rgba(104, 144, 192, 1.00);
cursor: pointer;
padding: 1% 0;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
}
.accordeon .text {
display: none;
float: left;
width: 100%;
height: auto;
margin: auto;
border-top: 0px;
border-bottom: 1px solid #ccc;
background-color: rgba(211, 196, 213, 1.00);
text-align: left;
}
.is-not-visible {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="nav-small">
<div class="accordeon">
<div class="expand"><img src="http://placehold.it/100x100" alt="Navigation" width="50%" height="auto" /> Navigation
</div>
<div class="text">
<ul>
<li>Home</li>
<li>Library</li>
<li class="sub-menu">Lifestyle <span id="trigger">▼</span>
<ul class="is-not-visible">
<li>Cleaning & Organizing</li>
<li>Health & Beauty</li>
<li>Travel</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
Related
Please consider the following code snippet.
My question is: why is the second li, the one with class filterdivision, lower in the layout than the previous one instead of being verticaly aligned with it ? I gave it the same height and see no margin or padding that might push it down.
Javascript code isn't relevant to the question but allows the snippet to be functional.
var triggerFilter = function(filterData)
{
console.log(filterData);
}
$(".customDropdown li").on('click',function(){
var $self = $(this);
var $list = $self.parent();
if($list.hasClass("listVisible"))
{ //Whole list is visible => Selecting an option
$list.find('.active').removeClass("active");
$self.addClass("active");
$list.removeClass("listVisible");
triggerFilter({filterName:$list.data("fieldname"),filterValue:$self.data("fieldvalue")});
}
else
{
//Show whole list
$list.addClass("listVisible");
}
});
.wrapper { background: #f2f2f2;; padding: 20px;position: relative;height:60px;}
.wrapper input { box-sizing: border-box; border: 1px solid #c2c2c2; font-size: 14px; padding: 10px 15px; width: 100%;}
.wrapper ol.filters { padding:0; margin: 0; font-size: 0; height:58px;}
.wrapper ol.filters > li
{
list-style-type: none;
display: inline-block;
width: 150px;
margin-right:20px;
height: 58px;/*Need to fix height because of absolute positionned fake dropdowns*/
position:relative;
}
.wrapper ol.filters > li:last-child{ margin-right:0;}
.wrapper ol.filters > li:first-child{ width: 150px;}
.wrapper label { display:block; font-size:12px; color: #797979; margin-bottom: 3px;}
/* CSS for custom dropdown */
.customDropdown {
position:absolute;
z-index: 50;
padding:0;
margin:0;
list-style-type: none;
background: #fff;
border: 1px solid #c2c2c2;
cursor: pointer;
width:150px;
}
.customDropdown li {display:none;padding: 10px 15px;font-size:14px;}
.customDropdown li::after { position: absolute; top: 10px; right: 10px; content: ""; display: inline-block; width: 0.5em; height: 0.5em; border-right: 2px solid black; border-bottom: 2px solid black; transform: rotate(45deg);}
.customDropdown li.active {display:block;}
.customDropdown.listVisible li {display:block;border-bottom: 1px solid #f2f2f2;}
.customDropdown.listVisible li:hover {background: #f2f2f2;color:#4fbbeb;}
.customDropdown.listVisible li.active {color:#4fbbeb;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<ol class="filters">
<li class="filterSearch">
<label for="filterSearch">Search</label><input type="text" id="search">
</li>
<li class="filterDivision">
<label>Division</label>
<ol class="customDropdown" data-fieldname="division">
<li class="active" data-fieldvalue="all">All divisions</li>
<li data-fieldvalue="consulting">Consulting</li>
<li data-fieldvalue="digital">Digital</li>
<li data-fieldvalue="other">Other</li>
</ol>
</li>
<!-- ... Other filter options in li tags -->
</ol>
</div>
Try using
float:left
instead of
display:inline-block
in
.wrapper ol.filters > li
Although this doesn't seem to be an issue here, floating elements wont affect the parent elements height, unless you add
clear:both;
overflow:auto;
to the parent elements style like this:
<div style="clear:both; overflow:auto">
<div style="float:left">hello</div>
<div style="float:left">world</div>
</div>
here's you code snippet using floating elements (I'm not sure what's causing your issue exactly, but floating left fixes it)
var triggerFilter = function(filterData)
{
console.log(filterData);
}
$(".customDropdown li").on('click',function(){
var $self = $(this);
var $list = $self.parent();
if($list.hasClass("listVisible"))
{ //Whole list is visible => Selecting an option
$list.find('.active').removeClass("active");
$self.addClass("active");
$list.removeClass("listVisible");
triggerFilter({filterName:$list.data("fieldname"),filterValue:$self.data("fieldvalue")});
}
else
{
//Show whole list
$list.addClass("listVisible");
}
});
.wrapper { background: #f2f2f2;; padding: 20px;position: relative;height:60px;}
.wrapper input { box-sizing: border-box; border: 1px solid #c2c2c2; font-size: 14px; padding: 10px 15px; width: 100%;}
.wrapper ol.filters { padding:0; margin: 0; font-size: 0; height:58px;}
.wrapper ol.filters > li
{
list-style-type: none;
float:left;
width: 150px;
margin-right:20px;
height: 58px;/*Need to fix height because of absolute positionned fake dropdowns*/
position:relative;
}
.wrapper ol.filters > li:last-child{ margin-right:0;}
.wrapper ol.filters > li:first-child{ width: 150px;}
.wrapper label { display:block; font-size:12px; color: #797979; margin-bottom: 3px;}
/* CSS for custom dropdown */
.customDropdown {
position:absolute;
z-index: 50;
padding:0;
margin:0;
list-style-type: none;
background: #fff;
border: 1px solid #c2c2c2;
cursor: pointer;
width:150px;
}
.customDropdown li {display:none;padding: 10px 15px;font-size:14px;}
.customDropdown li::after { position: absolute; top: 10px; right: 10px; content: ""; display: inline-block; width: 0.5em; height: 0.5em; border-right: 2px solid black; border-bottom: 2px solid black; transform: rotate(45deg);}
.customDropdown li.active {display:block;}
.customDropdown.listVisible li {display:block;border-bottom: 1px solid #f2f2f2;}
.customDropdown.listVisible li:hover {background: #f2f2f2;color:#4fbbeb;}
.customDropdown.listVisible li.active {color:#4fbbeb;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<ol class="filters">
<li class="filterSearch">
<label for="filterSearch">Search</label><input type="text" id="search">
</li>
<li class="filterDivision">
<label>Division</label>
<ol class="customDropdown" data-fieldname="division">
<li class="active" data-fieldvalue="all">All divisions</li>
<li data-fieldvalue="consulting">Consulting</li>
<li data-fieldvalue="digital">Digital</li>
<li data-fieldvalue="other">Other</li>
</ol>
</li>
<!-- ... Other filter options in li tags -->
</ol>
</div>
Inline blocks are blocks that try to span the entire width and in your code, the .wrapper didn't have the width set, which forced it to take up space beside, and not below
var triggerFilter = function(filterData)
{
console.log(filterData);
}
$(".customDropdown li").on('click',function(){
var $self = $(this);
var $list = $self.parent();
if($list.hasClass("listVisible"))
{ //Whole list is visible => Selecting an option
$list.find('.active').removeClass("active");
$self.addClass("active");
$list.removeClass("listVisible");
triggerFilter({filterName:$list.data("fieldname"),filterValue:$self.data("fieldvalue")});
}
else
{
//Show whole list
$list.addClass("listVisible");
}
});
.wrapper { background: #f2f2f2;; padding: 20px;position: relative;height:150px; width: 60px}
.wrapper input { box-sizing: border-box; border: 1px solid #c2c2c2; font-size: 14px; padding: 10px 15px; width: 100%;}
.wrapper ol.filters { padding:0; margin: 0; font-size: 0; height:116px;}
.wrapper ol.filters > li
{
list-style-type: none;
display: inline-block;
width: 150px;
margin-top: 10px;
margin-right:20px;
height: 58px;/*Need to fix height because of absolute positionned fake dropdowns*/
position:relative;
}
.wrapper ol.filters > li:last-child{ margin-right:0;}
.wrapper ol.filters > li:first-child{ width: 150px;}
.wrapper label { display:inline-block; font-size:12px; color: #797979; margin-bottom: 3px;}
/* CSS for custom dropdown */
.customDropdown {
position:absolute;
z-index: 50;
padding:0;
margin:0;
list-style-type: none;
background: #fff;
border: 1px solid #c2c2c2;
cursor: pointer;
width:150px;
}
.customDropdown li {display:none;padding: 10px 15px;font-size:14px;}
.customDropdown li::after { position: absolute; top: 10px; right: 10px; content: ""; display: inline-block; width: 0.5em; height: 0.5em; border-right: 2px solid black; border-bottom: 2px solid black; transform: rotate(45deg);}
.customDropdown li.active {display:block;}
.customDropdown.listVisible li {display:block;border-bottom: 1px solid #f2f2f2;}
.customDropdown.listVisible li:hover {background: #f2f2f2;color:#4fbbeb;}
.customDropdown.listVisible li.active {color:#4fbbeb;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<ol class="filters">
<li class="filterSearch">
<label for="filterSearch">Search</label><input type="text" id="search">
</li>
<li class="filterDivision">
<label>Division</label>
<ol class="customDropdown" data-fieldname="division">
<li class="active" data-fieldvalue="all">All divisions</li>
<li data-fieldvalue="consulting">Consulting</li>
<li data-fieldvalue="digital">Digital</li>
<li data-fieldvalue="other">Other</li>
</ol>
</li>
<!-- ... Other filter options in li tags -->
</ol>
</div>
I'm trying to have these small left and right borders either side of the text. Here is what I'm trying to make:
http://imgur.com/xCZnGgJ
My problem is that the borders are not the same height of the surrounding div however they only go the same height of the text. Here is a screen shot:
http://imgur.com/I2jjsAm
I have dried adding height: 30px to the li and ul however this does not change anything.
*{margin:0;}
#header {
width:100%;
}
#pre_header {
width:100%;
height:30px;
background-color:#202020;
}
.pre_header_content {
margin:0 auto;
width:1040px;
}
#pre_header ul {
list-style-type: none;
margin: 0;
padding: 0;
line-height:30px;
}
#pre_header li {
display: inline;
border-right: .5px solid #414141;
border-left: .5px solid #414141;
}
#pre_header a {
text-decoration:none;
color:#fff;
padding:6px 15px 6px 15px;
}
#pre_header a:hover {
background-color:#4e4e4e;
}
<div id="header">
<div id="pre_header">
<div class="pre_header_content">
<ul>
<li>Voucher codes</li>
<li>In-store codes</li>
<li>Online codes</li>
<li>Free samples</li>
<li>Advertise</li>
</ul>
</div>
</div>
<div id="main_header">
<div class="main_header_content">
Test
</div>
</div>
</div>
If anyone knows is there also anyway to bring the two borders together closer also?
Add the padding:6px 15px 6px 15px; to the li instead of a. And also, 0.5px does not work. What's half a pixel? Updated your code. See below!
EDIT: Note: I also changed your hover effect to affect the li element instead of a.
*{
margin:0;
box-sizing: border-box;
}
#header {
width:100%;
}
#pre_header {
width:100%;
height:30px;
background-color:#202020;
}
.pre_header_content {
margin:0 auto;
width:1040px;
}
#pre_header ul {
list-style-type: none;
margin: 0;
padding: 0;
line-height:30px;
}
#pre_header li {
display: inline;
border-right: 1px solid #414141;
border-left: 1px solid #414141;
padding: 0 15px;
float:left;
margin-right: 2px;
}
#pre_header li:last-child{
margin-right: 0;
}
#pre_header a {
text-decoration:none;
color:#fff;
}
#pre_header li:hover {
background-color:#4e4e4e;
}
<div id="header">
<div id="pre_header">
<div class="pre_header_content">
<ul>
<li>Voucher codes</li>
<li>In-store codes</li>
<li>Online codes</li>
<li>Free samples</li>
<li>Advertise</li>
</ul>
</div>
</div>
<div id="main_header">
<div class="main_header_content">
Test
</div>
</div>
</div>
You could simply change the li to display: inline-block; I've created a jsfiddle for you.
#pre_header li {
display: inline-block;
border-right: 1px solid #414141;
border-left: 1px solid #414141;
}
Also, don't use .5px, use a single amount. I have used 1px.
http://jsfiddle.net/xeqsn83a/
If you want the borders to touch, you would need to float it. And as others have mentioned, your border width needs to be an actual pixel size. There is no such thing as .5px. Here is an example of what (I think) you are trying to do:
http://jsfiddle.net/tuc4Lwuu/
#pre_header li {
float: left;
border-right: 1px solid #414141;
border-left: 1px solid #414141;
margin-right: 2px;
}
Try this:
* {
margin: 0;
}
#header {
width: 100%;
}
#pre_header {
width: 100%;
height: 30px;
background-color: #202020;
}
.pre_header_content {
margin: 0 auto;
width: 1040px;
}
#pre_header ul {
list-style-type: none;
margin: 0;
padding: 0;
font-size: 0;
}
#pre_header li {
display: inline-block;
border-right: 1px solid #414141;
border-left: 1px solid #414141;
margin-right: 1px;
}
#pre_header a {
text-decoration: none;
color: #fff;
padding: 6px 15px 6px 15px;
font-size: 16px;
line-height: 30px;
}
#pre_header a:hover {
background-color: #4e4e4e;
}
<div id="header">
<div id="pre_header">
<div class="pre_header_content">
<ul>
<li>Voucher codes</li>
<li>In-store codes</li>
<li>Online codes</li>
<li>Free samples</li>
<li>Advertise</li>
</ul>
</div>
</div>
<div id="main_header">
<div class="main_header_content">
Test
</div>
</div>
</div>
I changed display: inline to inline-block for li and border-width to 1px (it has to be an integer). Also made li items closer to each other with font-size: 0 technique (read this article for understanding).
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.
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>
<div class="header">
<div id="navigation">
<div class="center">
<div class="logo"></div>
<ul class="right">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
</div>
------------------------C S S--------------------------------
#navigation {
position:fixed;
display:block;
top: 0;
width: 100%;
height:35px;
padding-top: 15px;
-webkit-box-shadow: 0px 0px 8px 0px #000000;
background-color: rgba(1,1,1,0.8);
color:rgba(1,1,1,0.8);
border-bottom:1px solid black;
}
.center {width: 1000px; margin: 0 auto;}
div.logo {display:inline-block;
}
ul, li {
padding:0;
margin:0;
}
#navigation ul {
list-style: none;
float:right;
}
#navigation ul li {
display:inline;
}
#navigation a {
text-decoration:none;
font-size:14px;
padding: 0 15px;
color:white;
}
#navigation a:hover {
color: grey;
}
#content {
width: 800px;
margin: 0 auto;
margin-top: 80px;
}
an example would be like this
fiddle
you can modify the code for you
HTML:
<div class="containerc">
<div class="navbarc" id="navbarc">
<div class="username">
<!-- base menu -->
<ul>
<li onmouseover="showsubmenu()" onmouseout="hidesubmenu()"> <div id="menuname"> Menu </div>
<!-- actual menu -->
<ul>
<li> sub1 hover here
<!-- sub menu -->
<ul>
<li> submenu 2
</li>
<!-- for more submenu within sub menu add ul tags and li tags within that here -->
</ul>
</li>
<li>Logout
</li>
</ul>
</li>
</ul>
</div>
</div>
CSS:
.containerc>.navbarc { //setting the dimensions and font properties
padding-left:15px;
padding-right:15px;
padding-top:0px;
margin-left:auto;
margin-right:auto;
font-size:18px;
font-style:bold;
z-index:10;
}
.navbarc {
width:100%; //to occupy the full width of screen
height:45px;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #494846), color-stop(1, #0a0909));
border:1px solid #e7e7e7;
position:fixed; // this will take menu bar along the vertical scroll
color: white;
}
#navbarc ul {
margin: 0;
padding: 0;
list-style: none;
}
#navbarc a:link, #navbarc a:visited { //changing the style properties of anchor tags
color: white;
text-decoration: none; //removes the underline
}
#navbarc a {
display: block;
padding: 6px 8px;
}
#navbarc li {
float: left;
margin-right: 1px;
position: relative;
}
#navbarc li li { //for properties of submenu
width: 160px;
margin-top: 1px;
background-color: #494846;
}
#navbarc li:hover { //on hover change the background color
background-color: #6E6E6E;
}
#navbarc li li:hover {
background-color: #6E6E6E;
}
#navbarc ul ul { //for properties of submenu
position: absolute;
visibility: hidden;
font-size:15px;
}
#navbarc ul ul ul { //for properties of submenu within submenus
position: absolute;
left: 100%;
top: -2px;
border: solid 1px transparent;
}
#navbarc li:hover > ul { // on hover show the submenu
visibility: visible;
}
.menuname { //styling for base menu
display:inline-block;
padding-top:10px;
position:relative;
}
Javascript
$(document).ready(function(){
$("#navbarc ul ul").hide(); //to hide expanded menu initially
function showsubmenu() {
$("#navbarc ul ul").show(); //to show the list on function call
}
function hidesubmenu() {
$("#navbarc ul ul").hide(); // to hide the list on function call
}
});