Edit Mission accomplished, thank you for your replies. If anyone can help me with the click to expand/fade to view feature, it would be very helpful. I'm currently looking into it.
I am working on a very simple navigation for my website. I can't figure out why the texts can't stick to the right. Here is an example: http://jsfiddle.net/E6ArK/
I also hope to add a click-to-expand and maybe a fade into view feature some time. Any help would be much appreciated.
HTML
<div class="navigation">
<ul>
<li>
<h1>Applications</h1>
<ul>
<li>Not Available</li>
<li>Not Available</li>
</ul>
</li>
<li>
<h1>Forum</h1>
<ul>
<li>Not Available</li>
<li>Not Available</li>
</ul>
</li>
<li>
<h1>Guilds</h1>
<ul>
<li>Not Available</li>
<li>Not Available</li>
</ul>
</li>
<li>
<h1>Imageboards</h1>
<ul>
<li>People</li>
<li>Random</li>
<li>Screen Shots</li>
<li>Wallpapers</li>
</ul>
</li>
<li>
<h1>Projects</h1>
<ul>
<li>Not Available</li>
<li>Not Available</li>
</ul>
</li>
</ul>
</div>
CSS
/* NAVIGATION */
/* Heading */
.navigation ul li h1 {
background : #000000;
color : #ffffff;
display : table;
font-weight : 100;
margin : 0;
padding : 6px;
border-right : 3px solid #ffffff;
font-size : 28px;
margin-bottom : 3px;
}
/* Positioning */
.navigation {
font-family :'Open Sans Condensed', sans-serif;
margin : 12px;
position : fixed;
right : 0;
top : 0;
}
.navigation ul {
font-size : 20px;
margin : 0;
padding : 0;
text-align : right;
}
.navigation ul li {
clear : right;
color : #ffffff;
float : right;
list-style-type : none;
}
/* Second Level */
.navigation ul li ul {
display : none;
}
.navigation ul li:hover ul {
display : block;
}
.navigation ul li ul li {
background : #000000;
border-right : 3px solid #ff0000;
color : #ffffff;
display : table;
font-size : 18px;
margin-bottom : 3px;
padding : 6px;
}
You need to float the heading to the right as well. Add float: right to your block of rules for .navigation ul li h1. That should keep them stuck to the right.
You simply need to add a float:right property to your heading styling:
/* Heading */
.navigation ul li h1 {
background : #000000;
color : #ffffff;
display : table;
font-weight : 100;
margin : 0;
padding : 6px;
border-right : 3px solid #ffffff;
font-size : 28px;
margin-bottom : 3px;
float: right;
}
Hope that helps
Related
My responsive page has a nav menu on top. But for mobile resolution I created a button that opens up a ul of that nav bar upon clicking. It should work given the code, but it does not appear. I have tried my best to make it work but nothing seems to work. I still do not use javascript and I don't want to for the time being. So I wish to make it work using only CSS.
I tried this method to transform a div. Which absolutely worked fine.
#check:checked ~ .uno {
But if I use this same method to show the ul (as below) upon clicking the invisible checkbox, it doesn't work.
#check:checked ~ #nav-list{(to make it display block from display none)
Here's the code of the whole thing.
nav {
background-color : #0e1317;
width : 100%;
position : absolute;
z-index : 2;
height : 300px;
}
nav .navbar {
display : flex;
justify-content : space-between;
width : 95%;
margin : auto;
background-color : #0e1317;
padding : 20px 0;
}
#nav-list {
font-size: 1.4rem;
font-weight: 500;
}
.uno, .duo {
position : absolute;
height : 2px;
right : 15px;
top : 35px;
width : 25px;
background-color : aliceblue;
transition : all 1s;
}
.duo {
top : 45px;
}
#check:checked~.duo {
rotate : -45deg;
transform : translate(5px, -5px);
}
#check:checked~.uno {
rotate: 45deg;
transform: translate(2px, 2px);
}
.visually-hidden {
width : 40px;
height : 40px;
position : absolute;
right : 6px;
top : 18px;
background-color : #090c0f;
opacity : 0;
z-index : 4;
}
#check:checked~#nav-list {
display : block;
position : absolute;
z-index : 9;
}
#nav-list li {
float : left;
list-style : none;
position : relative;
}
#nav-list li a {
padding : 0 20px;
display : block;
position : relative;
}
nav ul ul {
display : none;
list-style : none;
}
li:hover>ul {
width : fit-content;
position : absolute;
display : block;
color : #b98d69;
transition : 0.75s;
top : 0;
padding : 35px 0;
}
nav ul li a:hover {
color : #b98d69;
transition : 0.75s;
}
.sub-child li {
background-color : #090c0f;
width : 200px;
padding : 5px 0;
font-weight : 300;
}
.sub-child li a {
padding-top : 15px !important;
padding-bottom : 15px !important;
font-size : 1.3rem;
}
#media (min-width: 1000px) /* Swiper Content Container till 1000px*/
{
#hamcross {
display : none;
}
#check {
display : none;
}
}
#media (max-width: 1000px) and (min-width: 100px) /* Swiper Content Container below 1000px*/
{
.book-a-table {
display : none;
}
.uno,.duo {
position : absolute;
height : 2px;
right : 15px;
top : 35px;
width : 25px;
background-color : aliceblue;
transition : all 1s;
}
.duo {
top: 45px;
}
#check:checked~.duo {
rotate: -45deg;
transform : translate(5px, -5px);
}
#check:checked~.uno {
rotate: 45deg;
transform : translate(2px, 2px);
}
.visually-hidden {
width : 40px;
height : 40px;
position : absolute;
right : 6px;
top : 18px;
background-color : #090c0f;
opacity : 0;
z-index : 4;
}
#nav-list {
display : none;
}
#check:checked~#nav-list {
display : block;
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" />
<nav>
<div class="navbar">
<ul id="nav-list">
<li>
HOME:-<i class="fa-solid fa-angle-down ficont"></i>
<ul class="sub-child">
<li>COFFEE HOUSE</li>
<li>RESTAURANT</li>
</ul>
</li>
<li>ABOUT</li>
<li>
MENU:-<i class="fa-solid fa-angle-down ficont"></i>
<ul class="sub-child">
<li>MENU COFFEE</li>
<li>MENU RESTAURANT</li>
</ul>
</li>
<li>
PAGES:-<i class="fa-solid fa-angle-down ficont"></i>
<ul class="sub-child">
<li>SERVICE</li>
<li>RESERVATION</li>
<li>HISTORY</li>
<li>OUR CHEFS</li>
<li>GALLERY</li>
<li>FAQS</li>
</ul>
</li>
<li>
BLOG:-<i class="fa-solid fa-angle-down ficont"></i>
<ul class="sub-child">
<li>BLOG GRID</li>
<li>BLOG STANDARD</li>
<li>BLOG SINGLE</li>
</ul>
</li>
<li>CONTACTS</li>
</ul>
<div id="hamcross">
<input type="checkbox" id="check" class="visually-hidden" />
<div class="uno"></div>
<div class="duo"></div>
</div>
</div>
</nav>
Pardon the long blocks of inefficient code. I am still learning, and would appreciate any help.
The reason your nav is not showing up is nav-list is a sibling to hamcross, hamcross is a parent to checkbox, uno and duo. Which means nav-list is like an uncle to checkbox, that is why #check:checked ~ #nav-list does not work. You need to have a hierarchy that you can traverse the dom with.
Check out this link for 10 examples css only!
Taking an ultra-basic HTML class and just need to submit this project so I don't fail the class. On my simply ugly-ass menu I get a vertical black bar inside my buttons to the left of the text on every button except "Home". Thank you for your help stay cool B)
My nav code is:
<style>
nav ul {list-style-type :none;
margin : 0 25% 0 25%;}
nav ul li {
float : center;
}
article {clear : left;}
nav ul li {
float : left;
margin-right : 1em;
margin-bottom : 1em;
text-align:center;
}
nav ul li a {
text-align:center;
padding : 0.25em .5em;
text-decoration : bold;
background-color : tan;
color : black;
border : 1px solid black;
border-top-left-radius : 0em 0em;
border-top-right-radius : 0em 0em;
}
</style>
</head>
<body>
<header>
<h1>Fish Stories</h1>
</header>
<nav>
<ul>
<li><a href="index.html">Home</li>
<li><a href="teenfishes.html">Teen Fisherman</li>
<li><a href="alienfish.html">Alien Fish</li>
<li>Jean Sot</li>
</ul>
</nav>
Correct your HTML code structure as below.
<ul>
<li>Home</li>
<li>Teen Fisherman</li>
<li>Alien Fish</li>
<li>Jean Sot</li>
</ul>
I'm having two problems regarding sub-menu.
I'm using Twitter Bootstrap 3. This version doesn't support the sub-menus so I've found a piece of CSS code which makes it possible to use.
But now I'm running two problems:
1). The sub-menu positioning. The child elements aren't under the parent element. They have a fixed position. I have made many code modifications but had no luck...
2). Second problem is that sometimes it is impossible to focus on sub-menu. This example could be seen in English version of demo template under 'contacts': http://www.01kuzma.tk/en/
The first problem could be seen here: http://www.01kuzma.tk/ru/ but it is Russian version of demo template.
The code which I'm using to style the sub-menu is:
.custom div.moduletable ul.nav, html body div#page div#midlle.row div.col-md-6 div#component nav.navbar div.moduletable ul.nav{
display: block; position: static; margin-bottom: 5px;
}
.dropdown-submenu{
position:relative;
}
.dropdown-submenu > .dropdown-menu
{
top:100%;
left:80%;
margin-top:-6px;
margin-left:-1px;
-webkit-border-radius:0 6px 6px 6px;
-moz-border-radius:0 6px 6px 6px;
border-radius:0 6px 6px 6px;
}
.dropdown-submenu:hover > .dropdown-menu{
display:block;
}
.dropdown-submenu > a:after{
display:block;
content:" ";
float:right;
width:0;
height:0;
border-color:transparent;
border-style:solid;
border-width:5px 5px 0;
border-top-color:#cccccc;
margin-top:5px;
margin-right:-10px;
}
.dropdown-submenu:hover > a:after{
border-top-color:#ffffff;
}
The main css file named as style0.css
Thank you in advance!
I have made this quiclky, may be it can help you :
http://jsfiddle.net/RUn6S/1/
HTML :
<div class="menu">
<ul class="list">
<li class="item">Contains sub menu
<ul class="list">
<li class="item">Sub item</li>
<li class="item">Sub item</li>
</ul>
</li>
<li class="item">Contains sub menu
<ul class="list">
<li>Sub item</li>
<li class="item">
Sub item
<ul class="list">
<li class="item">Sub item</li>
<li class="item">Sub item</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
CSS :
.menu
{
height: 25px;
background-color: #111111;
}
.menu a
{
color : gray;
text-decoration : none;
}
.menu a:hover
{
color : white;
text-decoration : none;
}
.list
{
list-style-type : none;
padding:0;
}
.item
{
position : relative;
display : inline-block;
vertical-align : top;
width : 150px;
}
.item>.list
{
display : none;
background-color : #222222;
}
.item:hover>.list
{
display : block;
}
I am doing a website for school, and it's been going well. The only problem I am stuck on is this: The navbar changes size on different sized screens. It's most readily apparent when zooming out, but it is slightly off on different screens.
Here is a screenshot of what I mean:
https://docs.google.com/a/g.ccsd.net/file/d/0B_Sda_-LouAKbnVKVHhMSW5yeXc/edit?usp=sharing
Please note that the left side, which is the problem, moves around a lot depending on the scale. The above image is only one example.
This is my CSS:
ul {
font-family: 'Open Sans', Times;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
position: relative;
float: right;
z-index: 150;
/* min-width: 739px;
max-width: 739px; */
}
ul li {
display: block;
position: relative;
float: right;
}
li ul { display: none; }
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 7px solid #CC4D4D;
padding: 25px 26.45px 30px 26.45px; /*top right bottom left*/
background: #333333;
margin-left: 0px;
white-space: nowrap;
}
ul li a:hover { background: #757575; }
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
}
li:hover a { background: #757575; }
li:hover li a:hover { background: #757575; }
This is my HTML:
<ul id="menu">
<li>Showcase</li>
<li>Contact</li>
<li>FAQ</li>
<li>Faculty
<ul>
<li>Mrs. Rosarita Olvina</li>
<li>Mrs. Christine Pavesich</li>
<li>Mr. Francisco Virella</li>
<li>Mrs. Susan Williams</li>
</ul>
</li>
<li>Program Areas
<ul>
<li>Graphic Design</li>
<li>Photography</li>
<li>Video Production</li>
<li>Animation</li>
<li>Art</li>
</ul>
</li>
<li>About
<ul>
<li>What We Do</li>
<li>Where We Go</li>
</ul>
</li>
<li>Home</li>
</ul>
Thank you for any help.
***I tried first answer, it didn't work, but I may be doing it very wrong.
The problem is not necessarily within the menu. Rather the whole menu (or its container) needs to be placed properly.
As far as I can tell from the code you've given, the floats may also play a part in fixing this. The whole menu and nested ULs are floating. My suggestion would be to avoid these floats and work with "display: inline-block" instead to get the horizontal arrangement.
After streamlining the menu entries like that, you can properly position your whole menu container in the surrounding HTML.
In case you don't already use it: Firebug or Chromebug plugins are really handy for identifying errors like this.
Ok hey guys.
So what I try to acheive is to have a menu in the topnav of my site and when hovring the mouse over to show some stuff in a list under it.
so far I'm working on local on a test html file until I get it working.
so what i got so far is this menu:
<ul id="menu">
<li>Notifications
<ul>
<li id="foot-notify-954>
Xtesting left a comment for your blog 22 hours ago
</li>
<li id="foot-notify-953>
X
<p>testing left a comment for your blog <span>22 hours ago</span></p>
</li>
</ul>
</li>
and my css code:
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul { display: none }
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #2C5463;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover { background: #617F8A }
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
}
li:hover a { background: #617F8A }
li:hover li a:hover { background: #95A9B1 }
I think the problem is that I'm having more than 1 <a> hyperlink inside the notifications <li>
id like each li notification to show in 1 line, as in the format, the X button at the start to remove it then the notification itself.
First, you have to check the html syntax:
list should looks like this:
<ul>
<li>Coffee</li>
<li>Tea</li>
<li><a href='#'>Milk</a></li>
</ul>
This tool helps you find the errors (red highlighted):
http://jsbin.com/emowir/1/edit
Here is your example:
<ul id="menu">
<!-- type 1: NOT drop down-->
<li>Home</li>
<!--type 2: drop down-->
<li>About Us
<ul>
<li>The Team</li>
<li>History</li>
<li>Vision</li>
</ul>
</li>
</ul>
What would you like to insert and where?
Your problem does seem to be bad code formatting. This is a clean and edited version of your code. The code "breaking" is an issue of CSS formatting. Using inline-blocks instead of blocks helps get things lined up properly, and shifting the background style to the <li> rather than the <a> makes it look better.
Your problem is the following:
ul li a {
display: block;
This makes every link you insert into the list a block. Try start to float things like in this example I made from your code, http://jsfiddle.net/xN8sc/1/