How to separate child element from parent in css? - css

I'm triying to combine these two menus:
http://tympanus.net/codrops/2013/05/08/responsive-retina-ready-menu/
http://tympanus.net/codrops/2010/11/25/overlay-effect-menu/
The first one will stay unchanged and the submenu in the second one will be used with it. But as i begin to change the css code and make these to merge, i always encounter a particular error. The "ul,li and a" properties of the "responsive-retina-ready-menu" effects the submenu that i take from "overlay-effect-menu" and i can not separate these properties. I mean it shows the submenu as it has the same style with the main menu. What can i do about it?
The one i have:
<div class="main clearfix">
<nav id="menu" class="nav">
<ul>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-home"></i>
</span>
<span>Menu 1</span>
</a><div class="cbp-hrsub">
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-services"></i>
</span>
<span>Menu 2</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-portfolio"></i>
</span>
<span>Menu 3</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-blog"></i>
</span>
<span>Menu 4</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-team"></i>
</span>
<span>Menu 5</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-contact"></i>
</span>
<span>Menu 6</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-contact"></i>
</span>
<span>Menu 7</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-contact"></i>
</span>
<span>Menu 8</span>
</a>
</li>
</ul>
</nav>
</div>
The one i want:
<div class="main clearfix">
<nav id="menu" class="nav">
<ul>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-home"></i>
</span>
<span>Menu 1</span>
</a><div class="cbp-hrsub">
<div class="cbp-hrsub-inner">
<div>
<h4>Learning & Games</h4>
<ul>
<li>Catch the Bullet</li>
<li>Snoopydoo</li>
<li>Fallen Angel</li>
<li>Sui Maker</li>
<li>Wave Master</li>
<li>Golf Pro</li>
</ul>
</div>
<div>
<h4>Utilities</h4>
<ul>
<li>Gadget Finder</li>
<li>Green Tree Express</li>
<li>Green Tree Pro</li>
<li>Wobbler 3.0</li>
<li>Coolkid</li>
</ul>
</div>
<div>
<h4>Education</h4>
<ul>
<li>Learn Thai</li>
<li>Math Genius</li>
<li>Chemokid</li>
</ul>
<h4>Professionals</h4>
<ul>
<li>Success 1.0</li>
<li>Moneymaker</li>
</ul>
</div>
</div><!-- /cbp-hrsub-inner -->
</div>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-services"></i>
</span>
<span>Menu 2</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-portfolio"></i>
</span>
<span>Menu 3</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-blog"></i>
</span>
<span>Menu 4</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-team"></i>
</span>
<span>Menu 5</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-contact"></i>
</span>
<span>Menu 6</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-contact"></i>
</span>
<span>Menu 7</span>
</a>
</li>
<li>
<a href="#">
<span class="icon">
<i aria-hidden="true" class="icon-contact"></i>
</span>
<span>Menu 8</span>
</a>
</li>
</ul>
</nav>
</div>

Like I mentioned in my comments you need to specify the styles of parent and children elements separately.
For example, in order to set list-style:none to parent uls you need the following CSS selector:
ul {
list-style:none;
}
To keep the default styling to children uls, you need to add the following selector after the previous one:
ul ul {
list-style:disc;
}
Here's a demo based on the HTML given in OP with minimal styling but illustrating the way you can style parent and child elements separately. (Note: Hover on Menu 1)

Related

Bulma wrong column width with default CSS

I am a beginner and use Bulma CSS and try to make a side menu by default CSS. Everything seems to be simple, but my content in the column is cut and has the wrong width.
`
<div class="columns is-fullheight" style="background-color: lightgrey;">
<aside class="column is-2 section is-narrow-mobile is-hidden-mobile is-fullheight" style="background-color: lightblue;">
<div class="menu">
<p class="menu-label is-hidden-touch">Navigation</p>
<ul class="menu-list">
<li>
<a href="#" class="">
<span class="icon"><i class="fa fa-home"></i></span> Home
</a>
</li>
<li>
<a href="#" class="is-active">
<span class="icon"><i class="fa fa-table"></i></span> Links
</a>
<ul>
<li>
<a href="#">
<span class="icon is-small"><i class="fa fa-link"></i></span> Link1
</a>
</li>
</ul>
</li>
</ul>
</div>
</aside>
</div>
`
Result
If I remove class "columns" I did size what I want
So, what I do incorrect?

Bootstrap 4.1 Vertical Navs how to mr-auto/ml-auto badge

Is navs not navbar
https://getbootstrap.com/docs/4.1/components/navs/#vertical
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" href="#">
<i class="fas fa-angle-right fa-fw"></i>
Link A
<span class="badge badge-warning badge-pill">140</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i class="fas fa-angle-right fa-fw"></i>
Link B
<span class="badge badge-warning badge-pill">300</span>
</a>
</li>
</ul>
tired change
<span class="badge badge-warning badge-pill">
to
<span class="badge badge-warning badge-pill ml-auto">
but didn't work
Edited: see #Temani Afif answer below
if with d-flex only
with d-flex align-items-center solved the problem
You need to make the a element a flex container to be able to use ml-auto/mr-auto. Simply add d-flex to a:
I also added align-items-center to center but it's not mandatory:
.nav {
background:pink;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" >
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link d-flex align-items-center" href="#">
<i class="fas fa-angle-right fa-fw"></i>
Link A
<span class="badge badge-warning badge-pill ml-auto">140</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link d-flex align-items-center" href="#">
<i class="fas fa-angle-right fa-fw"></i>
Link B
<span class="badge badge-warning badge-pill ml-auto">300</span>
</a>
</li>
</ul>

Navigation float right part

I have a question if and how the following is achievable through CSS:
View 1 (large screens):
View 2 (medium-sized screens):
Secondary question: How to center the navigation elements as soon as they are placed in a the second line?
View 3 (mobile):
My problem is, that the right part of the navigation (govel, bookmark, ..., login) should be in the same line as the logo, if there is not enough space (medium-sized screens, View 2). But if mobile navigation gets activated (View 3), I want to be the "Suche", "Kataloge", "Kategorien"... links first.
Also it would be nice if the navigation elements can be centered in (View 2).
The whole thing is build with Bootstrap 3.
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
nav#header img.favicon-logo {
padding-top: 5px;
height: 46px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default" id="header">
<div class="container-fluid">
<!-- Titel und Schalter werden für eine bessere mobile Ansicht zusammengefasst -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu" aria-expanded="false">
<span class="sr-only">Navigation ein-/ausblenden</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="/">
<img src="https://www.lotsearch.de/images/favicons/favicon_144x144.png" class="favicon-logo">
</a>
</div>
<!-- Alle Navigationslinks, Formulare und anderer Inhalt werden hier zusammengefasst und können dann ein- und ausgeblendet werden -->
<div class="navbar-collapse collapse" id="main-menu" aria-expanded="false" style="height: 1px;">
<div class="navbar-inner">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-search"></i>
Suche <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><i class="fa fa-lightbulb-o fa-fw"></i> Suche (Aktuelle Auktionen)</li>
<li><i class="fa fa-archive fa-fw"></i> Suche (Archiv)</li>
</ul>
</li>
<li>
<a href="/auction-catalogs">
<i class="fa fa-book fa-fw"></i>
Kataloge </a>
</li>
<li>
<i class="fa fa-list-alt fa-fw"></i> Kategorien
</li>
<li>
<i class="fa fa-bell fa-fw"></i> Suchaufträge
</li>
<li>
<i class="fa fa-bar-chart fa-fw"></i> Künstler / Analysen
</li>
<li>
<i class="fa fa-newspaper-o fa-fw"></i> Blog
</li>
<li>
<i class="fa fa-star fa-fw"></i> Top-Seiten
</li>
<li>
<i class="fa fa-pencil-square-o fa-fw"></i> Registrieren
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/bids/management/bidlist" title="Vorgemerkte Gebote auf Ihrer Bietliste">
<div class="icon-wrapper hidden-xs">
<i class="fa fa-gavel fa-fw"></i>
<span class="badge badge-orange" id="bidlist-counter">0</span>
</div>
<div class="visible-xs">
<i class="fa fa-gavel fa-fw"></i> Gebote (Bietliste)
</div>
</a>
</li>
<li>
<a href="/favorites" title="Merkzettel">
<div class="icon-wrapper hidden-xs">
<i class="fa fa-bookmark fa-fw"></i>
<span class="badge badge-orange" id="bookmark-counter">0</span>
</div>
<div class="visible-xs">
<i class="fa fa-bookmark fa-fw"></i> Merkzettel
</div>
</a>
</li>
<li class="dropdown">
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="flag-icon flag-icon-de"></span>
<span class=" fa fa-angle-down"></span>
</a>
<ul class="dropdown-menu dropdown-langauge">
<li><span class="flag-icon flag-icon-gb"></span> GB </li>
</ul>
</li>
<li class="dropdown">
<i class="fa fa-user fa-fw"></i> Login <span class="caret"></span>
<ul class="dropdown-menu dropdown-lr animated fadeIn" role="menu">
<li>
<div class="col-lg-12">
<h4>Login</h4>
<form method="post" name="loginform" action="/user/login" id="loginform">
<div class="form-group "><label>Email</label><input name="identity" type="text" tabindex="1" class="form-control" value=""></div>
<div class="form-group ">
<label for="credential">Passwort</label> <span class="pull-right">Passwort vergessen?</span>
<input type="password" name="credential" tabindex="2" class="form-control" value="">
</div>
<div class="form-group "><button type="submit" name="submit" class="form-control btn-orange btn btn-default" tabindex="3" value=""><span class="fa fa-sign-in"></span> Einloggen</button></div>
</form>
<div class="text-center pt-5px">
<p class="pb-5px">- ODER -</p>
<a class="btn btn-default" href="/user/registration/select-product">
<i class="fa fa-pencil-square-o"></i> Registrierung </a>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>

How can i add multi column bootstrap menu in WordPress?

I want to a add 3 column bootstrap menu in WordPress, but i am unable to do this. I have tried a lot, but the sub menus and the columns are not not shows. can any one please help me.
Here is my bootstrap code.
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php bloginfo('url')?>">
<img alt="Brand" src="img/is-logo.png">
</a>
</div>
<!--/.navbar-header-->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
Information <b class="caret"></b>
<ul class="dropdown-menu multi-column columns-3">
<div class="row">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li><span class="icon-airplane"></span> Airlines</li>
<li><span class="icon-github"></span> Animal</li>
<li><span class="icon-apple"></span> Apple</li>
<li>
<a href="#">
<span class="icon-Flag_of_Bangladesh"><span class="path1"></span><span class="path2"></span></span>
Bangladesh
</a>
</li>
<li><span class="icon-twitter"></span> Birds</li>
<li><span class="icon-droplet"></span> Blood</li>
<li><span class="icon-git-cat"></span> Cat</li>
<li>
<a href="#">
<span class="icon-Flag_of_China"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span><span class="path5"></span><span class="path6"></span><span class="path7"></span><span class="path8"></span><span class="path9"></span><span class="path10"></span><span class="path11"></span><span class="path12"></span><span class="path13"></span><span class="path14"></span><span class="path15"></span><span class="path16"></span><span class="path17"></span><span class="path18"></span><span class="path19"></span><span class="path20"></span><span class="path21"></span><span class="path22"></span><span class="path23"></span></span>
China
</a>
</li>
<li>
<a href="#">
<span class="icon-Flag_of_Denmark">
<span class="path1"></span><span class="path2"></span><span class="path3"></span>
</span>Denmark
</a>
</li>
<li><span class="icon-library"></span> Education</li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li><span class="icon-airplane"></span> Airlines</li>
<li><span class="icon-github"></span> Animal</li>
<li><span class="icon-apple"></span> Apple</li>
<li>
<a href="#">
<span class="icon-Flag_of_Bangladesh"><span class="path1"></span><span class="path2"></span></span>
Bangladesh
</a>
</li>
<li><span class="icon-twitter"></span> Birds</li>
<li><span class="icon-droplet"></span> Blood</li>
<li><span class="icon-git-cat"></span> Cat</li>
<li>
<a href="#">
<span class="icon-Flag_of_China"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span><span class="path5"></span><span class="path6"></span><span class="path7"></span><span class="path8"></span><span class="path9"></span><span class="path10"></span><span class="path11"></span><span class="path12"></span><span class="path13"></span><span class="path14"></span><span class="path15"></span><span class="path16"></span><span class="path17"></span><span class="path18"></span><span class="path19"></span><span class="path20"></span><span class="path21"></span><span class="path22"></span><span class="path23"></span></span>
China
</a>
</li>
<li>
<a href="#">
<span class="icon-Flag_of_Denmark">
<span class="path1"></span><span class="path2"></span><span class="path3"></span>
</span>Denmark
</a>
</li>
<li><span class="icon-library"></span> Education</li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li><span class="icon-airplane"></span> Airlines</li>
<li><span class="icon-github"></span> Animal</li>
<li><span class="icon-apple"></span> Apple</li>
<li>
<a href="#">
<span class="icon-Flag_of_Bangladesh"><span class="path1"></span><span class="path2"></span></span>
Bangladesh
</a>
</li>
<li><span class="icon-twitter"></span> Birds</li>
<li><span class="icon-droplet"></span> Blood</li>
<li><span class="icon-git-cat"></span> Cat</li>
<li>
<a href="#">
<span class="icon-Flag_of_China"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span><span class="path5"></span><span class="path6"></span><span class="path7"></span><span class="path8"></span><span class="path9"></span><span class="path10"></span><span class="path11"></span><span class="path12"></span><span class="path13"></span><span class="path14"></span><span class="path15"></span><span class="path16"></span><span class="path17"></span><span class="path18"></span><span class="path19"></span><span class="path20"></span><span class="path21"></span><span class="path22"></span><span class="path23"></span></span>
China
</a>
</li>
<li>
<a href="#">
<span class="icon-Flag_of_Denmark">
<span class="path1"></span><span class="path2"></span><span class="path3"></span>
</span>Denmark
</a>
</li>
<li><span class="icon-library"></span> Education</li>
</ul>
</div>
</div>
</ul>
</li>
</ul>
</div>
</div>
</nav>
dropdown menus wont work noramly in the wordpress so use Walker Class that will make them work

float bootstrap dropdown list above content and right side of the sidebar main menu

I can't figure out how to move the dropdown list so that it gets positioned on the right side of my main menus. Please see this screenshot that I want to achieve. http://i.imgur.com/nlAJgaC.png
Here is the code
<div id="sidebar-left" class="col-xs-2 col-sm-2 hidden-lg">
<ul class="nav main-menu">
<li>
<a href="#" class="align-center">
<i class="fa fa-dashboard"></i>
<span class="adClass hidden-xs">Menu 1</span>
</a>
</li>
<li class="dropdown">
<a class="align-center dropdown-toggle">
<i class="fa fa-print"></i>
<span class="adClass hidden-xs">Odometer</span>
</a>
<ul class="dropdown-menu">
<li><a ng-click="stopIt($event, 'submenu1')">submenu1</a></li>
<li><a ng-click="stopIt($event, 'submenu2')">submenu2</a></li>
<li><a ng-click="stopIt($event, 'submenu3')">submenu3</a></li>
<li><a ng-click="stopIt($event, 'submenu4')">submenu4</a></li>
</ul>
</li>
<li>
<a href="#" class="align-center">
<i class="fa fa-mobile"></i>
<span class="adClass hidden-xs">Menu 2</span>
</a>
</li>
<li>
<a href="#" class="align-center">
<i class="fa fa-flask"></i>
<span class="adClass hidden-xs">Menu 3</span>
</a>
</li>
<li>
<a href="#" class="align-center">
<i class="fa fa-bar-chart-o"></i>
<span class="adClass hidden-xs">Menu 4</span>
</a>
</li>
<li>
<a href="#" class="align-center">
<i class="fa fa-cogs"></i>
<span class="adClass hidden-xs">Menu 5</span>
</a>
</li>
<li>
<a href="#" class="align-center">
<i class="fa fa-clipboard"></i>
<span class="adClass hidden-xs">Menu 6</span>
</a>
</li>
</ul>
</div>
Bootstrap dropdowns use position: absolute; therefore you just need to move it left like:
.dropdown-menu { left: 106px; } just as much left as you need basically
I finally got it working but with the help of AngularJS. It's working great
var captureWidthOfSideBar = function() {
$rootScope.widthSideBar = (document.getElementById('left-sidebarId').offsetWidth + 10).toString() + "px";
};
captureWidthOfSideBar();
var resizeTimeout;
$(window).resize(function() {
if (resizeTimeout) {
$timeout.cancel(resizeTimeout);
}
resizeTimeout = $timeout(function() {
$scope.$apply(function() {
captureWidthOfSideBar();
});
}, 500);
});
then on my template, this is how it's called
<ul id="ddPrinterAnalytics" class="dropdown-menu" ng-style="{left : $root.widthSideBar}">
<li><a ng-click="stopIt($event, 'main.odometer')">Odometers</a></li>
<li><a ng-click="stopIt($event, 'login')">Real Time Print Job</a></li>
<li>Battery</li>
<li>Printhead</li>
</ul>
WOOHOO!!! :)

Resources