I have a menu that I have created with an unordered list. The menu cannot go over 900px wide, so I need my menu li text to sit on top of each other. Without shrinking the text size to 8px, is there a way to 'text-wrap' my menu item so it fits all nicely in the little box?
#font-face {
font-family: KBDunkTank;
src:url(KBDunkTank.ttf)
}
ul {
/* margin: 20px 60px;*/
}
ul li {
display: inline-block;
height: 70px;
line-height: 70px;
width: 130px;
margin: 5px 0px 0 0;
text-indent: 15px;
position: relative;
font-family: 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
font-size: 12px;
font-style: normal;
font-variant: normal;
font-weight: 500;
text-wrap: break-word;
text-shadow: 0 2px 2px black;
text-decoration:none;
}
ul li:before {
content: " ";
height: 0;
width: 0;
position: absolute;
left: -2px;
border-style: solid;
border-width: 35px 0 35px 40px;
border-color: transparent transparent transparent #fff;
z-index: 0;
text-decoration:none;
}
ul li:first-child:before {
border-color: transparent;
}
ul li a:after {
content: " ";
height: 0;
width: 0;
position: absolute;
right: -40px;
top: 0px;
border-style: solid;
border-width: 35px 0 35px 40px;
border-color: transparent transparent transparent #C34592;
z-index: 10;
text-decoration:none;
}
ul li.active a {
background: #FBE1EE;
z-index: 100;
text-decoration:none;
}
ul li.active a:after {
border-left-color: #FBE1EE;
}
ul li a {
display: block;
background: #C34592;
color: white;
text-decoration:none;
}
ul li a:hover {
background: #E899C9;
}
ul li a:hover:after {
border-color: transparent transparent transparent #E899C9;
}
#box{
width: 900px;
border-style: solid;
border-width: 5px;
}
<ul>
<li>Resume</li>
<li>Pick n Pack Game</li>
<li>Resume Rubric</li>
<li>Career Guru</li>
<li>Self Assessment</li>
<li>Submit</li>
</ul>
Image of what my menu looks like currently
Link to my menu on JSFiddle
Fixed it using 'word-wrap' and fiddled with the sizing of the borders and li for ages and finally got it...
ul.progressBar {
/* margin: 20px 60px;*/
}
ul.progressBar li {
display: inline-block;
height: 70px;
line-height: 30px;
width: 130px;
margin: 5px 5px 0 0;
/*text-indent: 20px;*/
position: relative;
font-family: 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
font-size: 16px;
font-style: normal;
font-variant: normal;
font-weight: 500;
word-wrap: break-word;
text-shadow: 0px 1px 1px black;
text-decoration:none;
text-align:center;
}
ul.progressBar li:before {
content: " ";
height: 0;
width: 0;
position: absolute;
left: -2px;
border-style: solid;
border-width: 30px 0 30px 40px;
border-color: transparent transparent transparent #fff;
z-index: 0;
text-decoration:none;
}
ul.progressBar li:first-child:before {
border-color: transparent;
}
ul.progressBar li a:after {
content: " ";
height: 0;
width: 0;
position: absolute;
right: -40px;
top: 0px;
border-style: solid;
border-width: 30px 0 30px 40px;
border-color: transparent transparent transparent #C34592; /*Pink: C34592*/
z-index: 10;
text-decoration:none;
}
ul.progressBar li.active a {
background: #FBE1EE;
z-index: 100;
text-decoration:none;
}
ul.progressBar li.active a:after {
border-left-color: #FBE1EE;
}
ul.progressBar li a {
display: block;
background: #C34592; /*Pink: C34592*/
color: black;
text-decoration:none;
padding-left: 30px;
}
ul.progressBar li a:hover {
background: #E899C9; /*Pink: E899C9*/
}
ul.progressBar li a:hover:after {
border-color: transparent transparent transparent #E899C9; /*Pink: E899C9*/
}
<ul class="progressBar">
<li>Resume<br><br></li>
<li>Pick n Pack Game</li>
<li>Resume<br>Rubric</li>
<li>Career<br>Guru</li>
<li>Self<br>Assessment</li>
<li>Submit<br><br></li>
</ul>
Related
I've borrowed and modified this code from jsfiddle to the code snippet below. I want to be able to wrap text in some arrows and not in others. As you can see, a single line of text doesn't render in the same place and two lines. I want the text centered in the <li>, How do I fix?
ul.money-class {
/*margin: 20px 60px;*/
margin-bottom: 0px
}
ul.money-class li {
display: inline-block;
height: 60px;
line-height: 60px;
width: 150px;
margin: 5px 1px 0 0;
text-indent: 35px;
position: relative;
}
ul.money-class li:before {
content: " ";
height: 0;
width: 0;
position: absolute;
left: 0px;
border-style: solid;
border-width: 30px 0 30px 30px;
border-color: transparent transparent transparent #fff;
z-index: 0;
}
ul.money-class li:first-child:before {
/*border-color: transparent;*/
}
ul.money-class li a:after {
content: " ";
height: 0;
width: 0;
position: absolute;
right: -30px;
top: 0px;
border-style: solid;
border-width: 30px 0 30px 30px;
border-color: transparent transparent transparent #ccc;
z-index: 10;
text-decoration: none;
}
ul.money-class li.active a {
background: orange;
z-index: 100;
}
ul.money-class li.active a:after {
border-left-color: orange;
}
ul.money-class li a {
display: block;
background: #ccc;
}
ul.money-class li a:hover {
background: pink;
}
ul.money-class li a:hover:after {
border-color: transparent transparent transparent pink;
}
span {display: block; line-height: 30px;}
<table class="table">
<tr>
<td>
<ul class="money-class">
<li class="active"><span>Round 1</span><span>£100</span></li>
<li><span>Round 2</span><span>£200</span></li>
<li><span>Round 3</span><span>£300</span></li>
<li><span>Round 4</span><span>£400</span></li>
<li><span>Round 5</span><span>£500</span></li>
<li>Prize Pot</li>
</ul>
</td>
</tr>
</table>
You can add some inline style only for that line as in my comment
<li style="vertical-align:top"><span style="line-height:60px; height:60px">Prize Pot</span></li>
or
it could work by adding some css exception to the last li and its descendants, but it won't work if the single line is in a random position in the list...
ul.money-class {
/*margin: 20px 60px;*/
margin-bottom: 0px
}
ul.money-class li {
display: inline-block;
height: 60px;
line-height: 60px;
width: 150px;
margin: 5px 1px 0 0;
text-indent: 35px;
position: relative;
}
ul.money-class li:before {
content: " ";
height: 0;
width: 0;
position: absolute;
left: 0px;
border-style: solid;
border-width: 30px 0 30px 30px;
border-color: transparent transparent transparent #fff;
z-index: 0;
}
ul.money-class li:first-child:before {
/*border-color: transparent;*/
}
ul.money-class li a:after {
content: " ";
height: 0;
width: 0;
position: absolute;
right: -30px;
top: 0px;
border-style: solid;
border-width: 30px 0 30px 30px;
border-color: transparent transparent transparent #ccc;
z-index: 10;
text-decoration: none;
}
ul.money-class li.active a {
background: orange;
z-index: 100;
}
ul.money-class li.active a:after {
border-left-color: orange;
}
ul.money-class li:last-child {vertical-align:top}
ul.money-class li:last-child a span {line-height:60px}
ul.money-class li a {
display: block;
background: #ccc;
}
ul.money-class li a:hover {
background: pink;
}
ul.money-class li a:hover:after {
border-color: transparent transparent transparent pink;
}
span {display: block; line-height: 30px;}
<table class="table">
<tr>
<td>
<ul class="money-class">
<li class="active"><span>Round 1</span><span>£100</span></li>
<li><span>Round 2</span><span>£200</span></li>
<li><span>Round 3</span><span>£300</span></li>
<li><span>Round 4</span><span>£400</span></li>
<li><span>Round 5</span><span>£500</span></li>
<li>Prize Pot</li>
</ul>
</td>
</tr>
</table>
#UncaughtTypeError provided the right solution
Declare vertical-align: top on ul.money-class li
I'm looking to achieve this with CSS:
and this is what I've got:
.breadcrumb {
list-style: none;
overflow: hidden;
font: 18px Helvetica, Arial, Sans-Serif;
margin: 0;
padding: 0;
}
.breadcrumb li {
float: left;
}
.breadcrumb li a {
border: 1px solid #c00;
color: black;
text-decoration: none;
padding: 10px 0 10px 55px;
background: #fff;
position: relative;
display: block;
float: left;
}
.breadcrumb li a:after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent;
/* Go big on the size, and let overflow hide */
border-bottom: 50px solid transparent;
border-left: 30px solid #fff;
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;
/* Go big on the size, and let overflow hide */
border-bottom: 50px solid transparent;
border-left: 30px solid red;
position: absolute;
top: 50%;
margin-top: -50px;
margin-left: 1px;
left: 100%;
z-index: 1;
}
.breadcrumb li:first-child a {
padding-left: 10px;
}
.breadcrumb li a:hover {
background: hsla(34, 85%, 25%, 1);
}
.breadcrumb li a:hover:after {
border-left-color: hsla(34, 85%, 25%, 1) !important;
}
.breadcrumb li:last-child a {
border-right: 1px solid red;
}
.breadcrumb li:last-child a:before {
border-left: 0 solid transparent;
}
<ul class="breadcrumb">
<li>Home</li>
<li>Vehicles</li>
</ul>
Issues:
Can't get the right side borders to show correctly
Can't get the right border of last element to be normal (not a chevron)
Can't get hover state right because of right side borders.
Here's is my working jsFiddle
.breadcrumb {
list-style: none;
overflow: hidden;
font: 18px Helvetica, Arial, Sans-Serif;
margin: 0;
padding: 0;
}
.breadcrumb li {
float: left;
position: relative;
background: #fff;
margin: 0 5px;
}
.breadcrumb li a {
border: 1px solid #0976a1;
color: #0976a1;
text-decoration: none;
padding: 10px 10px 10px 32px;
position: relative;
display: block;
z-index: 99;
font-weight: bold;
}
.breadcrumb li:first-child a {
padding-left: 10px;
border-right: none;
}
.breadcrumb li:last-child a {
border-left: none;
}
.breadcrumb li:before, .breadcrumb li:after{
content: " ";
display: block;
width: 33px;
height: 29px;
border-top: 5px solid transparent;
border-bottom: 1px solid #0976a1;
border-right: 1px solid #0976a1;
position: absolute;
top: 4px;
z-index: -1;
background: #fff;
transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
}
.breadcrumb li:before {
left: 87%;
}
.breadcrumb li:after {
left: 81%;
}
.breadcrumb li:first-child:before, .breadcrumb li:first-child:after{ z-index: 1; }
.breadcrumb li:first-child:after{ left: 73%; }
.breadcrumb li:last-child:before, .breadcrumb li:last-child:after{
display: none;
}
.breadcrumb li:first-child:hover:after, .breadcrumb li:hover{ background: #0976a1; }
.breadcrumb li:hover a{ border-color: transparent; }
.breadcrumb li:hover a{ color: #fff; }
<ul class="breadcrumb">
<li>Home</li>
<li>Vehicles</li>
</ul>
I hope this will help you :)
I think this code is helpful.
.breadcrumb {
list-style: none;
overflow: hidden;
font: 18px Helvetica, Arial, Sans-Serif;
margin: 0;
padding: 0;
}
.breadcrumb li {
float: left;
margin-right: 10px;
}
.breadcrumb li:first-child {
z-index: 9;
position:relative;
}
.breadcrumb li a {
border: 1px solid #006A9C;
color: black;
text-decoration: none;
padding: 10px 10px 10px 10px;
background: #fff;
position: relative;
display: block;
float: left;
}
.breadcrumb li:first-child a:after {
border-color:#fff;
border-style: solid;
border-width: 15px;
bottom: -30px;
box-shadow: 0 0 0 0 #c00, -1px 1px 0 1px #006A9C;
content: "";
height: 0;
position: absolute;
right: -29px;
transform: rotate(-135deg);
transform-origin: 0 0 0;
width: 0;
z-index: -1;
}
.breadcrumb li:first-child a {
border-right: 0;
}
.breadcrumb li:last-child a {
border-left: 0;
}
.breadcrumb li:last-child a:after{
display:none;
}
.breadcrumb li:last-child a:before{
border-color:#fff;
border-style: solid;
border-width: 15px;
bottom: -30px;
box-shadow: 0 0 0 0 #006A9C, -1px 1px 0 1px #006A9C;
content: "";
height: 0;
position: absolute;
left: -1px;
transform: rotate(-135deg);
transform-origin: 0 0 0;
width: 0;
}
.breadcrumb li:last-child a {
padding-left: 28px;
}
.breadcrumb li a:hover {
background: #006A9C;
color: #fff;
}
.breadcrumb li a:first-child:hover::after {
border-color:#006A9C;
}
<ul class="breadcrumb">
<li>Home</li>
<li>Vehicles</li>
</ul>
*{
margin: 0;
padding: 0;
}
.container{
margin: 20px;
display: flex;
flex-direction: row;
border: 1px solid skyblue;
width: 200px;
overflow: hidden;
}
.left,.right{
display: inline-block;
//border: 1px solid black;
line-height: 50px;
width: 100px;
height: 100%;
position: relative;
}
.right{
text-align: center;
}
p:hover{
background-color: skyblue;
color: white;
}
.left::after{
content:'';
position: absolute;
left: 70px;
top: 3px;
display: inline-block;
width: 45px;
height: 45px;
z-index: 2;
background:white;
transform:rotate(-45deg);
border-right: 1px solid skyblue;
border-bottom: 1px solid skyblue;
}
.left:hover::after{
background-color: skyblue;
}
<div class="container">
<p class="left">LEFT</p>
<p class="right">RIGHT</p>
</div>
It is doing my best.
I hope it will be useful for you.
So got a bit of a problem, and trying to figure out the best way.
So got some css code (heavily borrowed from coders better than me) that creates a pretty set of arrows in a menu, heavily using :after and :hover and all sorts. Had to write it in another application and now want to move it to the actual page.
Problem is, I need to set the class, and I am doing something really wrong. Basically, I decided to use the class "arrowrt" to set this to the top menu. But what is the easiest way to wrap it, or is it even easy to wrap it. Wanted to do something like .arrowrt { Loads of CSS settings }.
The code currently looks as follows
<style type="text/css" media="all">
a {
text-decoration:none;
}
ul {
margin: 20px 60px;
}
li {
margin-right: 5px;
}
ul li {
display: inline-block;
font-size: 12px;
height: 30px;
line-height: 30px;
width: 150px;
margin: 5px 8px 0 0;
text-align: center;
position: relative;
}
ul li:before {
content: " ";
height: 0;
width: 0;
position: absolute;
left: -2px;
border-style: solid;
border-width: 15px 0 15px 15px;
border-color: transparent transparent transparent #fff;
z-index: 0;
}
ul li:first-child:before , .dbfsrt {
border-color: transparent;
}
ul li a:after {
content: " ";
height: 0;
width: 0;
position: absolute;
right: -15px;
border-style: solid;
color: #000000;
border-width: 15px 0 15px 15px;
border-color: transparent transparent transparent #ccc;
z-index: 10;
}
ul li.arractive a {
background: orange;
z-index: 100;
}
ul li.active a:after {
border-left-color: orange;
}
ul li a {
display: block;
background: #ccc;
color: #000000;
}
ul li a:hover {
background: #000000;
color: #ececec;
}
ul li a:hover:after {
border-color: transparent transparent transparent #000000;
}
</style>
And the HTML section
<ul id="arrowrt">
<li class="arrowrt">Home</li>
<li class="arrowrt">Back Office</li>
<li class="arrowrt">Cash Management</li>
<li class="arrowrt arractive">Overdraft Management</li>
</ul>
You could (if using sass) do something like this:
.arrowrt li {
display: inline-block;
font-size: 12px;
height: 30px;
line-height: 30px;
width: 150px;
margin: 5px 8px 0 0;
text-align: center;
position: relative;
&:before {
content: " ";
height: 0;
width: 0;
position: absolute;
left: -2px;
border-style: solid;
border-width: 15px 0 15px 15px;
border-color: transparent transparent transparent #fff;
z-index: 0;
}
&:first-child:before {
border-color: transparent;
}
}
.dbfsrt {
border-color: transparent;
}
.arrowrt li {
a:after {
content: " ";
height: 0;
width: 0;
position: absolute;
right: -15px;
border-style: solid;
color: #000000;
border-width: 15px 0 15px 15px;
border-color: transparent transparent transparent #ccc;
z-index: 10;
}
&.arractive a {
background: orange;
z-index: 100;
}
&.active a:after {
border-left-color: orange;
}
a {
display: block;
background: #ccc;
color: #000000;
&:hover {
background: #000000;
color: #ececec;
&:after {
border-color: transparent transparent transparent #000000;
}
}
}
}
but you should have arrowrt as a class not id so that it can be reused.
The css equiv of this would be:
.arrowrt li {
display: inline-block;
font-size: 12px;
height: 30px;
line-height: 30px;
width: 150px;
margin: 5px 8px 0 0;
text-align: center;
position: relative;
}
.arrowrt li:before {
content: " ";
height: 0;
width: 0;
position: absolute;
left: -2px;
border-style: solid;
border-width: 15px 0 15px 15px;
border-color: transparent transparent transparent #fff;
z-index: 0;
}
.arrowrt li:first-child:before {
border-color: transparent;
}
.dbfsrt {
border-color: transparent;
}
.arrowrt li a:after {
content: " ";
height: 0;
width: 0;
position: absolute;
right: -15px;
border-style: solid;
color: #000000;
border-width: 15px 0 15px 15px;
border-color: transparent transparent transparent #ccc;
z-index: 10;
}
.arrowrt li.arractive a {
background: orange;
z-index: 100;
}
.arrowrt li.active a:after {
border-left-color: orange;
}
.arrowrt li a {
display: block;
background: #ccc;
color: #000000;
}
.arrowrt li a:hover {
background: #000000;
color: #ececec;
}
.arrowrt li a:hover:after {
border-color: transparent transparent transparent #000000;
}
I'd like to show a little triangle (similar as my tag box) below the selected menu item. I've tried various things without success, see http://jsfiddle.net/7zRVU/1/
How could I do that? Many thanks
nav {
float: right;
margin: 20px auto;
width: 100%;
}
nav ul {
margin-right: -4px;
margin-left: 5px;
text-align: right;
}
nav ul li {
display: inline-block;
margin-right: -4px;
margin-left: 5px;
vertical-align: top;
}
nav a {
padding: 4px 8px;
text-decoration: none;
color: rgba(255,255,255,1) !important ;
background: rgba(0,0,0,0.25);
font-weight: 300;
text-transform: uppercase;
letter-spacing: 1.5px;
font-size: 14px;
font-weight: 400;
}
nav a:hover {
background: rgba(0,0,0,0.35) !important ;
}
.activeNav {
background: rgba(0,0,0,0.35) !important ;
}
nav ul li ul {
position: absolute;
display: block;
margin-top: 5px;
background: none;
padding-top: 5px
}
nav ul li ul li {
display: block;
float: none;
margin: 0;
padding: 0
}
nav ul li ul li a {
display: block;
text-align: left;
color: rgba(255,255,255,0.9) !important ;
text-shadow: 0 1px rgba(0,0,0,0.33) !important ;
padding: 10px
}
nav ul li ul li a:hover {
background: rgba(20,150,220,0.5) !important ;
color: white;
text-shadow: 0 1px rgba(0,0,0,0.5)
}
.hover a {
display: block;
}
.hover span {
color: rgba(255,255,255,0.9);
background: rgba(20,150,220,0.5);
border-radius: 5px;
position: absolute;
display: block;
margin: 5px 0 0 -57px;
padding: 10px;
font-size: 13px;
font-weight: 300;
letter-spacing: 1.5px;
text-transform: uppercase;
text-align: center;
cursor: default;
}
li.selected a{
border-bottom: 1px solid rgba(16,65,145,0.9);
}
li.selected a:after {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-top-color: #3A7CDB;
border-width: 10px;
margin-left: -10px;
}
.tagbox {
top: -10px;
left: 60%;
position: absolute;
background-color: #3A7CDB;
background-image: linear-gradient(to bottom, #518CDE, #3A7CDB);
background-repeat: repeat-x;
padding: 10px 20px;
width: 250px;
margin-left: 0px;
text-align: center;
color: #fff;
margin-top:140px;
}
.tagbox:after {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-top-color: #3A7CDB;
border-width: 10px;
margin-left: -10px;
}
Here's an update to your fiddle - http://jsfiddle.net/7zRVU/4/1
You have actually done it, but you just need a "position:relative;" to your "selected" class, so the arrow to be absolutely positioned with it, and then, just change the position of the arrow to "top: height of the selected item"
.selected {
position: relative;
}
li.selected a:after {
top: 23px;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-top-color: #3A7CDB;
border-width: 10px;
margin-left: -10px;
}
i am not getting vertical scrollbar...
jsfiddle link -> http://jsfiddle.net/QNuzb/2/
css is
/* Navigation */
#nav-bar {position: fixed;top: 0;left: 0;z-index: 999;width: 100%;height: 45px;background: #F5F5F5;}
#nav {width: 800px;margin: 0 auto;height: 48px;text-align:center;}
#nav > li { display: inline-block;width: 15em;}
ul{list-style-type: none; display:inline-block;margin:0 auto; padding:0; position:relative;font-weight: bold; }
ul li{display:block;display:inline-block; position:relative;margin-right:5px;margin-left:5px}
ul li a{text-align: center;font-size: 18px;margin: 5px;padding: 8px;text-decoration: none; text-transform: capitalized;height: 35px; color:#222; font-size:18px; line-height:48px;}
ul li a:hover, ul li a.active{text-align:center;border-bottom:3px solid #800000; color:#800000}
/* Tabs */
.etabs { margin: 0; padding: 0; }
.tab { display: inline-block; zoom:1; *display:inline; background: #eee; border: solid 1px #999; border-bottom: none; -moz-border-radius: 4px 4px 0 0; -webkit-border-radius: 4px 4px 0 0; }
.tab a { font-size: 14px; line-height: 2em; display: block; padding: 0 10px; outline: none; }
.tab a:hover { text-decoration: underline; }
.tab.active { background: #fff; padding-top: 6px; position: relative; top: 1px; border-color: #666; }
.tab a.active { font-weight: bold; }
.tab-container .panel-container { background: #fff; border: solid #666 1px; padding: 10px; -moz-border-radius: 0 4px 4px 4px; -webkit-border-radius: 0 4px 4px 4px; }
It's because of the position: fixed; in your nav-bar class. remove it.
#nav-bar {
position: fixed; /* remove */
top: 0;
left: 0;
z-index: 999;
width: 100%;
height: 45px;
background: #F5F5F5;
}