Trying to understand the twitter bootstrap 3 sidebar navigation, e.g.: http://getbootstrap.com/javascript/
Here are already many questions about it (mainly about the affix), but i have an specific one.
I understand:
how to affix the sidebar, e.g.
$('#sidemenu').affix({
offset: {
top: 60
}
});
also is easy the scrollspy alone.
What i don't understand how is achieved the scrollspy + expanding submenus, e.g. in only the active chapter are shown the subchapters (what are also scrollspy-ed). As in red circle in the next screenshot:
Could someone explain what is basic principe? It is achieved with pure CSS (AFAIK), but when I'm, reading thru the http://getbootstrap.com/assets/css/docs.min.css didn't find how it is achieved.
Are you asking how only on larger views they show the sub-menu and on small they don't?
Before the media queries you will find that the ul is hidden:
.bs-docs-sidebar .nav .nav {
display: none;
padding-bottom: 10px;
}
Then when it's .active INSIDE the media queries it displays:
#media (min-width:992px) {
.bs-docs-sidebar .nav>.active>ul {
display: block
}
.... more styles go here ....
}
TIP: don't look at minified CSS.
If you're wondering how the scrollspy is achieved on the sub menu items, it's the same way as the large, each ID of the content corresponds with the link in the menu.
Related
I have two adjacent divs. One has only a single header ("MENU"). The second one is a simple table of contents. I want to show the table of contents iff user's screen width is >= 800px. In any other situation, the MENU div is hidden and table of contents is visible by default.
In order to show/hide table of contents based on screen size I use:
#media screen and (max-width: 800px) {
#tableOfContents { display: none; }
#menuSign { display: block}
I figured out how to show the table of contents when user hovers over MENU sign but I have no idea how to make it stay visible when the cursor moves from one div to the other.
#menuSign:hover + #tableOfContents {
display: block;
background: #f00;
cursor: default;
background-color: darkgray;
color: white;
}
Sorry if the answer to my question is obvious- I'm completely new to web development. All answers to similar problems either used JS (which I cannot do) or did't explain how to make table of contents persist on the screen.
If the divs have no empty space between them and the cursor can flow seamlessly from one to the other, you might try to change the selector into:
#menuSign:hover + #tableOfContents, #tableOfContents:hover { display: block; }
Also, as a personal suggestion, you should try never to use IDs in your CSS, it's bad practice: https://dev.to/claireparker/reasons-not-to-use-ids-in-css-4ni4
Moreover, if you are attempting to create a simple hamburger navigation menu, it's better to show the menu itself when the user clicks on the button instead of just hovering over it, for consistency with devices that don't have the hover functionality like mobile phones. This can be achieved in a number of different ways, the simplest involving some very simple JavaScript (or jQuery, for the simpler syntax) to add or remove a class on the DOM parent of the elements you are attempting to style now, or with hacks like using a checkbox as a proxy for the menu button.
I am learning as i go for a new website i am working on, never done custom css before. (am noob, please be nice)
Using Theme bemart from themeforest, Kingcomposer Pro, and wordpress.
(current plugin for widget css is zigwidgetclass)
www.aboutautomation.com.au (for inspect element)
I am trying to remove the border on just ONE widget on the side bar (custom_html-9) it is currently being inherited from the theme customisation and when edited will change all borders, which is undesirable. i am wanting to either make this a css class for this widget either making it #ffffff
but i cant manage to get it going, the only thing i have managed is to make it disappear completely with
.hide {
border: #ffffff; }
i am not even sure how that happened?!
does have a custom css on it already hide_on_mobile
#media only screen and (max-width:768px) {
.hide_on_mobile {
display: none !important;}
}
I'd go with:
#custom_html-9 .custom-html-widget {
border: transparent;
}
The contents shift if you removed the border completely (as they take up space) so set the border to transparent so you cannot see it but continues to take up space.
You could also use any combo of CSS classes on the parent aside elements and the inner div. Some other options include:
.sidebar .widget_text .textwidget
.sidebar .widget_text .custom-html-widget
.sidebar .widget_custom_html .textwidget
.sidebar .widget_custom_html .custom-html-widget
The current border is being applied with multiple CSS selectors and it looks like you'll need at least 3 classes or an ID in your selector in order to override the original.
I have an image slider on a website I am currently working on:
http://scientized.com/ (first part on the main page)
As you can see it works beautifully. Now I am trying to put the same image slider on a page:
http://scientized.com/mathematics/
As you can see it becomes slightly misaligned. The images do not slide edge to edge. I have been at for some hours now and cant seem to find where the problem is occurring.
It is a wordpress site, and the slider is a widget I've been working on.
All content is currently dummy content - don't read too much into it.
Anyone can spot the error in my css code?
Your ul has a margin on it on the faulty page. Change to this ...
.entry-content ul {
margin-left: 0 ;
}
But be aware it will affect other ul on Wordpress pages. Target a different class if possible.
EDIT: it's in your code as .entry-content ul ul
EDIT 2: you can target .slides, like this:
.slides {
margin-left: 0;
}
I seem to be having an issue with my one page navigation website. When I push my keys down or even scroll down the links don't change. What am I doing wrong?There is a video that I posted about the issue I'm having.
https://www.youtube.com/watch?v=yK_tjT536bA
So you have two choices looking at your existing code. You can either get this functionality using bootstrap javascript, or jquery.nav, which is the one I think you're trying to use. I'll give example usage for both, regardless.
Bootstrap
$('body').scrollspy({ target: '#navbar-example' });
where #navbar-example is the ID or class of the parent element of any Bootstrap .nav component.
Jquery.nav
$('#nav').onePageNav({
changeHash: true,
scrollSpeed: 750,
});
If you look at your code, your equivalent of this first line is incorrect (you have $('#nav').onePageNav();).
You also need to target the navbar <li> tag when the class .current is applied:
.navbar-default .navbar-nav > li.current > a {
color:#333;
}
Demo fiddle. I made the navbar fixed using class navbar-fixed-top so it was more obvious.
I am trying to create a menu bar that has 2 levels of menus. The top menu is is the main one. Then the second level underneath it has some sub category items. Right now you need to click on the main menu first and load that page to get see the sub category menu items for that section because they are just hard coded into the page. I want to make it so that when you hover over the main menu items that it will load the sub menu.
Here is a jsFiddle of the navigation area and CSS
Here are a couple of screenshots of what it looks like
What would be my best method of accomplishing this. I'm not the most experienced but I got a pretty good grasp of HTML and CSS. Any help in the right direction would be great. Thanks.
I've made this type of menu in the past, I've created a copy of the code you can find here http://jsfiddle.net/PWFGd/24/
The property you want to use is:
selector{
display: none;
}
selector:hover{
display: block;
}
Hope it helps.
Aymeric.
You can use a general sibling combinator (~) with your current structure to accomplish something like this. Use the hover pseudo element to toggle the display state (or visiblity) of the submenu.
http://jsfiddle.net/PWFGd/25/
/* on hover of mainmenu, find subnav and show it */
.mainMenu:hover ~ ul.subNav {
display: block;
}
ul.subNav{
display: none; /* hide submenu */
font:normal 11px/12px Arial, Helvetica, sans-serif;
padding:4px 0 0 0;
}
There are plenty of examples on the net of css based navigation menus. I think you might want to rethink your html structure and use one of those. Google
# Aymeric answer is good one, its also called "2 level horizontal navigation in CSS" i often use them in my projects,
here is demo what u looking for
complete tutorial link