I wanted to create a multi level menu. I have seen yesterday the following page that I would love to do:
https://sbaueraz.github.io/
So I have been watching yesterday some tutorial and tried to create a test drop down menu with Atom (just made a search on the web and found that App, guess it's enough for what I try to do) ,
but does not seem to work properly. At least the css integration.
As I am a real beginner, I copied more or less the code from what I was watching, and tweaking a few things, trying to understand the code of course.
If someone could help me that would be great.
What I have so far (with lots of mistakes):
html,
body {
width: 100%;
margin: 0;
padding: 0;
font-family: helvetica, sans-serif;
}
.multi-level,
.item ul,
.nav input[type="checkbox"] {
display: none;
}
#menu:checked~.multi-level,
.item:checked~ul {
display: block;
}
<div class="nav">
<input type="checkbox" id="menu">
<label for="menu">☰</label>
<div class="multi-level">
<div class="item">
<input type="checkbox" id="A">
<label for="A">Coupant</label>
<ul>
<li><a href="#" </a>Tête</li>
<li><a href="#" </a>corps</li>
<li><a href="#" </a>bras gauche</li>
<li><a href="#" </a>bras droit </li>
</ul>
</div>
<div class="item">
<input type="checkbox" id="B">
<label for="B">Armes à feu</label>
<ul>
<li>
<div class="sub-item">
<input type="checkbox" id="B-A">
<label for="B-A">Tête</label>
<li>
<div class="sub-sub-item">
<input type="checkbox" id="B-A-A">
<label for="B-C">1</label>
<ul>
<li><a>blablablablabla
blablablablabla</a></li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
Related
I'm trying to change a wrapper's background color by pressing the checkbox.
.switch_1:checked~.table_wrapper {
background: black;
}
<li class="nav-item">
<div class="switch_box box_1">
<input type="checkbox" class="switch_1">
</div>
</li>
<div class="table_wrapper">
</div>
If you can't change the DOM structure, you can't do it with CSS but you can do it with JS.
$(".switch_1").change(function () {
$('.table_wrapper').toggleClass('active');
});
.table_wrapper.active {
background: black
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li class="nav-item">
<div class="switch_box box_1">
<input type="checkbox" class="switch_1">
</div>
</li>
<div class="table_wrapper">
asd
</div>
Here's what would work. The element needs to be a sibling (side-by-side) for it to work.
There's currently no "parent selector" in css: Is there a CSS parent selector?
So I think your best option to deliver the functionality you're working towards would be with javaScript.
.switch_1:checked~.table_wrapper {
background: black;
}
<li class="nav-item">
<div class="switch_box box_1">
<input type="checkbox" class="switch_1">
<div class="table_wrapper">hello</div>
</div>
</li>
i have tried This from stackoverflow
which i haven't been able to get to work..
i have .playlist-list and .playlist-feature where only one should be displayed, with a radio button to check on.
so which ever radio button is checked, it should display : block the div. and hide the other.
but it is somehow not working..
I can start out with .playlist-feature being displayed fine, where i check on another button. but here it does not seem to work..
any idea as to a solution to this ?
My code:
html:
<div class="playlist-top">
<label for="playlist-button">Spilleliste</label>
<label for="playlist-feature-button">Indslag</label>
</div>
<input type="radio" id="playlist-list-button" />
<input type="radio" id="playlist-feature-button" />
<div class="playlist-content">
<div class="playlist-list">
<ul class="bar">
<li>
<span>12:36</span ><p class="text- uppercase">brian adams</p><span class="dr-icon-audio-boxed"></span>
<p>You Belong to me</p>
</li>
</ul>
</div>
<div class="playlist-feature">
<ul class="bar">
<li>
<span>08:51</span><span class="dr-icon-audio-boxed"></span>
<p>Gærdesmutten er sej trods sin beskedne størrelse</p>
</li>
</ul>
</div>
</div>
My CSS
#playlist:checked ~div.playlist-toggle{
.playlist-wrapper .container .playlist-content{
.playlist-feature{
display:block;
}
}
}
#playlist-list-button:checked ~div.playlist-toggle{
.playlist-wrapper .container .playlist-content{
.playlist-list{
display:block;
}
.playlist-feature{
display:none;
}
}
}
#playlist-feature-button:checked ~div.playlist-toggle{
.playlist-wrapper .container .playlist-content{
.playlist-feature{
display:block;
}
.playlist-list{
display:none;
}
}
}
I think this one useful for you with jquery
Put this code in your header,
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<style>
.playlist-list{
display: block;
}
.playlist-feature{
display:none;
}
</style>
<script>
$(document).ready(function () {
$('input[type=radio][name=rb1]').change(function () {
if (this.value == 'playlist-list-button') {
$('.playlist-list').show();
$('.playlist-feature').hide();
}
else if (this.value == 'playlist-feature-button') {
$('.playlist-feature').show();
$('.playlist-list').hide();
}
});
});
</script>
And HTML like this
<div class="playlist-top">
<label for="playlist-button" >Spilleliste</label>
<input type="radio" value="playlist-list-button" id="playlist-list-button" name="rb1" checked="" class="rb1" />
<label for="playlist-feature-button" >Indslag</label>
<input type="radio" value="playlist-feature-button" id="playlist-feature-button" name="rb1" class="rb1"/>
</div>
<div class="playlist-content">
<div class="playlist-list">
<ul class="bar">
<li>
<span>12:36</span ><p class="text- uppercase">brian adams</p><span class="dr-icon-audio-boxed"></span>
<p>You Belong to me</p>
</li>
</ul>
</div>
<div class="playlist-feature">
<ul class="bar">
<li>
<span>08:51</span><span class="dr-icon-audio-boxed"></span>
<p>Gærdesmutten er sej trods sin beskedne størrelse</p>
</li>
</ul>
</div>
</div>
i got it to work with this:
because the playlist-content is right under the input, it seems it could access it through that. so i could display the div and hide it at will.
and the class on .playlist-button was wrong.. it should have been .playlist-list-button.. no idea why i didn't see that before..
#playlist-feature-button:checked ~ div.playlist-content {
.playlist-feature {
display: block;
}
.playlist-list {
display: none;
}
}
Some of my issues was trying to follow some tutorials about off-screen navigation menu but they didn't quite fit my requirements.
Here is one example
What I am trying to accomplish here is kinda difficult and I can't find the answer. What I want is to press on the label and toggle the sidebar. Most of the tutorials show that but only when these two are directly related.
<div class="header">
<ul>
<li>Menu1</li>
<li>Menu2</li>
<li>Menu3</li>
<li>
<input type="checkbox" class="sidebar__toggle" id="sidebar__toggle">
<label for="sidebar__toggle">More info</label>
</li>
</ul>
</div>
<div class="content">
...rest of code here...
</div>
<div class="sidebar">
...sidebar code here...
</div>
And css(I'll be omitting the rest for the sake of simplicity):
.sidebar__toggle:checked ~ .sidebar {
background-color: pink;
}
As I followed the various tutorials on the web, this was the method if they we're related somehow, but mine(or THE one I need) actually is not.
You can put the checkbox anywhere you want as long as the label points to its id using the for attribute. I put it in front of .sidebar below:
.sidebar__toggle:checked ~ .sidebar {
background-color: pink;
}
<div class="header">
<ul>
<li>Menu1</li>
<li>Menu2</li>
<li>Menu3</li>
<li>
<label for="sidebar__toggle">More info</label>
</li>
</ul>
</div>
<div class="content">
...rest of code here...
</div>
<input type="checkbox" class="sidebar__toggle" id="sidebar__toggle">
<div class="sidebar">
...sidebar code here...
</div>
Hey guys this is my second question so far on a website i'm re-designing for my boss. I'm trying have it where if the user hovers over "4-Color Offset Printing" the background of the div ID will change to another background-color. (Example blue). I've tried adding #4_color_offset_printing:hover to see if that will just simply change the background color. This usually works but on this navigation bar it seems to not be working. Right now the default background is green. I'd like it to turn blue when i hover over it. I'm trying to apply this affect to every link but if i could get one working i could figure out the rest.
The older style of the navigation bar is the Gray with the blue link hover affect. The last developer that designed the site decided to use inline CSS. I'm not a fan of inline, but even if i try to simply copy and paste his inline code to the main.css it does not take affect. I have no idea why that would be happening. If anybody has any advice that would be great!
Here is my Demo
<style type="text/css"></style></head>
<body class="desktop webkit webkit_525">
<div id="header">
<div class="content_width rel">
<a href="./Welcome to our site!_files/Welcome to our site!.html">
<div id="header_logo"></div>
</a>
<ul id="top_nav">
<li><a class="home_icon" href="./Welcome to our site!_files/Welcome to our site!.html">Home</a></li>
<li>Contact</li>
<li>Estimates</li>
<li>Help Center</li>
<li>Samples</li>
<li>Shopping Cart</li>
<li class="last-child">My Account</li>
</ul>
<ul id="loginbar" class="rounded">
<li>New Account</li>
<li class="last-child">Login</li>
</ul>
<div id="header_products"></div>
<div id="header_phone">Customer Service: (949) 215-9060</div>
<div id="product_search">
<input id="product_ti" class="default" type="text" value="Find A Product">
<input id="product_btn" type="button" value="Search">
<input id="product_default" type="hidden" value="Find A Product">
</div>
</div>
</div>
<div id="nav">
<ul id="nav_links" class="content_width_adjust">
<li id="4_color_offset_printing" style="width:183px; height:44px; background-color:#0C0; border-top: 4px solid #009ad6; -webkit-box-sizing: border-box; -moz-box-sizing: border-box;box-sizing: border-box;" class=""><a class="nav_parent narrow" href=""><span>4-Color Offset Printing</span></a></li>
<li id="large_format" style="width:139px" class=""><a class="nav_parent wide" href=""><span>Large Format</span></a></li>
<li id="1-2_color_printing" style="width:164px"><a class="nav_parent" href=""><span>1&2 Color Printing</span></a></li>
<li id="4_color_digital_printing" style="width:189px"><a class="nav_parent narrow" href=""><span>4-Color Digital Printing</span></a></li>
<li id="roll_labels" style="width:130px" class=""><a class="nav_parent wide" href=""><span>Roll Labels</span></a></li>
<li id="services" class="last " style="width:133px"><a class="nav_parent services" href=""><span>Services</span></a></li>
</ul>
</div>
An elements ID can't start with a number, only classes can. Removing the 4_ from '4_color_offset_printing' so you just have a ID of 'color_offset_printing' will allow you to target it in CSS.
If you really don't want to change your ID's, you can target ID's that begin with a number like this:
[id='4_color_offset_printing'] {
background: blue;
}
But I wouldn't recommend using that, it may not work well in all browsers. Best to do things the right way and not use numbers to start your ID's.
Need to add to the #nav_links li a:hover class
#nav_links li a:hover
{
background-color: blue;
}
https://jsfiddle.net/akdz7udj/7/
I'm using 2 languages on my website: Arabic / English
English version: everything is OK.
I'm facing problem with Arabic version only when opening website on Chrome only, if you can check it here online (Arabic):
Here
You will see top margin above header, I'm trying to remove it but I have no idea where it's coming from but it's removed from English version successfully
It will start above .header-wrapper class.
HTML Code :
<div class="header-wrapper">
<div id="welcome">
<form action="http://staging.wain.com.kw/index.php?route=module/language" method="post" id="language_form" enctype="multipart/form-data">
<div id="language">
<a title="English" onclick="$('input[name=\'language_code\']').attr('value', 'en'); $('#language_form').submit();">
English
</a>
<input type="hidden" name="language_code" value="">
<input type="hidden" name="redirect" value="http://staging.wain.com.kw/index.php?route=common/home">
</div>
</form>
<span>مرحبا بالزائر يمكنك</span>تسجيل الدخول<b>أو</b>تسجيل جديد
<div class="links">
حسابي <ul>
<li>حسابي</li>
<li>سلة الشراء</li>
<li>إكمال الطلب</li>
</ul>
</div>
قائمة المقارنة
قائمة رغباتي (0)
</div>
<div id="header" class="sunset">
<div id="menu">
<span>Menu</span>
<ul>
<li class="home"><a title="الرئيسية" href="http://staging.wain.com.kw/index.php?route=common/home"><span><i class="icon-home"></i></span></a></li>
<li>أكواب
</li>
<li>الإكسسوارات
</li>
<li>بوستر
</li>
<li>سماعات
</li>
<li>ملابس
<div>
<ul>
<li>تي شيرت (19)</li>
<li>طويلة الأكمام (2)</li>
<li>قبعات (2)</li>
<li>هودي (3)</li>
</ul>
</div>
</li>
<li>ملصقات
</li>
</ul>
</div>
<div id="logo"><img src="http://staging.wain.com.kw/image/data/logo2.png" title="WAIN" alt="WAIN"></div>
<div id="cart">
<div class="heading">
<h4><i class="icon-shopping-cart"></i><!--سلة الشراء--></h4>
<a><span id="cart-total">سلة الشراء فارغة!</span></a></div>
<div class="content">
<div class="empty">سلة الشراء فارغة!</div>
</div>
</div> </div>
</div>
CSS Code:
.header-wrapper {
max-width: 1200px;
margin: 0px auto 0px;
}
Thank you.
Right after you <body> tag there is a lot of white-space. remove it and the space is gone.
It's generally recommended to keep the markup as clean as possible to avoid porblems like this in the future.
<body>
<meta charset="UTF-8">
After the body tag, there is a whitespace. You need to remove that white space to avoid the margin top.