How to prevent absolute position <ul> inside <li> to change its width? - background

I'm trying to achieve this effect.
Say we have this structure:
<ul id="menu">
<li>Guides
<ul>
<li>Getting Started</li>
<li>Characters</li>
<li>Epics</li>
<li>Road Map</li>
</ul>
</li>
<li>Skills</li>
<li>Equipments</li>
</ul>
and this simplified CSS:
ul#menu {
display:inline-block;
list-style-type:none;
padding:0;
height:30px; /* So the ul#menu's height isn't changed by the ul#menu>li>ul */
overflow:visible; /* So the ul#menu>li>ul is visible on ul#menu>li:hover */
background: #e69646;
box-shadow:0 2px 3px 0 #666;
}
ul#menu>li>ul {
list-style-type:none;
padding:0;
position:absolute;
background:inherit; /* */
box-shadow:inherit;
}
The problem is that having ul#menu>li>ul on absolute positioning makes it lose it's background gradient and shadow. background:inherit and box-shadow:inherit yield this result.
Is there a way to achieve the desired result?
Thank you in advance guys :)

This is the way I would do it - http://jsfiddle.net/bh6L5/3/
<ul id="menu">
<li>Guides
<ul>
<li>Getting Started</li>
<li>Characters</li>
<li>Epics</li>
<li>Road Map</li>
<div id="fake">Guides</div>
</ul>
</li>
<li>Skills</li>
<li>Equipments</li>
</ul>
Then add this to your css
#fake {
position:absolute;
width:45px;
height:31px;
padding:0 10px;
background: #e69646;
z-index:999;
top: -31px;
left:0px;
border-top-left-radius:5px;
border-top-right-radius:5px;
-webkit-border-radius-topleft:5px;
-webkit-border-radius-topright:5px;
-moz-border-radius-topleft:5px;
-moz-border-radius-topright:5px;
}

Related

How can I add a class to a popover with vue boostrap?

I have:
<li class="nav-item">
<b-popover
target="search-button"
placement="topleft"
title="Search"
triggers="click"
content="Placement"
container="nav-container"
>
<template slot="title">Interactive Content</template>
<template slot="content">Interactive Content</template>
</b-popover>
<a class="nav-link" href="#" title="Popover Title" id="search-button">
<i class="material-icons md-48">search</i>
</a>
</li>
I want to add a class to the popover, but ideally have it scoped to this component. When I try to do:
<style scoped>
.nav {
background: white;
border-top: 0.1px solid silver;
}
.nav-pills .nav-link {
border-radius: 0;
}
.popover {
width: 100%;
background: red;
}
</style>
It seems to have no impact on the actual popover.
Version 2.0.0-rc.26 (which is to be released soon) adds support for tooltip/popover variants as well as applying custom classes to the tooltip/popover root element.
You can see a preview at https://bootstrap-vue.netlify.com/ (and will appear at https://bootstrap-vue.js.org/ once released)
Its not possible to give class to <b-popover>, you can read here.
But as I mentioned in comment you can use querySelector and give class or styling.
Cheers.

bootstrap navbar always collapsed but when expanded, need to show the width as it is shown when the screen width is shorter

I did the following to make my navigation bar always collapsed. However, when you click on it, it's taking up the whole width of the screen. And when you click on Menu, the dropdown is occupying a small part only.
What I want is when I click the navigation icon in the right, it will expand but will not take the whole width of the screen. Instead I want it to display as it displays when the screen width is small just like in the picture
#media (max-width: 2000px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
}
This is what I need:
Ok, so I'm still not sure why you want a menu inside a menu, but you could use a nav instead of a dropdown if you're looking for full width. The dropdown has a width of 160px. Use collapse to show/hide the submenu.
<a href="#" data-toggle="collapse" data-target="#menu1" role="button" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span>
<span>Menu</span>
</a>
<ul class="nav collapse" aria-labelledby="menu" id="menu1">
<li>
<div class="menu-content">
<ul class="nav nav-stacked">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
</div>
</li>
</ul>
http://bootply.com/cv3l6gxjZn

Correct naming convention for styling only classes in Bootstrap 3?

Im using Twitter Bootstrap 3 and I want to make reusable styling classes. The code below works exactly how I want it to but does it conform to the SMACKS /OOCSS naming convention used by Bootstrap?
Note - Im using LESS not plain CSS so ill be using variables for things like border thickness that are repeated.
<div class="box box-red">
<div class="odd">
First content
</div>
<div class="even">
second content
</div>
<div class="odd">
third content
</div>
</div>
<div class="box box-green">
<div class="odd">
First content
</div>
<div class="even">
second content
</div>
<div class="odd">
third content
</div>
</div>
/* Box styles */
.box {
margin: 10px;
border-radius: 10px;
}
.box > .odd,
.box > .even {
padding: 10px;
}
.box > .odd:last-child,
.box > .even:last-child {
border-bottom: none;
}
/* Red box styles */
.box-red {
background: #ffcccc;
border: 1px solid #ff0000;
}
.box-red > .odd,
.box-red > .even {
border-bottom: 1px solid #ff0000;
}
.box-red > .even {
background: #ff4c4c;
}
/* Green box styles */
.box-green {
background: #BCED91;
border: 1px solid #3B5323;
}
.box-green > .odd,
.box-green > .even {
border-bottom: 1px solid #3B5323;
}
.box-green > .even {
background: #78AB46;
}
http://codepen.io/anon/pen/jduyE
You need to think about what is common between all of the components and what are the differences. In your case, you just want to have different colors, so don't repeat for example the styles for the border-width or border-style. Additionally, it would be tedious and error-prone if you have to markup odd and even rows differently. The :nth-child pseudo class accepts odd and even as keywords. It's important to note that nth-child isn't supported on IE8, but neither is last-child, and you were already using that so I figured that IE8 wasn't important for you.
CSS:
/* Box styles */
.box {
margin: 10px;
border-radius: 10px;
border: 1px solid transparent;
}
.box > .box-content-row {
padding: 10px;
border-bottom: 1px solid transparent;
}
.box > .box-content-row:last-child {
border-bottom: none;
}
/* Red box styles */
.box-red {
background: #ffcccc;
border-color: #ff0000;
}
.box-red > .box-content-row:nth-child(even) {
background: #ff4c4c;
}
.box.box-red > .box-content-row {
border-color: #ff0000;
}
/* Green box styles */
.box-green {
background: #BCED91;
border-color: #3B5323;
}
.box-green > .box-content-row:nth-child(even) {
background: #78AB46;
}
.box.box-green > .box-content-row {
border-color: #3B5323;
}
HTML:
<div class="box box-red">
<div class="box-content-row">
First content
</div>
<div class="box-content-row">
second content
</div>
<div class="box-content-row">
third content
</div>
<div class="box-content-row">
add a fourth div for fun
</div>
<div class="box-content-row">
and what the heck a fifth one too
</div>
</div>
<div class="box box-green">
<div class="box-content-row">
First content
</div>
<div class="box-content-row">
second content
</div>
<div class="box-content-row">
third content
</div>
</div>

Centering navigation bar

I am having trouble centering my navigation bar, I have tried display:inline-block and then align center like most posts suggest but it doesn't seem to be working.
HTML:
<!--Navigation-->
<div class="band navigation">
<nav class="container primary">
<div class="sixteen columns">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Projects</li>
<li>Contact Us</li>
</ul>
</div>
</nav>
</div>
CSS:
nav.primary{
display: table;
margin: 0 auto;
}
nav.primary ul, nav.primary ul li {
margin: 0px;
}
nav.primary select {
display: none;
width: 100%;
height: 28px;
margin: 21px 0;
}
nav.primary ul li {
display: inline;
float: left;
position: relative;
}
nav.primary ul li a {
display: inline-block;
line-height: 49px;
padding: 0 14px;
color: white;
text-transform: uppercase;
text-decoration: none;
font-weight: bold;
letter-spacing: 0.08em;
background: ##999999;
}
nav.primary ul li a:hover {
background: #2ecc71;
cursor: pointer;
}
Ok finally got it:
nav.primary ul li {
display: inline;
float: left; <---
position: relative;
Remove the float: left;
Since the navigation is the full width of the containing div, there is no need to mess with floats, the list items will line up with just display: inline;
I tried something else that works... It seems to work better than trying to build in something custom thus far in my experience with Skeleton... Although it produces a bit less pretty markup for the HTML, the rigidity of the final result works for me. Here is my code so that you can see what I did to achieve the desired effect:
<div class="row">
<div class="two columns offset-by-three">
Portfolio
</div>
<div class="two columns">
About
</div>
<div class="two columns">
Contact
</div>
</div>
What you can see here is that the skeleton framework allows for the columns to operate naturally and restack at lower resolutions without any extra code. The only tricky part really is setting up the offset on the left most item.
Have you tried nav.primary ul {text-align: center;}
As well as keeping the left/right margins to auto, this worked for me when I was using the skeleton framework.

Position: Sticky example in JS Fiddle

I am testing the new position:sticky feature but it does not appear to work.
CSS
.slide {
width:300px;
height:400px;
border:1px solid #888;
border-radius:8px;
position:relative;
overflow:auto;
}
.slide > ul {
padding:0;
margin:0;
position:relative;
}
.slide > ul > li {
min-height:20px;
display:block;
padding:10px;
background:#F8F8F8;
box-shadow:inset 0 0 3px #CCC;
list-style:none;
}
.slide > ul > li.title {
min-height:12px;
background:#888;
colour:#FFF;
font-weight:bold;
position:-webkit-sticky;
}
HTML
<div class="slide">
<ul>
<li class="title">Settings</li>
<li>General</li>
<li>Social</li>
<li>Search Engine</li>
</ul>
<ul>
<li class="title">Privacy</li>
<li>Personal</li>
<li>Business</li>
<li>Enigma</li>
</ul>
<ul>
<li class="title">Settings</li>
<li>General</li>
<li>Social</li>
<li>Search Engine</li>
</ul>
<ul>
<li class="title">Privacy</li>
<li>Personal</li>
<li>Business</li>
<li>Enigma</li>
</ul>
</div>
The Fiddle http://jsfiddle.net/78kxU/3/
position: sticky requires you to specify either a top or bottom CSS property in order to determine where/when the sticky element should begin sticking. You should also specify the un-vendor-prefixed value for forwards-compatibility (in this case, it seems to be required, at least on Chrome 30.0.1599.101).
So, in other words, add these two lines to your .slide > ul > li.title style rules:
position: sticky;
top: 0;
Here's the updated fiddle: http://jsfiddle.net/46gpu/