I have a sidebar on the page that should look like this
but What I get is this
The submenu doesn't show as it should, my code look like this
.submenu{
position: absolute;
}
.submenu ul{
height: auto !important;
background-color: transparent !important;
}
.submenu ul li{
position: static !important;
}
When I assign right: value the behavior of the component is not usual. Here is a jsfiddle
Thank you!
Okay I got this to work but not in the fiddle you provided. When making a fiddle for a question on overflow try to isolate only the code that pertains to the question or problem. When you add everything in there it makes it a little hard to find the related material.
I made a fiddle for you to show how it works and if you like how it is then feel free to just use that. This is a css dropdown and doesn't require any scripting. What you need to do is nestle a ul inside of the main ul's li tag. You then have to hide the nested ul to later be revealed on a hover action.
The triangle I made does not have to be a CSS3 triangle, you can use an image.
HTML
<div class="sideBar">
<ul>
<li>¿Porqué Nosotros?</li>
<li><span class="tri"></span>Pregrado
<ul>
<li>Diseño & Comunicación Visual</li>
<li>Comunicació y Relaciones Públicas</li>
</ul>
</li>
<li>Posgrado</li>
<li>Maestría</li>
<li>Calendario</li>
</ul>
CSS
.sideBar {
position: absolute;
top: 0;
left: 0;
background: black;
color: #fff;
width: 200px;
}
.sideBar ul {
list-style-type: none;
padding: 0;
margin: 0;
}
.sideBar ul li {
height: 20%;
width: 180px;
padding: 10px 0 10px 20px;
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
}
.tri {
content: "";
border-top: 19px solid transparent;
border-bottom: 19px solid transparent;
border-left: 10px solid red;
position: absolute;
width: 0;
height: 0;
padding: 0;
margin: 0;
left: 100%;
top: 20%;
display: none;
z-index: 1000;
}
.tri:after {
height: 38px;
left: 100%;
top: 0;
content: "";
position: absolute;
width: 10px;
display: block;
}
.sideBar ul li:hover .tri {
display: block;
}
.sideBar ul li:hover {
background: red;
}
.sideBar ul li ul {
display: none;
position: absolute;
top: 30%;
left: 100%;
}
.sideBar ul li ul li {
background: #7b7b7b;
border: none;
padding-left: 20px;
width: 260px;
}
.sideBar ul li ul li:hover {
background: black;
}
.sideBar ul li:hover ul {
display: block;
}
Here is a fiddle you can use for a visual reference.
jsfiddle
If you need more help then let me know.
Related
I'm using a trick to add a border between navigation items
li {
&:not(.active) {
&::before {
border-bottom: grey;
bottom: 0;
content: '';
height: 1px;
left: 20px;
position: absolute;
width: 220px;
:host-context(.minified) {
display: none;
}
}
It works fine. You can see the yellow marked line.
If navigation is active i do not add this border.
If the navigation link is active, i would like to remove the border from previous sibling. You can see the red arrow.
Anybody ideas how can i do that?
You can define the divider at the top of the li and remove the first divider with li:first-child:after
Now, when hovering you can access the next li with + and set the background to be transparent.
Here's an example:
html, body{
padding: 0px;
margin: 0px;
}
ul {
border-right: 2px solid #e5e5e5;
width: 180px;
box-shadow: 5px 2px 10px #e5e5e5;
margin: 0px;
padding: 0px;
}
li {
list-style-type: none;
height: 40px;
display: flex;
align-items: center;
margin: 0px;
padding-left: 15px;
position: relative;
}
li:after{
position: absolute;
background-color: #e5e5e5;
top: 1px;
height: 1px;
width: 130px;
left: 20px;
z-index: 1;
content: "";
}
li:first-child:after{
height: 0px;
}
li:hover {
color: #13A83E;
background-color: #e5e5e5;
}
li:hover + li:after {
background-color: transparent;
}
<ul>
<li>Dashboard</li>
<li>Assets</li>
<li>Devices</li>
<li>More</li>
<li>Options</li>
</ul>
I am facing an issue on IE11 on a fixed element. That's a context menu that needs to grow horizontally depending on the text inside. This works perfectly on Firefox, Chrome and Safari, but not on IE.
The problem is that on IE11 the right arrow goes down to the next line, instead of growing the line to allow all text be shown.
The following is my code:
* {
box-sizing: border-box;
}
#context-menu {
display: none;
text-align: left;
position: fixed;
z-index: 1000000000;
}
#context-menu ul {
background-color: white;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 1px 1px 3px #444;
text-align: left;
min-width: 150px;
width: auto;
}
#context-menu ul,
#context-menu ul li {
padding: 0;
margin: 0;
position: relative;
display: block;
width: auto;
color: black;
text-align: left;
background-color: #fff;
}
#context-menu ul li {
padding: 5px 10px;
cursor: pointer;
}
#context-menu ul li:hover ul {
z-index: 1;
}
#context-menu ul li:first-child {
border-radius: 3px 3px 0 0;
}
#context-menu ul li:last-child {
border-radius: 0 0 3px 3px;
}
#context-menu ul li .fa {
margin-right: 10px;
width: 15px;
vertical-align: middle;
}
#context-menu ul li.group {
cursor: default;
background-color: #dfdfdf;
font-weight: bold;
}
#context-menu ul > li:not(.group):hover {
background-color: hsla(208, 56%, 53%, 1);
color: black;
}
#context-menu ul > li.submenu::after {
font-family: FontAwesome;
content: "\f105";
margin-left: 15px;
float: right;
}
#context-menu ul> li > ul{
display: none;
}
#context-menu ul > li:hover > ul {
display: block;
position: absolute;
left: 100%;
top: 0;
}
<link href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" rel="stylesheet"/>
<div id="context-menu" style="display: block;">
<ul>
<li><span class="optionText">Long text to show the problem here on the right arrow</span></li>
<li class="submenu"><span class="optionText">Another text</span></li>
<li class="submenu"><span class="optionText">Long text to show the problem here on the right arrow</span>
<ul class="dropdownright">
<li><span class="optionText">Other</span></li>
</ul>
</li>
</ul>
</div>
If you see, if the text is longer than the min-width, it grows on all browsers except IE11, where the arrow goes down to the next line.
How can I make it grow the width automatically ?
Thank you.
Removing the "float: right" in the rule "#context-menu ul > li.submenu::after" seems to be working for me in Internet explorer 11.
I have a navigation dropdown element that I would like to make selectable - currently the link only works when the text is hovered and not the box surrounding it. Is there a way in which I can do this in CSS.
My CSS code:
.main-menu {
position: absolute;
top:90px;
right:0px;
text-align: right;
z-index: 2000;
}
.main-menu ul {
width: 50%;
background-color: #333;
display: inline;
margin: 0;
padding: 20px 5px;
list-style: none;
color: #fff;
}
.main-menu ul li {
display: inline-block;
margin-right: -10px;
position: relative;
padding: 17px 15px;
cursor: pointer;
color: #fff;
font-size: 14px;
font-weight: 700;
}
.main-menu ul li a {
color: #fff;
border: none;
}
.main-menu ul li a:hover {
color: #f1c40f;
}
/* sub menu */
.main-menu ul li ul {
position: absolute;
top: 25px;
left: 0;
min-width: 150px;
opacity: 0;
margin: 10px 0px;
padding: 17px 5px 0px 5px;
visibility: hidden;
text-align: left;
}
.main-menu ul li ul li {
display: block;
color: #fff;
margin: 0px -5px;
}
.main-menu ul li ul li:hover {
background: #666;
color: #f1c40f;
}
.main-menu ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
Jsfiddle is: http://jsfiddle.net/9BdTK/
Method 1
You can simply move the <a></a> outside of <li>.
E.G:
<li>Home</li>
DEMO HERE
Note: I have only done this for the first two links.
Method 2
A better way to do this is the following:
HTML:
<div id="con">
<ul>
<li>Test</li>
<li>Test</li>
<li>Test</li>
</ul>
</div>
CSS:
#con {
width: 100%;
background: #eee;
text-align: center;
}
ul {
list-style: none;
}
li {
display: inline-block;
width: 80px;
height: 50px;
outline: 1px solid #000;
}
a {
display: block;
height: 100%;
width: 100%;
}
Keep <a> inside and set it to display: block;, then set the width and height to 100% and this will take up the whole div creating a div link.
Demo of div link - DEMO HERE
Demo with hover - DEMO HERE
Hope this helps.
I have this on my site, but I also managed to do so from this site.
have a look :
Don't put padding in the 'li' item. Instead set the anchor tag to
display:inline-block; and apply padding to it.By Stussa
As said on : Make whole area clickable
Goodluck
I'm designing a Homepage like this: https://dl.dropboxusercontent.com/u/178536659/new/Document.htm and I'm currently working on the dropdown menu. My problem is that my dropdown menu is not fully displayed. I tried so many ways such as using "float: left" (what what I'm using now) or using "dislay:inline" for the ul li, it still doesn't work.
try this
in this class #nav li ul z-index give then menu show properly,
#nav li ul {
background-color: black;
display: none;
left: -60px;
margin: 0;
padding: 0;
position: absolute;
width: 257px;
z-index: 1;
}
#nav ul li ul li {
border-bottom: 2px solid #2185C5;
padding: 14px;
width: 89%;
}
Add the following to remove the extra blue border:
#nav ul li ul li {
padding: 14px 25px 14px 14px;
border-bottom: 2px solid #2185C5;
width: 100%;
margin-left: -40px;
}
#aftercolor {
position: absolute;
top: 99px;
height: 8px;
width: 960px;
background-color: #2185C5;
}
also add margin:0 to your body to make your site good looking.
body{
margin: 0;
}
I've created a custom breadcrumb in jsfiddle http://jsfiddle.net/jimbodeni/Ata9k/ . When you shrink the width of the page the text is on 2 lines on the last 2 breadcrumbs but is only on one line on the first breadcrumb. This causes the grey background to be out of line on the first breadcrumb with the other 2.
How can I get this to always be the max height of the largest breadcrumb so they're all uniform height no matter if one has got one line of text and another 2 lines of text?
<div id="breadcrumb-container">
<ul class="breadcrumb">
<li>Surgery Started</li>
<li class="current">Surgery Started</li>
<li>Surgery Compl'd</li>
</ul>
</div>
div#breadcrumb-container {
width:100%;
}
div#breadcrumb-container li {
width: 33%;
}
div#breadcrumb-container li:last-child {
width: 34%;
}
.breadcrumb {
list-style: none;
overflow: hidden;
font: 13px Helvetica, Arial, Sans-Serif;
}
.breadcrumb li {
float: left;
background: #C7C7C7;
}
.breadcrumb li a {
color: white;
text-decoration: none;
padding: 5px 5px 5px 45px;
position: relative;
display: block;
}
.breadcrumb li a:after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 30px solid #C7C7C7;
position: absolute;
top: 50%;
margin-top: -50px;
left: 100%;
z-index: 2;
}
.breadcrumb li a:before {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 30px solid #001940;
position: absolute;
top: 50%;
margin-top: -50px;
margin-left: 3px;
left: 100%;
}
.breadcrumb li:first-child a {
padding-left: 12px;
border:none;
}
.breadcrumb li:last-child a:after {
border:none;
}
.breadcrumb .current {
background:#007ACC; color:#fff;
pointer-events: none;
cursor: default;
}
.breadcrumb .current a:after {
border-left-color:#007ACC;
pointer-events: none;
cursor: default;
}
.breadcrumb li a:hover { background: #007ACC; }
.breadcrumb li a:hover:after { border-left-color: #007ACC !important; }
Also, how do I get all 3 breadcrumbs to be exactly the same size? At the minute the first one is bigger than the other 2.
Thanks in advance to anyone who can help!