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;
}
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.
In this fiddle I create a simple breadcrumb. I like to change the dependencies of class "div.arrow-right". I like to control the arrow size by "#sequence". So that the size of the arrow belongs to the font-size. That means if I change the font-size the right-arrow should fit automatically the same high as the div which contains the writing.
#sequence {
font-size: 28px;
}
And I like to add a gap or lets say a white thin arrow between two breadcrumb elements, see the picture below.
An alternate using :before and :after pseudo elements. Fiddle
.breadcrumb {
list-style: none;
overflow: hidden;
font-size: 28px;
}
.breadcrumb li {
color: white;
text-decoration: none;
padding: 8px 0 8px 50px;
position: relative;
display: block;
float: left;
cursor: pointer;
}
.breadcrumb li:after {
content: "";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 30px solid #74c476;
position: absolute;
top: 50%;
margin-top: -50px;
left: 100%;
z-index: 2;
}
.breadcrumb li:before {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 30px solid white;
position: absolute;
top: 50%;
margin-top: -50px;
margin-left: 2px;
left: 100%;
z-index: 1;
}
li:nth-child(1) {
padding-left: 20px;
background-color: #74c476;
}
li:nth-child(2) {
background-color: #61a362;
}
li:nth-child(3) {
background-color: #518851;
}
li:nth-child(1):after {
border-left-color: #74c476;
}
li:nth-child(2):after {
border-left-color: #61a362;
}
li:nth-child(3):after {
border-left-color: #518851;
}
<ul class="breadcrumb">
<li>hello</li>
<li>operator</li>
<li>layout</li>
</ul>
I'm trying to design a vertical breadcrumb. I'm not sure how to do the small triangles on the bottom, I'm hoping that I can do this with css only and not use images. I'm looking at getting the following results:
They should be able to fill with white color just like the element on hover.
You can see my progress on fiddle: http://jsfiddle.net/5jJm3/2/
HTML:
<ul>
<li><div class="link"><p>Link1</p></div></li>
<li><div class="link"><p>Link2</p></div></li>
<li><div class="link"><p>Link3</p></div></li>
<li><div class="link"><p>Link4</p></div></li>
</ul>
CSS:
ul {
width: 100px;
height:500px;
border: 1px solid red;
margin: 0;
padding: 0;
text-align: center;
background: #1c818a;
}
ul li {
width: 100px;
height: 100px;
background: #64c7c7;
color: white;
list-style-type: none;
border-bottom: 3px solid white;
position: relative;
}
ul li:hover {
cursor: pointer;
background: white;
color: #64c7c7;
}
.link {
width:100px;
height:100px;
position:absolute;
left:50%;
top:50%;
margin:-25px 0 0 -50px;
}
Thanks!
DEMO: http://jsbin.com/zexoq/1
http://jsbin.com/zexoq/2/edit -- better
Multi-line: http://jsbin.com/qebek/2/edit
<ol class="breadcrumbs">
<li>title</li>
<li>title</li>
<li>title</li>
<li>title</li>
</ol>
CSS
.breadcrumbs,
.breadcrumbs * {
box-sizing: border-box;
list-style: none;
margin: 0;
}
.breadcrumbs li { width: 100px }
.breadcrumbs a {
text-decoration: none;
display: block;
height: 100px;
width: 100%;
background: aqua;
text-align: center;
line-height: 105px;
position: relative;
overflow: visible;
}
.breadcrumbs li a { border-bottom: 2px solid #fff }
.breadcrumbs li:last-child { border-bottom: 10px solid blue }
.breadcrumbs li:not(:last-child) a:after {
content: '';
width: 0;
height: 0;
position: absolute;
z-index: 2;
bottom: -10px;
left: 50%;
margin-left: -10px;
border-style: solid;
border-width: 10px 10px 0 10px;
border-color: aqua transparent transparent transparent;
}
.breadcrumbs li:not(:last-child) a:before {
content: '';
width: 0;
height: 0;
position: absolute;
z-index: 1;
bottom: -13px;
left: 50%;
margin-left: -12px;
border-style: solid;
border-width: 12px 12px 0 12px;
border-color: #fff transparent transparent transparent;
}
.breadcrumbs li:hover a {
background:#fff;
}
.breadcrumbs li:hover a:after {
border-top-color:#fff;
}
You can use :before and :after to create the triangle with borders.
Check my code:
ul{
text-align: center;
background: #1c818a;
width:200px;
padding:0;
margin:0;
height:900px;
}
li{
list-style-type: none; margin:0; margin-bottom:-2px;
}
p{margin-top:50px; color:white; font-size:20px;}
.arrow_box {
position: relative;
background: #66c7c5;
border: 2px solid #FFF;
border-left:0;
width:200px;
height:200px;
}
.arrow_box:hover {
background: #FFF;
}
.arrow_box:hover > p{
color: #66c7c5;
}
.normal_box {
position: relative;
background: #66c7c5;
border: 2px solid #FFF;
border-left:0;
width:200px;
height:200px;
}
.normal_box:hover {
background: #FFF;
}
.normal_box:hover > p{
color: #66c7c5;
}
.arrow_box:hover:after{
border-color: rgba(255, 255, 255, 0);
border-top-color: #FFF;
}
.arrow_box:after, .arrow_box:before {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
border-color: rgba(102, 199, 197, 0);
border-top-color: #66c7c5;
border-width: 30px;
margin-left: -30px;
}
.arrow_box:before {
border-color: rgba(255, 255, 255, 0);
border-top-color: #FFF;
border-width: 33px;
margin-left: -33px;
}
.arrow_box:nth-of-type(1):before,.arrow_box:nth-of-type(1):after{z-index:4;}
.arrow_box:nth-of-type(2):before,.arrow_box:nth-of-type(2):after{z-index:3;}
.arrow_box:nth-of-type(3):before,.arrow_box:nth-of-type(3):after{z-index:2;}
DEMO: http://jsfiddle.net/4n9hq/
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;
}