Triangle inside div with text - css

I've got a side bar which contains a list, however I want a triangle located at the right side of the div. Now I know about the border trick, but then the text isn't located at the same location where it should be.
JSFiddle: http://jsfiddle.net/ppX53/44/
This is how my code looks like:
HTML:
<li id="activeMenuLi">
Admin Panel
</li>'
CSS:
.multilevelpushmenu_wrapper li #activeMenuLi{
width: 213px;
height: 45px;
border-top: 20px solid transparent;
border-right: 30px solid red;
border-bottom: 20px solid transparent;
}
How it looks like now:
The triangle is not complete, but it needs to be :).I think you know how I want it to look like.
I Use the following sidebar: link.
Note: I am not a complete rookie with CSS. I just hate building sidebars ^^. I'll try building a JSFiddle.
OfficialBAMM

Taking a look at your code, the problem is that you're attempting the "border-trick" on the li itself instead of a :before/:after pseudo-element. If you move the borders to a pseudo-element, it works. I've provided an example below.
body, html {
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif
}
h2 {
margin: 0 0 0.5em;
padding: 0.5em;
}
div {
background-color: #40516F;
color: #FFF;
width: 213px;
position: relative;
}
ul, li {
position: relative;
margin: 0;
padding: 0;
list-style: none;
}
ul { width: 213px; }
li > a {
color: #FFF;
border-top: 1px solid #445675;
padding: 0.6em;
display: block;
position: relative;
text-decoration: none;
}
li > a:hover {
background-color: #364155;
color: #FFE;
}
li.is-active > a:before {
position: absolute;
content: "";
top: 8px;
right: 0;
border-width: 10px;
border-style: solid;
border-color: transparent;
border-left: none;
border-right-color: orange;
}
<div>
<h2><i class="fa"></i>About</h2>
<ul>
<li class="is-active">Our Beliefs
</li>
<li>Our Doctrines
</li>
<li>Our Constitution
</li>
<li>Our Leaders
</li>
<li>Our History
</li>
<li>Church Links
</li>
</ul>
</div>

Related

css triangle in :before is off by 1px on safari (iPad)

I'm sorry if this should be more obvious, but I've spent a lot of time searching and can't seem to fix my problem.
I'm trying to get a specific arrow shape for a navigation list. It works perfectly on my PC on firefox and chrome, but when I take it to safari on my ipad, there's a 1px space between my :before pseudo element and the background for the link. Is there any way to fix this so that they're aligned correctly on both?
<ul id="listnav">
<li>link 1</li>
<li>link 2</li>
<li>link 3</li>
</ul>
css
#listnav {
list-style-type: none;
float: right;
padding: 0;
margin: 0;
}
#listnav a:link, a:visited {
display: block;
color: #ffffff;
background-color: #111111;
height: 20px;
width: 220px;
text-align: left;
padding: 3px;
margin:0 15px 5px 10px;
text-decoration: none;
position: relative;
border: none;
}
#listnav a:hover, a:active {
background-color: #462530;
color: #e2d276;
}
#listnav a:before {
content: "";
border-top: 13px solid transparent;
border-bottom: 13px solid transparent;
border-right: 8px solid #111111;
position: absolute; left: -8px; top: 0;
border-radius: 1px;
padding: 0;
}
#listnav a:hover:before {
border-right-color: #462530;
}
jsfiddle link
Thanks for your help!

Drop down menu borders

I'm attempting to create a simple drop down menu for. What I have currently looks like the following: http://jsfiddle.net/Wt9UC/
Now, what I'm aiming to achieve is something more in the lines of what Fiverr has, see for reference.
To clarify, I'm attempting to get borders (top, left, right) around the menu item hovered and around the entire box of sub-items which appears on-hover. If I'm being unclear in my wording the following image might help.
I tried playing around with layers (e.g. bringing the sub-items to the front in hopes of the border line being covered) but it didn't work out very well.
My HTML:
<ul id="menu">
<li>Test
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</li>
</ul>
My CSS:
#menu a {
color: black;
}
#menu {
padding: 0;
margin: 0;
list-style-type: none;
height: 30px;
}
#menu li {
float: left;
}
#menu li a {
padding: 9px 20px;
display: block;
text-decoration: none;
font-size: 12px;
}
#menu a:hover {
color: #c5cbc9;
border-radius: 3px;
border-left: 1px solid;
border-top: 1px solid;
border-right: 1px solid;
}
/* Submenu */
#menu ul {
border-radius: 3px;
border: 1px solid;
position: absolute;
left: -9999px;
top: -9999px;
list-style-type: none;
}
#menu li:hover { /*had bg*/
position: relative;
}
#menu li:hover ul { /*had bg*/
left: 0px;
top: 30px;
padding: 0px;
}
#menu li:hover ul li a {
padding: 5px;
display: block;
width: 168px;
text-indent: 15px; /*had bg*/
}
#menu li:hover ul li a:hover {
text-decoration: underline;
}
Thanks for your time!
Here is a Complete tutorial for building a Mega Menu. Hope this helps.
http://code.tutsplus.com/tutorials/how-to-build-a-kick-butt-css3-mega-drop-down-menu--net-15129
Demo Link : http://cdn.tutsplus.com/net/uploads/legacy/819_megamenu/demo/index.html
Hover on "4 column"/ Thats your exact requirment/
u need to do the following:
Add a "border-bottom: 1px solid #FFF" to your "#menu li a {}" and then move your dropdown 1px up.
link to fiddle http://jsfiddle.net/cL2x7/

Navigation not staying contained within parent div when browser window resized

I have an ul of navigation links nested in a div which is in turn nested into a 'header' div. My header div also contains a banner image, which should display in the top left corner of the website, and next to the banner I want my navigation links, which contain drop down menus when moused over.
Right now I am floating the banner to the left, and the nav links are automatically displaying next to the banner at my desktops resolution. The problem with this method is that once I resize the browser window the nav links begin to wrap around the banner and it looks terrible. Ideally I want the banner and the nav links to stay on the same line no matter the resolution of the device my site is viewed on.
Here is a jfiddle with an example of how my site displays. When I view the site at my default resolution of 1920x1080 it displays fine, but when I resize it does some funky stuff.
<!--- header div containing banner image and navigation bar --->
<div class="header">
<img id="banner" src="img/image.png" alt="Banner image displays here">
<div id="w">
<nav>
<ul id="ddmenu">
<li>About
<ul>
<li>Our Mission</li>
<li>The Staff</li>
<li>History</li>
</ul>
</li>
<li>Services
<ul>
<li>Donations</li>
<li>Volunteering</li>
<li>Housing</li>
</ul>
</li>
<li>Links
<ul>
<li>China</li>
<li>Japan</li>
<li>Canada</li>
<li>Australia</li>
<li>South America</li>
</ul>
</li>
<li>Contact Us</li>
</ul>
</nav>
</div>
</div>
/* relevent css for header, banner image, and navigation */
body {font-size: 100%; line-height: 1; max-width: 100%; font-family: 'Source Sans Pro', sans-serif; margin:0px; padding:0px;}
a:link, a:visited, a:active {color:#FFFFFF; text-decoration: none;}
a:hover {color: #C0C0C0; text-decoration: none;}
.header {width: 100%; margin:0; background-color: #FFFFFF; padding-bottom: 10px; margin-bottom: 10px;}
#banner { float: left; max-width:100%; margin: 0; padding: 0; border: none;}
#w { max-width:50%; background-color: #FFFFFF; margin: 0; padding: 0; border: none; }
#ddmenu {
max-width: 50%;
height: 68px;
margin: 0 auto;
padding-top: 2px;
padding-bottom: 2px;
background: #fff;
cursor: pointer;
outline: none;
font-weight: bold;
color: #8aa8bd;
}
#ddmenu li { display: inline-block; float: left; font-size: 1.00em;}
#ddmenu li a {
display: block;
float: left;
padding: 0 10px;
line-height: 4.9em;
font-weight: bold;
text-decoration: none;
color: #FF0000;
}
#ddmenu li:hover > a { color: #FFF; background-color: #FF0000;}
#ddmenu li:hover ul {display: block;}
/*Fills gap between top level li and nested ul so that the above mouse hover pseudoclass selecting ul works*/
#ddmenu > li:after {
content: " ";
position: absolute;
bottom: -12px;
left: 0;
width: 100%;
height: 12px;
background: transparent;
}
#ddmenu ul {
position: absolute;
top: 80px;
width: 120px;
background: #fff;
display: none;
margin: 0;
padding: 4px 4px;
list-style: none;
border-radius: 3px;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
/* tooltip arrow */
#ddmenu ul:after {
content: "";
width: 0;
height: 0;
position: absolute;
bottom: 100%;
left: 8px;
border-width: 0px 8px 8px 8px;
border-style: solid;
border-color: #fff transparent;
}
#ddmenu ul:before {
content: "";
width: 0;
height: 0;
position: absolute;
bottom: 100%;
left: 4px;
border-width: 0 10px 10px 10px;
border-style: solid;
border-color: rgba(0, 0, 0, 0.1) transparent;
}
#ddmenu ul li {
display: block;
width: 100%;
font-size: 0.9em;
}
#ddmenu ul li a {
display: block;
width: 100%;
padding: 6px 2px;
line-height: 1.4em;
}
I removed a lot of your styling because there is a lot of CSS to debug, but take a look at this Fiddle. I think it shows a simpler example of the effect you are going for and you may be able to work from the CSS.
Here's a breakdown of the most important parts of the CSS:
.header ul { list-style-type: none; }: don't show bullets
.header li { display: inline-block; }: make the list items sit next to each other horizontally instead of stacking in a column like normal
.header ul ul li { display: block; }: Not for submenus, though. Still want those in a stack.
.header ul ul { display: none; }: Don't show the nested lists...
.header li:hover ul { display: block; }: ...until we hover over the parent
.header li:hover ul { position: absolute; }: binds to nearest non-statically positioned ancestor
.header li { position: relative; top: 0; left: 0; }: which is its parent thanks to this trickery. Remember to specify top and left even if you're not moving anywhere or certain browsers will ignore you.
The rest is just fluff to make it look a little better. Since you're using inline-block to take care of most of the effect, you get resizing and wrapping for free.

Center a submenu with CSS and pointers

I have been reading and searching the whole day long. I even read this article and tried to work it out but with no success.
So, what I want to do is a CSS menu with sub menus and have the sub menus centered to the page. This is what I have done so far. What I want is that the submenus show up completely centered to the page. Is this possible?
Here's the HTML:
<div id="menu_panel">
<div id="menu_2border">
<div id="menu_section">
<div id='menu1'>
<ul>
<li class='first sub'><a href='#'><span>Hem</span></a>
<ul>
<li><a href='#'><span>Privat</span></a></li>
<li><a href='#'><span>Om Robust</span></a></li>
</ul>
</li>
<li class='sub'><a href='#'><span>Koncept</span></a>
<ul>
<li><a href='#'><span>Insikt</span></a></li>
<li><a href='#'><span>Koncept</span></a></li>
<li><a href='#'><span>Aktivering</span></a></li>
</ul>
</li>
<li class='sub'><a href='#'><span>Uppdrag</span></a>
<ul>
<li><a href='#'><span>Företag</span></a></li>
<li><a href='#'><span>Privat</span></a></li>
</ul>
</li>
<li class='sub'><a href='#'><span>Blogg</span></a>
<ul>
<li><a href='#'><span>Arkiv</span></a></li>
<li><a href='#'><span>Kategori</span></a></li>
</ul>
</li>
<li class='sub'><a href='#'><span>Om Robust</span></a>
<ul>
<li><a href='#'><span>Vad erbjuder vi?</span></a></li>
<li><a href='#'><span>Vilka är vi?</span></a></li>
</ul>
</li>
<li class='sub'><a href='#'><span>Kontakter</span></a>
</li>
</ul>
</div>
</div>
</div>
</div>
And the CSS:
#menu_panel {
width:100%;
height: 49px;
color:#4b4b4b;
display:block;
border-top:#efefef 1px solid;
}
#menu_2border {
width:100%;
border-top:#7a7a7a 1px solid;
}
#menu_section {
width: 960px;
height: 29px;
margin:auto;
padding: 0 0 0 30px;
color:#4b4b4b;
background-color:#fff;
}
#menu1 ul,
#menu1 li,
#menu1 span,
#menu1 a {
margin: auto;
padding: 0;
position: relative;
}
#menu1 {
height: 29px;
background: #fff;
margin:auto;
}
#menu1:after,
#menu1 ul:after {
content: '';
display: block;
clear: both;
}
#menu1 a {
background: #fff;
color: #4b4b4b;
display: inline-block;
font-size: 15px;
line-height: 29px;
padding: 0px 40px;
text-decoration: none;
}
#menu1 ul {
list-style: none;
/* float: left; */
}
#menu1 > ul > li {
float: left;
}
#menu1 li .mainmenu {
border-right:#d8d8d8 1px dotted;
}
#menu1 > ul > li:hover:after { /* faz as setas debaixo dos items do menu */
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 7px solid #fff;
margin-left: -10px;
}
#menu1 > ul > li.sub {
border-right:#d8d8d8 1px dotted;
}
#menu1 > ul > li.first {
border-left:#d8d8d8 1px dotted;
}
#menu1 > ul > li:hover > a {
background: #efefef;
}
#menu1 .sub {
z-index: 1;
}
#menu1 .sub:hover > ul {
display: block;
background-color:#
}
#menu1 .sub ul { /* faz o formato das caixas do sub-menu */
display: none;
position: absolute;
width: 803px;
height: 189px;
margin:auto;
border-bottom: #dddddd 1px solid;
border-left: #dddddd 1px solid;
border-right: #dddddd 1px solid;
background: #FFF;
}
#menu1 .sub ul li {
*margin-bottom: -1px;
}
#menu1 .sub ul li a {
background: #fff;
filter: none;
font-size: 13px;
display: block;
line-height: 120%;
padding: 10px 30px;
}
Notice that there are pointing arrows in each item of the menu, and they should stay where they are. What should be centered are the big submenu rectangles.
Many thanks in advance!
I dont explicitly understand your situation, do you need something like this? If so, i will make clear understanding on it.
#menu1 .sub ul { /* faz o formato das caixas do sub-menu */
display: none;
position: absolute;
width: 803px;
height: 189px;
margin-left: -401.5px; /* width divided by 2 */
left: 50%;
border-bottom: #dddddd 1px solid;
border-left: #dddddd 1px solid;
border-right: #dddddd 1px solid;
background: #FFF;
}
Example / Screen Result
You need to apply absolute positioning to your drop down menu, and have it relate to your top-level menu by applying relative positioning only to it. That direct relationship means you can set your drop-down menu to left: 0 and right: 0, sticking it to the left-most side and right-most side respectively of the top-level menu regardless of where it appears in your HTML (ie. it will match the width of your top-level ul).
Because you have set position:relative to a number of items, and some of your code might be dependant on that, I can't easily change your code to make it work. However, I put together this quick demonstration on jsfiddle to illustrate my explanation. I hope it helps.

Simple CSS tabs - need to break border on active tab

I want to create a very simple tab style that looks like this:
_____ _____ _____
_|_____|_| |_|_____|______________
So basically there is a horizontal border on the bounding box that breaks for the active tab. I'm using a basic list, with the following CSS, but the outer border always appears over the individual tabs. I've tried various positioning and z-index as well to no avail.
ul.tabHolder {
overflow: hidden;
clear: both;
margin: 1em 0;
padding: 0;
border-bottom: 1px solid #666;
}
ul.tabHolder li {
list-style: none;
float: left;
margin: 0 3px -1px; /* -1 margin to move tab down 1px */
padding: 3px 8px;
background-color: #444;
border: 1px solid #666;
font-size: 15px;
}
ul.tabHolder li.active {
background-color: #944;
border-bottom: 1px solid #944;
}
Try this solution by Eric Meyer.
Content below copied from the site to ensure the answer is still valid if the site closes, changes or breaks.
#navlist {
padding: 3px 0;
margin-left: 0;
border-bottom: 1px solid #778;
font: bold 12px Verdana, sans-serif;
}
#navlist li {
list-style: none;
margin: 0;
display: inline;
}
#navlist li a {
padding: 3px 0.5em;
margin-left: 3px;
border: 1px solid #778;
border-bottom: none;
background: #DDE;
text-decoration: none;
}
#navlist li a:link {
color: #448;
}
#navlist li a:visited {
color: #667;
}
#navlist li a:hover {
color: #000;
background: #AAE;
border-color: #227;
}
#navlist li a#current {
background: white;
border-bottom: 1px solid white;
}
<div id="navcontainer">
<ul id="navlist">
<li id="active">Item one</li>
<li>Item two</li>
<li>Item three</li>
<li>Item four</li>
<li>Item five</li>
</ul>
</div>
ABOUT THE CODE
Some lists within the Listamatic site had to be modified so that they could work on Listamatic's simple list model. When in doubt, use the external resource first, or at least compare both models to see which one suits your needs.
Changing your existing code as little as possible - try display: inline-block for the li tags, with the border on a .menu container div:
.menu {
border-bottom: 1px solid #666;
}
ul.tabHolder {
overflow: hidden;
margin: 1em 0 -2px;
padding: 0;
}
ul.tabHolder li {
list-style: none;
display: inline-block;
margin: 0 3px;
padding: 3px 8px 0;
background-color: #444;
border: 1px solid #666;
font-size: 15px;
}
ul.tabHolder li.active {
background-color: #944;
border-bottom-color: #944;
}
HTML used to illustrate (added div at bottom to show blending of active tab into div colour):
<div class="menu">
<ul class="tabHolder">
<li>Menu 1</li>
<li class="active">Menu 2</li>
<li>Menu 3</li>
</ul>
</div>
<div style="background-color: #944; height: 1em">
.tab {
display: inline-block;
background-color: #aaa;
padding: 4px;
border: 1px solid #888;
border-bottom: none;
position: relative;
bottom:-1px;
z-index: -1;
}
.tab-body {
position: relative;
height: 100px;
width: 200px;
padding: 4px;
background-color: #ccc;
border: 1px solid #888;
z-index: 1;
}
.tab.active {
background-color: #ccc;
z-index: 2;
}
<div class="tab tab1">Tab 1</div>
<div class="tab tab2 active">Tab 2</div>
<div class="tab tab3">Tab 3</div>
<div class="tab-body">Tab Body</div>

Resources