Gradient CSS arrow [duplicate] - html

This question already has answers here:
Make CSS3 triangle with linear gradient
(5 answers)
Closed 8 years ago.
How is it possible to make a CSS arrow as a gradient instead os a solid colour?
Here is my CSS"
.breadcrumbDivider .arrow-right {
width: 0;
height: 0;
border-top: 25px solid transparent;
border-bottom: 25px solid transparent;
border-left: 25px solid gold;
position: relative;
margin-left: 360px;
}
I tried using the CSS gradient background image gradient but it takes the border parameter but unsure how to overcome this?
Here is the gradient I am trying to use...
background-color: #c9bc9e;
background-image: -webkit-gradient(linear, left top, left bottom, from(#c9bc9e), to(#a89464));
background-image: -webkit-linear-gradient(top, #c9bc9e, #a89464);
background-image: -moz-linear-gradient(top, #c9bc9e, #a89464);
background-image: -ms-linear-gradient(top, #c9bc9e, #a89464);
background-image: -o-linear-gradient(top, #c9bc9e, #a89464);
background-image: linear-gradient(top, #c9bc9e,#a89464);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#c9bc9e', endColorStr='#a89464');

I've made this by 'cutting out' the arrow from a square div, instead of 'generating' an arrow. It even has a hover effect:
.arrow {
height: 200px;
width: 300px;
background: rgb(169, 3, 41);
background: -moz-linear-gradient(top, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(169, 3, 41, 1)), color-stop(44%, rgba(143, 2, 34, 1)), color-stop(100%, rgba(109, 0, 25, 1)));
background: -webkit-linear-gradient(top, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
background: -o-linear-gradient(top, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
background: -ms-linear-gradient(top, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
background: linear-gradient(to bottom, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#a90329', endColorstr='#6d0019', GradientType=0);
position: relative;
overflow: hidden;
transition: all 0.8s;
}
.arrow:before {
content: "";
position: absolute;
top: 0;
width: 70%;
height: calc(100% - 80px);
border-top: 40px solid white;
border-bottom: 40px solid white;
z-index: 10;
}
.arrow:after {
content: "";
position: absolute;
right: 0;
border-top: 100px solid white;
border-bottom: 100px solid white;
border-left: 100px solid transparent;
z-index: 10;
}
.perc {
position: absolute;
top: 0;
width: 0%;
height: 100%;
background: rgb(30, 87, 153);
background: -moz-linear-gradient(top, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 50%, rgba(32, 124, 202, 1) 51%, rgba(125, 185, 232, 1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(30, 87, 153, 1)), color-stop(50%, rgba(41, 137, 216, 1)), color-stop(51%, rgba(32, 124, 202, 1)), color-stop(100%, rgba(125, 185, 232, 1)));
background: -webkit-linear-gradient(top, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 50%, rgba(32, 124, 202, 1) 51%, rgba(125, 185, 232, 1) 100%);
background: -o-linear-gradient(top, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 50%, rgba(32, 124, 202, 1) 51%, rgba(125, 185, 232, 1) 100%);
background: -ms-linear-gradient(top, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 50%, rgba(32, 124, 202, 1) 51%, rgba(125, 185, 232, 1) 100%);
background: linear-gradient(to bottom, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 50%, rgba(32, 124, 202, 1) 51%, rgba(125, 185, 232, 1) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1e5799', endColorstr='#7db9e8', GradientType=0);
z-index: 5;
transition: all 0.8s;
}
.arrow:hover .perc {
width: 100%;
}
<div class="arrow">
<div class="perc"></div>
</div>
Note
Originally designed for a progress bar, but hover effect can be removed if necessary.
Is suitable for a block coloured background only
So, if I cut the 'fancy stuff' and show you how it works:
Hover the one below to see the magic:
.arrow {
height: 200px;
width: 300px;
background: rgb(169, 3, 41);
background: -moz-linear-gradient(top, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(169, 3, 41, 1)), color-stop(44%, rgba(143, 2, 34, 1)), color-stop(100%, rgba(109, 0, 25, 1)));
background: -webkit-linear-gradient(top, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
background: -o-linear-gradient(top, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
background: -ms-linear-gradient(top, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
background: linear-gradient(to bottom, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#a90329', endColorstr='#6d0019', GradientType=0);
position: relative;
overflow: hidden;
transition: all 0.8s;
}
.arrow:before {
content: "";
position: absolute;
top: 0;
width: 100%;
height: calc(100% - 80px);
border-top: 40px solid white;
border-bottom: 40px solid white;
z-index: 10;
}
.arrow:after {
content: "";
position: absolute;
right: 0px;
border-top: 100px solid white;
border-bottom: 100px solid white;
border-left: 100px solid transparent;
z-index: 10;
}
.arrow:hover:before {
border-top: 40px solid tomato;
border-bottom: 40px solid tomato;
}
.arrow:hover:after {
border-top: 100px solid yellow;
border-bottom: 100px solid blue;
}
<div class="arrow"></div>

Related

I want to change the colour of my Progress tag

I have tried my best to change the color of the value of the <progress> tag.
Instead of using traditional CSS. I am using SCSS.
progress {
border: none;
width: 400px;
height: 60px;
background: crimson;
}
progress {
color: lightblue;
}
progress::-moz-progress-bar {
background: lightcolor;
}
progress::-webkit-progress-value {
background: rgb(2,0,36);
background: -moz-linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(223,168,231,1) 0%, rgba(18,189,223,1) 100%);
background: -webkit-linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(223,168,231,1) 0%, rgba(18,189,223,1) 100%);
background: linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(223,168,231,1) 0%, rgba(18,189,223,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#020024",endColorstr="#12bddf",GradientType=1);
}
progress::-webkit-progress-bar {
background: blue;
}
<progress min = "0" max = "100" value = "80">80%</progress>
Any ideas about what is happening wrong with my code.
/Instead of rgb(2, 0, 36) and rgba(18, 189, 223, 1) you can apply the color of your choice when you want to use a gradient/
/**If you don't want to use a gradient simply replace the content of progress::-webkit-progress-value by background: yourcolor;
progress {
border: none;
width: 400px;
height: 60px;
background: crimson;
}
progress::-webkit-progress-value {
background: linear-gradient(rgb(2, 0, 36) 0%, rgba(18, 189, 223, 1) 100%);
background: -moz-linear-gradient(90deg, rgba(2, 0, 36, 1) 0%, rgba(18, 189, 223, 1) 100%);
background: -webkit-linear-gradient(90deg, rgba(2, 0, 36, 1) 0%, rgba(18, 189, 223, 1) 100%);
background: linear-gradient(90deg, rgba(2, 0, 36, 1) 0%, rgba(18, 189, 223, 1) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr="#020024", endColorstr="#12bddf", GradientType=1);
}
<progress min="0" max="100" value="80">80%</progress>

How to create this button with CSS?

How would one create the following button using CSS?
The fact that it is skewed is not the issue. The part I'm not sure about is the diagonal split in color that's positioned from corner to corner. Im not sure how to define a gradient in such a way that it would work for all button dimensions responsively.
I have the following so far, for a skewed button without the diagonal difference in color.
button.btn {
color: white;
background-color: red;
padding: 10px 20px;
line-height: 1;
border: none;
transform: skewX(-25deg);
cursor: pointer;
}
button.btn span {
display: block;
transform: skewX(25deg);
}
<button class="btn" ><span>View Demo</span></button>
But I'm sure a lot of that will all have to change.
Here is a gradient solution that will work with any size:
button.btn {
color: white;
background:linear-gradient(to bottom right, #e80027 49%,#d20024 50%);
padding: 10px 20px;
line-height: 1;
border: none;
transform: skewX(-25deg);
cursor: pointer;
}
button.btn span {
display: block;
transform: skewX(25deg);
}
<button class="btn" ><span>View Demo</span></button>
<button class="btn" ><span>View Demo Demoooo</span></button>
<button class="btn" ><span>View </span></button>
Use Gradient CSS generator to get any sort of gradient backgrounds..
button.btn {
color: white;
background: rgba(248, 80, 50, 1);
background: -moz-linear-gradient(-45deg, rgba(248, 80, 50, 1) 0%, rgba(241, 111, 92, 1) 50%, rgba(246, 41, 12, 1) 51%, rgba(240, 47, 23, 1) 71%, rgba(231, 56, 39, 1) 100%);
background: -webkit-gradient(left top, right bottom, color-stop(0%, rgba(248, 80, 50, 1)), color-stop(50%, rgba(241, 111, 92, 1)), color-stop(51%, rgba(246, 41, 12, 1)), color-stop(71%, rgba(240, 47, 23, 1)), color-stop(100%, rgba(231, 56, 39, 1)));
background: -webkit-linear-gradient(-45deg, rgba(248, 80, 50, 1) 0%, rgba(241, 111, 92, 1) 50%, rgba(246, 41, 12, 1) 51%, rgba(240, 47, 23, 1) 71%, rgba(231, 56, 39, 1) 100%);
background: -o-linear-gradient(-45deg, rgba(248, 80, 50, 1) 0%, rgba(241, 111, 92, 1) 50%, rgba(246, 41, 12, 1) 51%, rgba(240, 47, 23, 1) 71%, rgba(231, 56, 39, 1) 100%);
background: -ms-linear-gradient(-45deg, rgba(248, 80, 50, 1) 0%, rgba(241, 111, 92, 1) 50%, rgba(246, 41, 12, 1) 51%, rgba(240, 47, 23, 1) 71%, rgba(231, 56, 39, 1) 100%);
background: linear-gradient(135deg, rgba(248, 80, 50, 1) 0%, rgba(241, 111, 92, 1) 50%, rgba(246, 41, 12, 1) 51%, rgba(240, 47, 23, 1) 71%, rgba(231, 56, 39, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f85032', endColorstr='#e73827', GradientType=1);
padding: 10px 20px;
line-height: 1;
border: none;
transform: skewX(-25deg);
cursor: pointer;
}
button.btn span {
display: block;
transform: skewX(25deg);
}
<button class="btn"><span>View Demo</span></button>
Try this:
.btn{
background-color: #34ADFF;
background-image: -webkit-linear-gradient(-68deg, #e80027 50%, #d20024 50%);
border:0px;
padding:20px 25px;
font-size:17px;
-webkit-transform:skew(-30deg);
-moz-transform:skew(-30deg);
-o-transform:skew(-30deg);
transform:skew(-30deg);
color:#fff;
margin-left:20px;
}
<button class="btn" ><span>View Demo</span></button>
button.btn {
color: white;
background-color: red;
padding: 10px 20px;
line-height: 1;
border: none;
transform: skewX(-25deg);
cursor: pointer;
background: linear-gradient(165deg, rgba(245, 80, 50, 1) 0%, rgba(245, 111, 92, 1) 50%, rgba(230, 41, 12, 1) 51%, rgba(230, 47, 23, 1) 71%, rgba(230, 56, 39, 1) 100%);
}
button.btn span {
display: block;
transform: skewX(25deg);
}
<button class="btn" ><span>View Demo</span></button>

Convert list in chart vertically using css

Hi i am working on an org chart where in i was successfully able to generate the whole tree. Now my concern is how can i convert a group of list elements to display vertically instead of horizontal display.
My code for the org chart is as follows:
* {
margin: 0;
padding: 0;
}
.tree ul {
padding-top: 50px;
position: relative;
transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
}
.tree li {
float: left;
text-align: center;
list-style-type: none;
position: relative;
padding: 40px 5px 0 5px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
}
/*We will use ::before and ::after to draw the connectors*/
.tree li::before,
.tree li::after {
content: '';
position: absolute;
top: 0;
right: 50%;
border-top: 2px solid #3f3974;
width: 50%;
height: 40px;
}
.tree li::after {
right: auto;
left: 50%;
border-left: 2px solid #3f3974;
}
/*We need to remove left-right connectors from elements without
any siblings*/
.tree li:only-child::after,
.tree li:only-child::before {
display: none;
}
/*Remove space from the top of single children*/
.tree li:only-child {
padding-top: 0;
}
/*Remove left connector from first child and
right connector from last child*/
.tree li:first-child::before,
.tree li:last-child::after {
border: 0 none;
}
/*Adding back the vertical connector to the last nodes*/
.tree li:last-child::before {
border-right: 2px solid #3f3974;
border-radius: 0 5px 0 0;
-webkit-border-radius: 0 5px 0 0;
-moz-border-radius: 0 5px 0 0;
}
.tree li:first-child::after {
border-radius: 5px 0 0 0;
-webkit-border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
}
/*Time to add downward connectors from parents*/
.tree ul ul::before {
content: '';
position: absolute;
top: 0;
left: 50%;
border-left: 2px solid #3f3974;
width: 0;
height: 50px;
}
.tree li a {
border: 1px solid #ccc;
padding: 5px 10px;
text-decoration: none;
color: #666;
font-family: arial, verdana, tahoma;
font-size: medium;
font-weight: bolder;
display: inline-block;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
width: 10em;
word-break: break-word;
white-space: pre-wrap;
}
.tree li a~.tree li a {
/* Undo last assignment */
word-spacing: unset;
display: table-caption;
}
/*Time for some hover effects*/
/*We will apply the hover effect the the lineage of the element also*/
.tree li a:hover,
.tree li a:hover+ul li a {
/* background: #c8e4f8; */
color: #000;
border: 1px solid #94a0b4;
}
/*Connector styles on hover*/
.tree li a:hover+ul li::after,
.tree li a:hover+ul li::before,
.tree li a:hover+ul::before,
.tree li a:hover+ul ul::before {
border-color: #94a0b4;
}
.tree ul.sections {
margin-top: -20px;
}
.tree ul.sections li.section {
padding-left: 25px;
border-bottom: 2px solid orange;
height: 80px;
}
.tree ul.sections li.section a {
background: #92D4A8;
top: 38px;
position: absolute;
z-index: 1;
width: 95%;
height: auto;
vertical-align: middle;
right: 0px;
line-height: 14px;
}
a[class^='level1_'] {
background: rgb(248, 80, 50);
/* Old browsers */
background: -moz-linear-gradient(45deg, rgba(248, 80, 50, 1) 0%, rgba(246, 41, 12, 1) 18%, rgba(246, 41, 12, 1) 18%, rgba(246, 41, 12, 1) 21%, rgba(246, 41, 12, 1) 25%, rgba(240, 47, 23, 1) 43%, rgba(241, 111, 92, 1) 61%, rgba(231, 56, 39, 1) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(45deg, rgba(248, 80, 50, 1) 0%, rgba(246, 41, 12, 1) 18%, rgba(246, 41, 12, 1) 18%, rgba(246, 41, 12, 1) 21%, rgba(246, 41, 12, 1) 25%, rgba(240, 47, 23, 1) 43%, rgba(241, 111, 92, 1) 61%, rgba(231, 56, 39, 1) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(45deg, rgba(248, 80, 50, 1) 0%, rgba(246, 41, 12, 1) 18%, rgba(246, 41, 12, 1) 18%, rgba(246, 41, 12, 1) 21%, rgba(246, 41, 12, 1) 25%, rgba(240, 47, 23, 1) 43%, rgba(241, 111, 92, 1) 61%, rgba(231, 56, 39, 1) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#f85032', endColorstr='#e73827', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
color: #f2f2f2 !important;
}
a[class^='level2_'] {
background: rgb(181, 189, 200);
/* Old browsers */
background: -moz-linear-gradient(45deg, rgba(181, 189, 200, 1) 22%, rgba(130, 140, 149, 1) 33%, rgba(40, 52, 59, 1) 59%, rgba(130, 140, 149, 1) 62%, rgba(40, 52, 59, 1) 73%);
/* FF3.6-15 */
background: -webkit-linear-gradient(45deg, rgba(181, 189, 200, 1) 22%, rgba(130, 140, 149, 1) 33%, rgba(40, 52, 59, 1) 59%, rgba(130, 140, 149, 1) 62%, rgba(40, 52, 59, 1) 73%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(45deg, rgba(181, 189, 200, 1) 22%, rgba(130, 140, 149, 1) 33%, rgba(40, 52, 59, 1) 59%, rgba(130, 140, 149, 1) 62%, rgba(40, 52, 59, 1) 73%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#b5bdc8', endColorstr='#28343b', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
color: #f2f2f2 !important;
}
a[class^='level3_'] {
background: rgb(157, 213, 58);
/* Old browsers */
background: -moz-linear-gradient(45deg, rgba(157, 213, 58, 1) 29%, rgba(161, 213, 79, 1) 38%, rgba(128, 194, 23, 1) 47%, rgba(157, 213, 58, 1) 63%, rgba(124, 188, 10, 1) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(45deg, rgba(157, 213, 58, 1) 29%, rgba(161, 213, 79, 1) 38%, rgba(128, 194, 23, 1) 47%, rgba(157, 213, 58, 1) 63%, rgba(124, 188, 10, 1) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(45deg, rgba(157, 213, 58, 1) 29%, rgba(161, 213, 79, 1) 38%, rgba(128, 194, 23, 1) 47%, rgba(157, 213, 58, 1) 63%, rgba(124, 188, 10, 1) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#9dd53a', endColorstr='#7cbc0a', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
color: #000 !important;
}
a[class^='level4_'] {
background: -moz-linear-gradient(45deg, rgba(30, 87, 153, 0) 0%, rgba(30, 87, 153, 1) 19%, rgba(30, 87, 153, 0.95) 20%, rgba(31, 92, 159, 0.8) 23%, rgba(41, 137, 216, 0.8) 50%, rgba(30, 87, 153, 0.8) 80%, rgba(30, 87, 153, 0.8) 81%, rgba(30, 87, 153, 0) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(45deg, rgba(30, 87, 153, 0) 0%, rgba(30, 87, 153, 1) 19%, rgba(30, 87, 153, 0.95) 20%, rgba(31, 92, 159, 0.8) 23%, rgba(41, 137, 216, 0.8) 50%, rgba(30, 87, 153, 0.8) 80%, rgba(30, 87, 153, 0.8) 81%, rgba(30, 87, 153, 0) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(45deg, rgba(30, 87, 153, 0) 0%, rgba(30, 87, 153, 1) 19%, rgba(30, 87, 153, 0.95) 20%, rgba(31, 92, 159, 0.8) 23%, rgba(41, 137, 216, 0.8) 50%, rgba(30, 87, 153, 0.8) 80%, rgba(30, 87, 153, 0.8) 81%, rgba(30, 87, 153, 0) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#001e5799', endColorstr='#001e5799', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
color: #fff !important;
}
a[class^='level5_'] {
background: #6db3f2;
/* Old browsers */
background: -moz-linear-gradient(45deg, #6db3f2 39%, #6db3f2 39%, #54a3ee 40%, #3690f0 45%, #1e69de 69%);
/* FF3.6-15 */
background: -webkit-linear-gradient(45deg, #6db3f2 39%, #6db3f2 39%, #54a3ee 40%, #3690f0 45%, #1e69de 69%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(45deg, #6db3f2 39%, #6db3f2 39%, #54a3ee 40%, #3690f0 45%, #1e69de 69%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#6db3f2', endColorstr='#1e69de', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
color: #fff !important;
width: 7em !important;
}
/*Thats all. I hope you enjoyed it.
Thanks :)*/
<section class="uRegion clearfix" id="newtree" style="overflow-x: scroll;">
<div class="uRegionContent clearfix" style="width: 4275px;">
<div class="tree">
<ul class="leve1">
<li class="level1">President
<ul class="level2">
<li class="level21">Direc1
<ul class="level3">
<li class="level3_3">CSD
<ul class="level4">
<li class="level4_8">MR Sec.</li>
<li class="level4_9">Insts Section
<ul class="level5 sections">
<li class="level5_2 section">Ip Unit</li>
<li class="level5_3 section">Sp Unit</li>
<li class="level5_4 section">QTS Unit</li>
</ul>
</li>
<li class="level4_10">Acc Section
<ul class="level5 sections">
<li class="level5_5 section">Acc Unit</li>
<li class="level5_6 section">Cust Bill Unit</li>
</ul>
</li>
<li class="level4_11">BC Sec.</li>
<li class="level4_12">Mtr Section
<ul class="level5 sections">
<li class="level5_7 section">Tech Supp AMI Unit</li>
<li class="level5_8 section">Mtr Inst Unit</li>
</ul>
</li>
<li class="level4_13">CC & CC Sec
<ul class="level5 sections">
<li class="level5_9 section">CC Unit</li>
<li class="level5_10 section">BOff Unit</li>
<li class="level5_11 section">Q & A Unit</li>
<li class="level5_12 section">CC Rep. Unit</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</section>
In the chart under sections i have some list elements aligned horizontally. Now i want to display align the li elements vertically as shown in the figure i.e.
I tried tweaking with the code by adding a new class other than the one already available but it didn't work out.
To list list's items vertically you don't have to do anything.
Lists are automatically vertical.
If you want to display them horizontally, you have to use property float: left;
.horizontal li {
float: left;
padding: 20px;
list-style-type: none;
}
<ul class="horizontal">
<li> one </li>
<li> two </li>
<li> three </li>
</ul>
As I can see in your code, you have float: left property added to each .tree li element. Just remove it from those elements that you don't want to be floated (and should be vertical), and add it only to those which have to be flated (and should be horizontal).

Increase menu width to page size

I'm trying to create a menu which stretches across the page. However, it's not stretching across the screen, even when I make the width 100%.
Here's my code:
select {
display: none;
}
nav {
margin: 0 auto;
text-align: center;
background: #fff;
height: 70px;
width: 100%;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: inline-block;
vertical-align: top;
background: rgba(148, 148, 149, 1);
background: -moz-linear-gradient(top, rgba(148, 148, 149, 1) 0%, rgba(192, 192, 192, 1) 36%, rgba(192, 192, 192, 1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(148, 148, 149, 1)), color-stop(36%, rgba(192, 192, 192, 1)), color-stop(100%, rgba(192, 192, 192, 1)));
background: -webkit-linear-gradient(top, rgba(148, 148, 149, 1) 0%, rgba(192, 192, 192, 1) 36%, rgba(192, 192, 192, 1) 100%);
background: -o-linear-gradient(top, rgba(148, 148, 149, 1) 0%, rgba(192, 192, 192, 1) 36%, rgba(192, 192, 192, 1) 100%);
background: -ms-linear-gradient(top, rgba(148, 148, 149, 1) 0%, rgba(192, 192, 192, 1) 36%, rgba(192, 192, 192, 1) 100%);
background: linear-gradient(to bottom, rgba(148, 148, 149, 1) 0%, rgba(192, 192, 192, 1) 36%, rgba(192, 192, 192, 1) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#949495', endColorstr='#c0c0c0', GradientType=0);
}
nav ul li {
float: left;
margin: 0;
padding: 0;
}
nav ul li a {
display: block;
padding: 10px 7px;
color: #000;
text-decoration: none;
}
nav ul li~li {
border-left: 1px solid #857D7A;
}
nav .active a {
background: rgba(180, 85, 12, 1);
background: -moz-linear-gradient(top, rgba(180, 85, 12, 1) 0%, rgba(234, 110, 16, 1) 36%, rgba(234, 110, 16, 1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(180, 85, 12, 1)), color-stop(36%, rgba(234, 110, 16, 1)), color-stop(100%, rgba(234, 110, 16, 1)));
background: -webkit-linear-gradient(top, rgba(180, 85, 12, 1) 0%, rgba(234, 110, 16, 1) 36%, rgba(234, 110, 16, 1) 100%);
background: -o-linear-gradient(top, rgba(180, 85, 12, 1) 0%, rgba(234, 110, 16, 1) 36%, rgba(234, 110, 16, 1) 100%);
background: -ms-linear-gradient(top, rgba(180, 85, 12, 1) 0%, rgba(234, 110, 16, 1) 36%, rgba(234, 110, 16, 1) 100%);
background: linear-gradient(to bottom, rgba(180, 85, 12, 1) 0%, rgba(234, 110, 16, 1) 36%, rgba(234, 110, 16, 1) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#b4550c', endColorstr='#ea6e10', GradientType=0);
color: #fff;
}
#media (max-width: 480px) {
select {
display: block;
width: 200px;
margin: 0 auto;
}
nav {
display: none;
}
}
<nav>
<ul>
<li class="active">Item 1
</li>
<li>Item 2
</li>
<li>Item 3
</li>
<li>Item 4
</li>
<li>Item 5
</li>
</ul>
</nav>
<select>
<option value="#">Item 1</option>
<option value="#">Item 2</option>
<option value="#">Item 3</option>
<option value="#">Item 4</option>
<option value="#">Item 5</option>
</select>
You just need to add width: 100%; to your nav ul like this:
nav ul {
width: 100%;
list-style: none;
margin: 0;
padding: 0;
display: inline-block;
vertical-align: top;
background: rgba(148,148,149,1);
background: -moz-linear-gradient(top, rgba(148,148,149,1) 0%, rgba(192,192,192,1) 36%, rgba(192,192,192,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(148,148,149,1)), color-stop(36%, rgba(192,192,192,1)), color-stop(100%, rgba(192,192,192,1)));
background: -webkit-linear-gradient(top, rgba(148,148,149,1) 0%, rgba(192,192,192,1) 36%, rgba(192,192,192,1) 100%);
background: -o-linear-gradient(top, rgba(148,148,149,1) 0%, rgba(192,192,192,1) 36%, rgba(192,192,192,1) 100%);
background: -ms-linear-gradient(top, rgba(148,148,149,1) 0%, rgba(192,192,192,1) 36%, rgba(192,192,192,1) 100%);
background: linear-gradient(to bottom, rgba(148,148,149,1) 0%, rgba(192,192,192,1) 36%, rgba(192,192,192,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#949495', endColorstr='#c0c0c0', GradientType=0 );
}
If you want the buttons to expand, you need to use display: table; on the nav ul followed by display: table-cell; on the nav ul li
Here is a fiddle for you showing it working - http://jsfiddle.net/andyjh07/Ldu3o1jm/
Check this Codepan. You need to change this.
nav ul
{
width:100%
}

CSS: How to style table background including the <caption> element

Stylesheets for tables elements exclude the table caption (a <caption> tag inside the <table> tag).
Is there a way for a table to have a gradiented background that includes the caption ?
Adding display:block; should solve it
<style>
table{
background-image: -moz-linear-gradient(bottom, rgb(156,155,250) 43%, rgb(255,255,255) 88%);
display:block;
}
<table>
<caption>Test</caption>
<tr>
<td>Col1</td>
<td>Col2</td>
</tr>
</table>
Yes, there is: http://jsfiddle.net/Pe5Lt/2/
Position the caption absolutely, relatively to the table, then give the table some padding-top and center the caption with margin: Xpx auto;:
HTML
<table>
<caption>I'm a CAPTION</caption>
<thead>
<tr>
<th>I'm a TH</th>
</tr>
</thead>
<tbody>
<tr>
<td>I'm a TD</td>
</tr>
</tbody>
</table>
CSS
table {
position: relative;
padding-top: 30px;
width: 200px;
border: 1px solid red;
background: rgb(30, 87, 153);
/* Old browsers */
background: -moz-linear-gradient(top, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 66%, rgba(32, 124, 202, 1) 100%, rgba(125, 185, 232, 1) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(30, 87, 153, 1)), color-stop(66%, rgba(41, 137, 216, 1)), color-stop(100%, rgba(32, 124, 202, 1)), color-stop(100%, rgba(125, 185, 232, 1)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 66%, rgba(32, 124, 202, 1) 100%, rgba(125, 185, 232, 1) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 66%, rgba(32, 124, 202, 1) 100%, rgba(125, 185, 232, 1) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 66%, rgba(32, 124, 202, 1) 100%, rgba(125, 185, 232, 1) 100%);
/* IE10+ */
background: linear-gradient(to bottom, rgba(30, 87, 153, 1) 0%, rgba(41, 137, 216, 1) 66%, rgba(32, 124, 202, 1) 100%, rgba(125, 185, 232, 1) 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e5799', endColorstr='#7db9e8', GradientType=0);
/* IE6-9 */
}
table caption {
color: red;
position: absolute;
top: 0;
width: 100%;
margin: 10px auto;
}
CSS Gradient background generated with http://www.colorzilla.com/gradient-editor/