Dropdown menu show behind div - z-index, overflow, position not working - css

I need some help with a dropdown menu that's hiding behind a div. I tried setting the z-index to higher value, set the li to position:relative, checked for overflow in css (none). I see these as common causes for this issue, but nothing works for me.
Please note that z-index, positive and negative, were added whilst trying to find a solution. It makes no difference.
NOTE: dropdown is hiding behind "text-on-banner", yet showing in front of "main-banner".
Thanks for looking at this.
HTML:
<div class="wrapper">
<div class="header">
<ul class="PrimaryNav with-indicator">
<li class="Nav-item">
A
<li class="Nav-item">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">B</a>
<ul class="dropdown-menu">
<li class="Nav-subitem">B.1</li>
<li class="Nav-subitem">B.2</li>
<li class="Nav-subitem">B.3</li>
</ul>
<li class="Nav-item">
C
</ul>
</div>
</div>
<div class="section-wrapper">
<div class="main-banner">
<div class="text-on-banner">
<h2><strong>SOME TEXT HERE</strong></h2>
</div>
</div>
</div>
CSS:
.wrapper {
width: 100%;
}
.header {
width: 100%;
background: #26282c;
color: #f5f5f5;
text-align: center;
}
.PrimaryNav {
list-style: none;
margin: 7px auto;
max-width: 1220px;
padding: 0;
width: 100%;
font-family: 'Open Sans', sans-serif;
font-size: 130%;
font-weight: 600;
}
.with-indicator {
position: relative;
z-index: 0;
}
.Nav-item {
background: #26282c;
display: block;
float: left;
margin: 0;
padding: 0;
width: 14.28%;
text-align: center;
}
.Nav-item a {
color: #c2c5ca;
display: block;
padding-top: 20px;
padding-bottom: 20px;
text-decoration: none;
}
.Nav-subitem {
background: #26282c;
display: inline-block;
width: 100%;
text-align: center;
position: relative;
z-index: 999999;
}
.section-wrapper {
max-width: 1250px;
margin: auto;
padding: 20px 0 0 0;
}
.main-banner {
text-align: center;
font-weight: 700;
font-family: 'Titillium Web', sans-serif;
font-size: 36px;
line-height: 40px;
padding: 10px 2px 1px 2px;
color: #26282c;
box-shadow:
inset 0 0 0 1px rgba(232, 45, 0, 0.1),
inset 0 0 5px rgba(232, 45, 0, 0.2),
inset -285px 0 35px white;
border-radius: 10px;
background: #fff url(banner00.jpg) no-repeat center left;
z-index: -1;
}
.text-on-banner {
font-weight: 1000;
width: 95%;
max-width: 95%;
background-color:white;
opacity:0.6;
border-radius: 10px;
z-index: -1;
}
.text-highlight {
color: #e82d00;
font-weight: 800;
}

After spending 2-3 hours on this, I just realize that it was the .with-indicator ul which had to have z-index > 0. All working as expected now.
Hope this helps somebody else though. Thanks for looking.

Related

Same width as height on a flex child element

I'm working on a navbar where I will have a burger menu for toggling an extended menu.
I want to avoid to explicitly set a width to the burger menu element (.extendedMenu__toggle) and have it scale based on the font-size set on .header if possible.
The element gets it height from the parent as it's flex, but not sure how I can translate that into a proper width property so that I get a perfect square.
html {
font-size: 62.5%;
}
html, body {
font-family: helvetica;
line-height: 1.45;
}
.header {
left: 0;
position: fixed;
right: 0;
top: 0;
z-index: 1000;
font-size: 1.3rem;
font-weight: bold;
}
.nav {
display: flex;
justify-content: flex-start;
margin: 0;
position: relative;
z-index: 5;
margin: 1rem;
}
.extendedMenu__toggle {
/*width: 37px;
height: 37px;*/
background: red;
}
.navLink {
padding: 0.75rem 1.25rem;
text-decoration: none;
border: 2px solid;
border-radius: 30px;
margin-left: 0.75rem;
text-transform: uppercase;
}
.navLink:first-child {
margin-left: 0;
}
<header class="header" role="banner">
<nav class="nav">
<div class="extendedMenu__toggle">
<span></span>
<span></span>
<span></span>
</div>
<a class="navLink" href="#">Home</a>
<a class="navLink" href="#">About</a>
<a class="navLink" href="#">News</a>
</nav>
</header>
Option #1: Use Javascript. After the element renders you would check the height then set flex-basis to element height. I also set overflow: hidden since my content is "not square".
SO's code snippet seems not to like window.onload so here's a codepen example
html {
font-size: 62.5%;
}
html, body {
font-family: helvetica;
line-height: 1.45;
}
.header {
left: 0;
position: fixed;
right: 0;
top: 0;
z-index: 1000;
font-size: 4rem;
font-weight: bold;
}
.nav {
display: flex;
justify-content: flex-start;
margin: 0;
position: relative;
z-index: 5;
margin: 1rem;
}
.extendedMenu__toggle {
/*width: 37px;
height: 37px;*/
background: red;
overflow:hidden;
}
.navLink {
padding: 0.75rem 1.25rem;
text-decoration: none;
border: 2px solid;
border-radius: 30px;
margin-left: 0.75rem;
text-transform: uppercase;
}
.navLink:first-child {
margin-left: 0;
}
<header class="header" role="banner">
<nav class="nav">
<div id="box" class="extendedMenu__toggle">
menu
</div>
<a class="navLink" href="#">Home</a>
<a class="navLink" href="#">About</a>
<a class="navLink" href="#">News</a>
</nav>
</header>
Option #2: Use an image. This is kinda hacky but a square image will try to retain its proportions long as it's rendered in the HTML. Here are a few ways, available:
place an image of the hamburger menu with a transparent background in HTML. (go large so you're not scaling up, just down).
place a 10px x 10px transparent image in HTML and absolutely position other content on top of it.
create a pseudo class with content: url(image.jpg); in the CSS then layer content above it.
The first is the easiest to show so I'm doing that one. I would add a max-height to the image so it doesn't get out of control.
html {
font-size: 62.5%;
}
html, body {
font-family: helvetica;
line-height: 1.45;
}
.header {
left: 0;
position: fixed;
right: 0;
top: 0;
z-index: 1000;
font-size: 4rem;
font-weight: bold;
}
.nav {
display: flex;
justify-content: flex-start;
margin: 0;
position: relative;
z-index: 5;
margin: 1rem;
}
.extendedMenu__toggle {
/*width: 37px;
height: 37px;*/
background: red;
}
.extendedMenu__toggle img {
display:block;
max-height: 6rem;
}
.navLink {
padding: 0.75rem 1.25rem;
text-decoration: none;
border: 2px solid;
border-radius: 30px;
margin-left: 0.75rem;
text-transform: uppercase;
}
.navLink:first-child {
margin-left: 0;
}
<header class="header" role="banner">
<nav class="nav">
<div class="extendedMenu__toggle">
<img src="https://cdn1.imggmi.com/uploads/2018/10/15/e86f8a312edd60d643c8d80212b64dba-full.png" />
</div>
<a class="navLink" href="#">Home</a>
<a class="navLink" href="#">About</a>
<a class="navLink" href="#">News</a>
</nav>
</header>

Scrolling on overflow when making a list of N items

I have a prompt-box div that has a max-height of 80% of the screen.
Inside of it, I have a ul which holds a bunch of li elements depending on how many the user adds.
How do I configure this so that once that prompt-box hits a certain size, new items can be added to the list but the contents just scroll instead of overflowing like this?
Thanks!
Edit: Adding html & css
<div className='prompt-box'>
<p className='title'>What's in your future?</p>
<ul className='options-holder'>
{
this.state.items.map(item => (
<li key={item.id} className='option'>
<div className='circle' />
<p className='item-text'>{ item.text }</p>
</li>
))
}
<li key={0} className='option form'>
<div className='circle' />
<form className='new-item-form' onSubmit={this.handleSubmit}>
<input className='new-item-input' placeholder='Type something and press return...' onChange={this.handleChange} value={this.state.text} />
</form>
</li>
</ul>
<button className='confirm-button'>Continue</button>
</div>
.prompt-box {
#include absolute-center;
background: #1E1E1E;
width: 35%;
margin: 0 auto;
border-radius: 7px;
border: 1px solid rgba(255, 255, 255, 0.1);
color: #ccc;
font-family: 'Circular Book';
max-height: 80%;
overflow-y: auto;
}
.prompt-box .title {
text-align: center;
font-size: 30px;
margin-top: 30px;
margin-bottom: 25px;
}
.prompt-box .options-holder {
list-style: none;
border-radius: 3px; // not currently working
padding: 0;
width: 95%;
margin: 12px auto;
}
.prompt-box .option {
background: #303030;
padding: 18px;
border-bottom: 1px solid rgba(196, 196, 196, 0.1);
}
.prompt-box .option.form {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
.prompt-box .item-text {
color: white;
font-size: 24px;
margin: 0;
display: inline-block;
padding: 0 18px;
}
.prompt-box .new-item-form .new-item-input {
background: transparent;
border-style: none;
font-size: 24px;
padding-left: 18px;
color: white;
width: 80%;
&:focus { outline: none; }
}
.prompt-box .confirm-button {
width: 95%;
margin: 22px auto 18px auto;
}
You haven't shown us any HTML/CSS code for us to reproduce and test a fix for the issue, but adding something like this should work, to allow that container to scroll vertically when its height is exceeded:
.prompt-box {
overflow-y: auto;
}
Try a overflow: scroll; style rule on your div.prompt-box. (You're already giving it a max height, so the extra contents should have a vertical scroll bar).
I threw a max-height and an overflow-y: scroll on the ul and it did the trick.

Tooltip CSS is forcing my text to run vertically

Please read my profile before proceeding. Anyone who doesn't keep the critique to only the code itself will be disregarded. Okay? Okay.
I'm trying to do tooltips to my navigation header, using the code on this page. The bottom tooltip, specifically.
I've snagged out the relevant parts of code from my own CSS and webpage to tool around with in their Try It Editor to get it working, and I've been cussing at this since last week and this is the furthest I've gotten to making it work, and even that came with some sacrifices in design I'm not sure how to fix. I will admit that tooltips like this are a very new area for me, and I'm trying to learn a new thing, and it's making me give it a very salty side-eye. So pointers to where I'm going wrong and what I need to be doing to correct it are what I'm looking for. Links to any sites that explain this better would also be tremendously appreciated.
<!DOCTYPE html>
<html>
<style>
body {
margin: 0px;
padding: 0;
background-color: #000000;
background-image: url(http://www.metathriving.com/img/index2bg.png);
background-repeat: no-repeat;
background-attachment: fixed;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #72809F;
}
/* Header */
#header {
width: 960px;
height: 160px;
margin: 0px auto;
background-color:rgba(0,0,0,0.5);
}
/* Boy Without A Fairy */
#navi {
float: left;
width: 900px;
height: 55px;
}
#navi ul li {
margin: 0;
padding: 0px 0px 0px 0px;
list-style: none;
line-height: normal;
}
#navi a {
display: block;
float: left;
height: 45px;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #578fa8;
}
#navi a:hover {
color: #9dd0ed;
}
#navi a.active {
color: #FFFFFF;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #c0c0c0;
color: #000000;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent #ffffff transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style>
<body>
<div id="header">
<!-- Hey! Listen! -->
<div id="navi">
<ul>
<li><span style="color:#c0c0c0; font-weight: bold;">Just Another<br>Brick in<br>the Wall</span></li>
<li><div class="tooltip">Weary Eyes Still<br>Stray to the<br>Horizon <span class="tooltiptext">More About Me</span><div></li>
<li><span style="font-style: italic;">A Heavenly Ride<br>Through<br>Our Silence</span></li>
<li><span style="font-style: italic;">A Thousand<br>Miles of<br>Moonlight Later</span></li>
<li><span style="font-style: italic;">Trade Your Heroes<br>For Ghosts</span></li>
<li><span style="font-style: italic;">If You Can Hear<br>This Whispering<br>You Are Dying</span></li>
<li><span style="font-style: italic;">I'll See You On<br>the Dark Side<br>of the Moon</span></li>
<li><span style="font-style: italic;">Frontiers Shift<br>Like<br>Desert Sands</span></li>
<li><span style="font-style: italic;">You Are Only<br>Coming Through<br>In Waves</span></li>
</ul>
</div>
</body>
</html>
Here's a screencap of what that code renders in the w3schools.com Tryit Editor panel. (Ignore the font colors and the fact it's not easy to see in some spots because of text + background. the font will be tweaked when I have the layout done, I change up font colors as I work to make sure things are working and to single out stuff. And the full code does give a solid background under the text for better legibility.)
Screencap of what the code makes
As you can see, it line breaks. Where it does, the tool tip works. But it's not supposed to move the rest of it to a new line. At least, I don't want it to do that. I'm not sure where it's going off the rails here. Like I said, this is a new trick I'm trying to learn and I'm stumped, after a week of working, research, and several books studying. It's right in front of me, and it's gotta be bloody obvious, but what IS it?
Two issues:
There were a few tags in the tooltip incorrectly wrapped. Namely, <a></span></a></span>. I corrected this.
Then, the tooltip is causing the break you don't want. Add a float: left; to the .tooltip class.
body {
margin: 0px;
padding: 0;
background-color: #000000;
background-image: url(http://www.metathriving.com/img/index2bg.png);
background-repeat: no-repeat;
background-attachment: fixed;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #72809F;
}
/* Header */
#header {
width: 960px;
height: 160px;
margin: 0px auto;
background-color: rgba(0, 0, 0, 0.5);
}
/* Boy Without A Fairy */
#navi {
float: left;
width: 900px;
height: 55px;
}
#navi ul li {
margin: 0;
padding: 0px 0px 0px 0px;
list-style: none;
line-height: normal;
}
#navi a {
display: block;
float: left;
height: 45px;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #578fa8;
}
#navi a:hover {
color: #9dd0ed;
}
#navi a.active {
color: #FFFFFF;
}
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
float: left;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #c0c0c0;
color: #000000;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent #ffffff transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style> <body> <div id="header"> <!-- Hey! Listen! -->
<div id="navi">
<ul>
<li><span style="color:#c0c0c0; font-weight: bold;">Just Another<br>Brick in<br>the Wall</span>
</li>
<li>
<div class="tooltip"><a href="about.html">Weary Eyes Still<br>Stray to the<br>Horizon <span class="tooltiptext">More About Me
</span></a>
</div>
</li>
<li><span style="font-style: italic;">A Heavenly Ride<br>Through<br>Our Silence</span>
</li>
<li><span style="font-style: italic;">A Thousand<br>Miles of<br>Moonlight Later</span>
</li>
<li><span style="font-style: italic;">Trade Your Heroes<br>For Ghosts</span>
</li>
<li><span style="font-style: italic;">If You Can Hear<br>This Whispering<br>You Are Dying</span>
</li>
<li><span style="font-style: italic;">I'll See You On<br>the Dark Side<br>of the Moon</span>
</li>
<li><span style="font-style: italic;">Frontiers Shift<br>Like<br>Desert Sands</span>
</li>
<li><span style="font-style: italic;">You Are Only<br>Coming Through<br>In Waves</span>
</li>
</ul>
</div>

How to create a horizontal node branch using bootstrap?

How do I create something like this in bootstrap ?
I was thinking of making 4 columns each one of the nodes using the grid layout. But the center node is taking more space than it should take.
Here is the bootply http://www.bootply.com/5ni6EJeTWM
As of now it looks like this
Here is what I came up with. It is not perfect but it should help you get on the track.
UPDATED the code - FULLY RESPONSIVE NOW !!!
.node-list {
margin-bottom: 10px;
overflow: hidden;
width: 100%;
padding: 0px;
margin: 0px;
}
.node-list li {
list-style-type: none;
color: white;
text-transform: uppercase;
font-size: 14px;
width: 25%;
float: left;
position: relative;
text-align: center;
}
.node-list li p {
color: #000;
font-weight: bold;
}
.node-list li:after {
content: '';
width: 20px;
height: 20px;
line-height: 20px;
display: block;
font-size: 18px;
color: #000;
background: #fff;
border: 10px solid #000;
margin: 0 auto 5px auto;
}
.node-list li:before {
content: '';
width: 100%;
height: 6px;
background: #000;
position: absolute;
left: -50%;
bottom: 20px;
z-index: -1
}
.node-list li:first-child:before {
content: none;
}
<ul class="node-list">
<li class="active">
<p>ABC</p>
</li>
<li class="">
<p>ABC</p>
</li>
<li class="">
<p>ABC</p>
</li>
<li class="">
<p>ABC</p>
</li>
</ul>

CSS menu with fly outs

I'm trying to create a very basic page of weblinks, arranged into 7 columns. Some of the links have sub-links. What I want to happen is when the mouse is held over a link that has sub-links, the sub-links are to appear just below it and just to the right (as shown in menu 2.2)
I've cobbled the code together from various websites (I'm not a coder!), and I'm almost there I think, but if you take a look at the jsfiddle you will see there is a problem with the 3rd column (I've cut the menu down in the example).
HTML
<div id="container">
<ul id="menu">
<li><h3>Menu 1</h3></li>
<li>1.1</li>
<li>1.2</li>
</ul>
<ul id="menu">
<li><h3>Menu 2</h3></li>
<li>2.1</li>
<li>2.2
<ul id="sub1">
<li>2.2.1</li>
<li>2.2.2</li>
<li>2.2.3</li>
</ul>
</li>
</ul>
<ul id="menu">
<li><h3>Menu 3</h3></li>
<li>3.1
<ul id="sub2">
<li>3.1.1</li>
<li>3.1.2</li>
<li>3.1.3</li>
</ul>
</li>
<li>3.2</li>
<li>3.3</li>
</ul>
CSS
a {
font-family: arial, helvetica, sans-serif;
font-size: 12px;
font-weight: 700;
text-decoration:none;
color:black;
display:block;
padding-top: 17px;
padding-bottom: 17px;
outline: 0;
}
a:visited {
color:black;
background-color:#fff;
}
a:hover {
color:#fff;
background-color:#302403;
display:block;
}
ul {
padding: 10px 0px 0px 0px;
margin: 1px;
display: inline-block;
text-align: center;
position:relative;
list-style-type:none;
float: left;
width: 160px;
background-color: #fff;
height: 400px;
}
ul#sub1 {
position: relative;
left: 30px;
top: -15px;
visibility: hidden;
height: auto;
padding: 0;
}
ul#sub2 {
position: relative;
left: 30px;
top: -15px;
visibility: hidden;
height: auto;
padding: 0;
}
ul#menu li:hover #sub1 {
visibility: visible;
height: auto;
z-index: 1;
border: 2px solid;
padding: 0;
}
ul#menu li:hover #sub2 {
visibility: visible;
height: auto;
z-index: 1;
border: 2px solid;
padding: 0;
}
http://jsfiddle.net/87u27aw0/
I can get it to work if I give each sub-menu it's own absolute position, but I'm sure there is a better way than how I'm doing it - using relative maybe? Oh, and it has to work in IE8 onwards.
Thanks in advance.
Graybags

Categories

Resources