I am using the following media query in my bootstrap app.
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
.nav li { width: 100%;
}
.nav .dropdown ul {display:none; }
.nav .open ul { display: block; }
.nav-collapse .nav > li > a, .nav-collapse .dropdown-menu a {
text-align: center;
background-color:#211256;
}
.nav-collapse .nav > li > a:hover,
.nav-collapse .dropdown-menu a:hover {
background-color: #211256;
color:white;
}
.navbar .nav > li a:hover{
color:white;
}
.navbar .nav .active > a, .navbar .nav .active > a:hover {
background: #211256;
color: white;
text-decoration: none;
}
.nav-collapse .nav > li > a, .nav-collapse .dropdown-menu a {
border-radius: 3px 3px 3px 3px;
color: white;
font-weight: bold;
padding: 6px 15px;
margin-bottom:2px;
}
.navbar .nav li.dropdown .dropdown-toggle .caret, .navbar .nav li.dropdown.open .caret {
border-bottom-color: white;
border-top-color: white;
}
.navbar .nav li.dropdown.open > .dropdown-toggle, .navbar .nav li.dropdown.active > .dropdown-toggle, .navbar .nav li.dropdown.open.active > .dropdown-toggle {
background-color: transparent;
color: #211256;
}
.accordion-inner {
border-top: 1px solid #E5E5E5;
padding: 9px 15px;
}
}
When viewing the page in landscape mode
http://46.32.253.11/
the dropdown navbar is open by default and I cant see the bootstrap button, I use exactly the same media query for max-width 979px and the button appears and is closed.
Can anyone advise what selector i need to target to have the ipad show the bootstrap button and hide the dropdown menu until the button is pressed.
Any help appreciated
That would require some JavaScript and I'm going to recommend jQuery for sake of simplicity.
Essentially, you're going to listen for the orientationchange event in JavaScript and then, based on the orientation, invoke a function that will handle the toggle.
$(document).ready(function() {
window.onorientationchange = function() {
var orientation = window.orientation;
switch(orientation) {
case 0: // portrait
break;
case 90: // landscape left
toggler();
break;
case -90: // landscape right
toggler();
break;
}
}
function toggler() {
var toggled = false;
$('.dropdown-toggle').on('click', function() {
if (toggled === false) {
$('.nav .open ul').hide();
$('.nav .dropdown ul').show();
toggled = true;
} else {
$('.nav .dropdown ul').hide();
$('.nav .open ul').show();
toggled = false;
}
});
}
});
Try this out and see if it gets you started in the right direction (pun intended).
Related
I'm brand new to CSS so please forgive me if I'm missing something obvious. I've spent several hours on this and searched this website and have not been able to resolve my issue.
I have a Shiny (R) app that I am trying to add some custom styling to using CSS. I have been making change to the Navbar, which I am happy with so far. However, something in my CSS is causing undesirable behavior in mobile-sized screens, where the tabs of the navbar do not stack vertically and overlap with the main content:
Compared to the default, which is what I would like:
I know this is something related to my CSS because when I disable it this issue is resolved. I have tried many things and nothing so far has helped, I was wondering if someone might be able to point out in my CSS where I have introduced this problem and how I might resolve it.
Thanks in advance. CSS:
/*=============NAVBAR STYLING=============*/
/*Entire navbar*/
.navbar.navbar-default.navbar-static-top{
background-color:white;
height:60px;
/*margin: 10px;*/
margin:0px;
}
/*All navbar tabs*/
.navbar-default .navbar-nav>li>a {
/*Sets consistent height for navbar tabs, must be !important*/
height:60px !important;
justify-content:center;
align-items:center;
display:flex;
}
/*Style the *active* navbar tab*/
.navbar-default .navbar-nav>.active>a{
/*Make the active tab darker in color w/ white text*/
background-color:#676767!important;
color:white!important;
border-radius: 10% / 50%;
}
.nav-link {
position:absolute;
}
/*======Screen-width specific styling=======*/
#media (min-width:1276), (max-width: 1426px) {
.navbar.navbar-default .navbar-nav > li > a {
font-size: 12px;
}
h2 {
font-size:26px;
}
.hometext {
font-size: 18px !important;
}
ol {
font-size: 18px !important;
}
}
#media only screen and (min-width:768px) and (max-width:1275px) {
.navbar.navbar-default .navbar-nav > li > a {
font-size: 11px !important;
margin-top:10px !important;
}
h2 {
font-size:24px;
}
.hometext {
font-size: 16px !important;
}
ol {
font-size: 16px !important;
}
}
/* Next two classes keeps the navbar tabs on the same line in smaller windows */
.min-width{
overflow-x:auto
}
ul.nav{
display:inline-flex
}
}
#media only screen and (min-width:1px) and (max-width:767px) {
.navbar-default .navbar-collapse > li{
display: block!important;
}
.navbar-default .navbar-collapse > li > a {
float: none!important;
/*Removes grey line above tabs (overlaps with logo)*/
.navbar-default .navbar-collapse{
border-color:transparent;
}
}
I need to change the background color of the dropdown menu on my website:
https://institutoschuman.org/
I supposed it was very easy but I'm not able to do it. I've Checked the code of my style.css but I haven't found the lines that determine the color of the dropdown menu. Any suggestion?
You can update your style.css with the CSS below and change your background colour from white (#fff) to one you prefer, that should do it.
#media screen and (max-width: 960px) and (min-width: 0px) {
.respMenu {
background: #fff;
}
.respMenu a {
background: #fff;
}
}
The solution:
.menu ul.sub-menu, .menu ul.children {
margin-top: 65px;
}
.sub-menu > li {
background: white !important;
}
.sub-menu > li:hover {
background: #fcfcf4 !important;
}
.sub-menu > li > a {
color: black !important;
}
.sub-menu > li > a:hover {
color: #008ddb !important;
}
How to change the link's color and font size for the drop down menu when collapsed and NOT change the drop down menu when it is full size?
Here is visually what I'm asking: 1
Here is my present code: http://jsbin.com/bigoxeyuri/edit?css,output
You can see the links in the full size and the collapsed are two different colors - collapsed being the default gray that I want to change.
Thank you.
/*Navbar color full size and collapsed including drop down list*/
.navbar-default {
background-color: #B4A890;
border-color: #B4A890;
}
/*Link color for top links; but not drop down list*/
.navbar-default .navbar-nav > li > a {
color: #f5ebdb;
}
/*Link hover color; full size & collapsed; but not drop downlist*/
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
color: #110a02;
}
/* Drop down menu's Full Size only background color*/
.navbar-nav > li > .dropdown-menu
{ background-color: #ffffff;
font-size: 12px; /*size for full size and collapsed*/
}
/* Link color for drop down list & its rows' hover color for full size menu only*/
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus
{
color: #f5ebdb;
text-decoration: none;
background-color: #B4A890;
background-image: none;
}
/* Drop down list Title Cell background collapsed & full*/
.dropdown-toggle:active, .open .dropdown-toggle
{
background:#f5ebdb !important;
color:#110a02 !important;
}
.nav > li > a:hover,
.nav > li > a:focus {
text-decoration: none; /* affects top main links*/
background-color: white; /* ???Change rollover cell color here*/
}
/*???BACKGROUND color for active*/
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active >
a:hover, .navbar-default .navbar-nav > .active > a:focus {
color: #000000;
background-color: #ffffff;
}
/* 3-bar button - color */
.navbar-toggle {
background-color: #B4A890;
}
/* 3-bar button - stripes */
.navbar-default .navbar-toggle .icon-bar {
background-color: #f5ebdb;
}
/* 3-bar button - color hover */
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
background-color: #c2b89f;
}
/* 3-bar button - border */
.navbar-default .navbar-toggle {
border-color: #c2b89f;
}
this is the solution
/* solution */
#media(max-width:768px){
.navbar-default .navbar-nav .open .dropdown-menu>li>a, .navbar-default .navbar-nav .open .dropdown-menu>li {
color: #FFF;
font-size: 16px;
}
}
i have updated your code
jsbin
The only time the navbar is collapsed is when the screen is a certain size in pixels. You should look into learning about media rules in CSS to learn more.
#media (max-width: 767px) { //mobile width that collapses the navbar
body {
background-color: blue; //changes the background color to blue
}
}
Here is an example on W3 schools
I am trying to add smooth slide hover effect on Bootstrap navbar at this JS Fiddle. What I would like to do is sliding the active class style horizontally on each hovered nav.
As you can see from my try right now styles just jumps on the top of any hovered element and the Active class still stay there.
Here is the CSS I am using for this:
.navbar-nav>li {
width: 120px;
text-align:center
}
.navbar {
margin-bottom: 30px;
}
.navbar .nav > .active > a, .navbar .nav > .active > a:hover, .navbar .nav > .active > a:focus {
background-color: darkgreen;
color: white;
}
.navbar .nav > li > a:hover {
background-color: darkgreen;
color: white;
}
I also used this jQuery which didn't go through:
$( document ).ready(function() {
$(".navbar .nav > li > a").on("mouseenter", function() {
$( '.navbar .nav > li' ).addClass( "active" );
}).on("mouseleave", function() {
$( '.navbar .nav > li' ).removeClass( "active" );
});
});
How can I make the navbar more interactive by adding hover/slide effect?
I am having trouble with my drop down menus. I would like to have multiple columns under one drop down.
http://jsfiddle.net/Ru3Zv/ here is what I am working with.
#navigation-primary > ul > li > h2, #navigation-primary > ul > li > a {
/* font-size of the first level */
font-size: 1em;
line-height: 40px;
}
#navigation-primary > ul > li > h2 > a, #navigation-primary > ul > li > a {
/* links of the first level */
/* text-transform: uppercase; */
color:white;
font-weight: bold;
text-decoration:none;
/* background: #156aa3; */
background: #1f1f1f;
}
#navigation-primary > ul > li > a.active, #navigation-primary > ul > li > h2 > a.active {
/* active state of the first level */
background:#1f1f1f;
color:#fff;
}
#navigation-primary > ul > li > a:hover, #navigation-primary > ul > li > h2 > a:hover, #navigation-primary > ul > li:hover > a, #navigation-primary > ul > li:hover > h2 > a {
/* hover state of the first level */
background:#1f1f1f;
color:#fff;
}
#navigation-primary .mega a {
/* links color inside panel */
color:white;
}
#navigation-primary .mega a:hover {
/* :hover on links inside panel */
color:white;
/* text-decoration:underline; */
font-size:1.10em
}
#navigation-primary .mega ul.megamenu-2 a {
/* color:#4c4b4b;*/
/* This is the color of the submenu items */
color:#ffffff;
}
#navigation-primary h3, #navigation-primary li.menu-section-title > a {
/* primary links subsection titles */
font-size:1.0em;
/* text-transform:uppercase; */
font-weight: bold;
text-decoration:none
}
#navigation-primary li.menu-leaf-list {
/* child links inside the panel */
/* border-bottom: 1px dashed #e2e2e2;*/
}
.mega {
/* border-top: 10px solid #1f1f1f; */
border-bottom: 4px solid #1f1f1f;
border-left:1px solid #1f1f1f;
/* border-right:1px solid #ccc; */
background:#1f1f1f;
white-space:nowrap !important;
width:auto !important;
}
Under the Services menu I would like to have one column with Managed Services then the underlined links below that then in a second column have Consulting Services with the rest of the underlined links below that. This is similar to http://www.workday.com/.
What would I have to change to get this?
Try this module. It might help.
https://drupal.org/project/megamenu
example:
http://www.aaml.org/
For the multiple columns under one drop down use "tb mega menu". Only for drupal 7.
https://drupal.org/project/tb_megamenu