Related
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).
how to make a button with an obtuse angle?
I would like to happen like this
I got here so
My code - Fiddle
*{
box-sizing: border-box;
}
.btn{
display: inline-block;
padding: 16px 30px;
color: #fff;
border: 1px solid #4A803C;
position: relative;
border-radius: 3px;
background: rgb(74,168,28); /* Old browsers */
background: -moz-linear-gradient(top, rgba(74,168,28,1) 0%, rgba(63,155,19,1) 100%, rgba(56,146,12,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(74,168,28,1) 0%,rgba(63,155,19,1) 100%,rgba(56,146,12,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(74,168,28,1) 0%,rgba(63,155,19,1) 100%,rgba(56,146,12,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4aa81c', endColorstr='#38920c',GradientType=0 );
}
.btn > span{
position:relative;
z-index: 1;
}
.btn:after {
content: "";
width: 35px;
height: 35px;
display: block;
position: absolute;
top: 7px;
right: -18px;
border: 1px solid #4A803C;
border-left: none;
border-bottom: none;
border-radius: 3px;
-webkit-transform: rotate(47deg) skew(5deg);
transform: rotate(47deg) skew(5deg);
background-image: -moz-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -webkit-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -ms-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
}
.btn:hover{
background: rgb(56,146,12); /* Old browsers */
background: -moz-linear-gradient(top, rgba(56,146,12,1) 0%, rgba(63,155,19,1) 0%, rgba(74,168,28,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(56,146,12,1) 0%,rgba(63,155,19,1) 0%,rgba(74,168,28,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(56,146,12,1) 0%,rgba(63,155,19,1) 0%,rgba(74,168,28,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#38920c', endColorstr='#4aa81c',GradientType=0 );
}
.btn:hover:after{
background-image: -moz-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -webkit-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -ms-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
}
<a href="#" class="btn">
<span>Умножитель матрицы</span>
</a>
I would be glad of any help.
Thank you
A simple solution would be to add a rotateY(Xdeg) to the .btn:after element. This would make the element's Y-axis get rotated and thus would make it look narrower than it actually is.
Rotation angle can be modified as required. It can be any value below 90 degrees depending on how wide or narrow the arrow should be. Higher the value the narrower the arrow would be.
* {
box-sizing: border-box;
}
.btn {
display: inline-block;
padding: 16px 30px;
color: #fff;
border: 1px solid #4A803C;
position: relative;
border-radius: 3px;
background: rgb(74, 168, 28);
background: linear-gradient(to bottom, rgba(74, 168, 28, 1) 0%, rgba(63, 155, 19, 1) 100%, rgba(56, 146, 12, 1) 100%);
}
.btn > span {
position: relative;
z-index: 1;
}
.btn:after {
content: "";
width: 35px;
height: 35px;
display: block;
position: absolute;
top: 7px;
right: -18px;
border: 1px solid #4A803C;
border-left: none;
border-bottom: none;
border-radius: 3px;
transform: rotateY(45deg) rotate(47deg) skew(5deg);
background-image: linear-gradient(143deg, rgb(74, 168, 28) 0%, rgb(63, 155, 19) 100%);
}
.btn:hover {
background: rgb(56, 146, 12);
background: linear-gradient(to bottom, rgba(56, 146, 12, 1) 0%, rgba(63, 155, 19, 1) 0%, rgba(74, 168, 28, 1) 100%);
}
.btn:hover:after {
background-image: linear-gradient(-47deg, rgb(74, 168, 28) 0%, rgb(63, 155, 19) 100%);
}
<a href="#" class="btn">
<span>Умножитель матрицы</span>
</a>
I almost have a nice blue button but I want the background yellow and I want the text in center.
#post3 {
width: 450px;
background: -moz-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #6db3f2), color-stop(50%, #54a3ee), color-stop(51%, #3690f0), color-stop(100%, #1e69de)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* IE10+ */
background: linear-gradient(to bottom, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#6db3f2', endColorstr='#1e69de', GradientType=0); /* IE6-9 */
/*display: inline-block;*/
border: 1px solid rgb(0, 0, 0);
/*width: 290px;*/
height: 45px;/*
font-size: 150%;*/
text-decoration: none;
/*text-align: center;*/
color: rgb(255, 255, 255);
font-weight: bold;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
background-image: -webkit-linear-gradient(top, rgb(109, 179, 242) 0%, rgb(84, 163, 238) 50%, rgb(54, 144, 240) 51%, rgb(30, 105, 222) 100%);
background-position: initial initial;
background-repeat: initial initial;
}
<div id="post3"> Loren Ipsum</div>
Can you please help me? I don't know how to center the text and I don't know how to apply a text shadow.
Check this out:
Demo
background-image: -webkit-linear-gradient(top, rgb(242, 227, 109) 0%, rgb(219, 238, 84) 50%, rgb(240, 231, 54) 51%, rgb(222, 222, 30) 100%);
width:450px; /*It was width=450px; */
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style>
#post3 {
background: #ffcf32; /* Old browsers */
background: -moz-linear-gradient(top, #ffcf32 0%, #ffff30 50%, #f7df27 51%, #ffdf89 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffcf32), color-stop(50%,#ffff30), color-stop(51%,#f7df27), color-stop(100%,#ffdf89)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffcf32 0%,#ffff30 50%,#f7df27 51%,#ffdf89 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffcf32 0%,#ffff30 50%,#f7df27 51%,#ffdf89 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffcf32 0%,#ffff30 50%,#f7df27 51%,#ffdf89 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffcf32 0%,#ffff30 50%,#f7df27 51%,#ffdf89 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffcf32', endColorstr='#ffdf89',GradientType=0 ); /* IE6-9 */
/*display: inline-block;*/
border: 1px solid rgb(0, 0, 0);
/*width: 290px;*/
height: 45px;/*
font-size: 150%;*/
text-decoration: none;
/*text-align: center;*/
font-weight: bold;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
background-image: -webkit-linear-gradient(top, rgb(109, 179, 242) 0%, rgb(84, 163, 238) 50%, rgb(54, 144, 240) 51%, rgb(30, 105, 222) 100%);
background-position: initial initial;
background-repeat: initial initial;
width: 300px;
text-align: center;
}
span.center-content {
display: inline-block;
vertical-align: middle;
line-height:45px;
}
#post3 a {
color: #fff;
font-size: 24px;
letter-spacing: 2px;
text-decoration: none;
text-shadow: 2px 3px 7px #000000;
text-transform: uppercase;
}
</style>
</head>
<body>
<div id="post3"><span class="center-content">Loren Ipsum</span></div>
</body>
</html>
Just copy and paste the code above you should see the yellow colored button with gradient effect. Have a look at the URL http://www.colorzilla.com/gradient-editor/#ffcf32+0,ffff30+50,f7df27+51,ffdf89+100;Custom for creating the gradients on the fly.
This code coveres
Yellow gradient
Horizontally and vertically centered text
Shadow effect for the text on the button
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%
}
This question already has answers here:
How do I combine a background-image and CSS3 gradient on the same element?
(20 answers)
Closed 8 years ago.
I have a button, that has a gradient on it. I also needs an image arrow on it, but when I put it to background, and a button with two classes it seems not to work. Below is an example:
<button class="btn btn-wide">Load more</button>
.btn{
background: rgb(0,166,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(0,166,255,1) 0%, rgba(0,166,255,1) 50%, rgba(2,154,236,1) 53%, rgba(2,154,236,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,166,255,1)), color-stop(50%,rgba(0,166,255,1)), color-stop(53%,rgba(2,154,236,1)), color-stop(100%,rgba(2,154,236,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00a6ff', endColorstr='#029aec',GradientType=0 ); /* IE6-9 */
border:0px;
color:white;
font-family: HelveticaNarrow;
font-weight: bold;
font-size: 12pt;
text-transform: uppercase;
cursor: pointer;
}
.btn-wide{
width:728px;
height:45px;
background-image: url('images/white-arrow-down.png') no-repeat;
background-position: 50% 50%;
}
The background at the class .btn-wide is getting ignored because of the .btn class I guess.
What would be the best markup solution in this example? :)
Jsfiddle
The issue is that you are using the background shorthand property so trying to apply a second background image merely overwrites the previous statement (the gradient).
You can use comma separated background image statements like this.
CSS
.btn{
background-image: /* note bg image */
url(http://lorempixel.com/output/abstract-q-c-32-32-2.jpg),
linear-gradient(to bottom, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* W3C */
background-repeat:no-repeat;
border:0px;
color:white;
font-family: HelveticaNarrow;
font-weight: bold;
font-size: 12pt;
text-transform: uppercase;
cursor: pointer;
background-position:50% 50%;
}
.btn-wide{
width:728px;
height:45px;
}
JSFiddle Demo
Find the following link for updated fiddle.
FIDDLE
I updated the css.
.btn{
background: rgb(0,166,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(0,166,255,1) 0%, rgba(0,166,255,1) 50%, rgba(2,154,236,1) 53%, rgba(2,154,236,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,166,255,1)), color-stop(50%,rgba(0,166,255,1)), color-stop(53%,rgba(2,154,236,1)), color-stop(100%,rgba(2,154,236,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00a6ff', endColorstr='#029aec',GradientType=0 ); /* IE6-9 */
border:0px;
color:white;
font-family: HelveticaNarrow;
font-weight: bold;
font-size: 12pt;
text-transform: uppercase;
cursor: pointer;
position:relative;
width:728px;
height:45px;
}
.btn div{
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background-image: url('https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-ios7-arrow-right-128.png');
background-position: right;
background-repeat:no-repeat;
background-size:32px 32px;
}
Change the arrow image path according to your image.
The problem is with this rule
background-image: url('images/white-arrow-down.png') no-repeat;
you're specifying repeat in background-image.
You can rewrite it as
background-image: url('images/white-arrow-down.png');
background-repeat: no-repeat;
Update:
Fixing actual issue in your CSS doesn't provide you with your desired results because backgorund-image is going to overwrite the gradient. You can add position: relative .btn, remove background from .btn-wide, and use :before pseudo selector to add an element to your button. Following is the CSS
.btn{
background: rgb(0, 166, 255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0, 166, 255, 1)), color-stop(50%, rgba(0, 166, 255, 1)), color-stop(53%, rgba(2, 154, 236, 1)), color-stop(100%, rgba(2, 154, 236, 1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00a6ff', endColorstr='#029aec', GradientType=0); /* IE6-9 */
border: 0px;
color: white;
font-family: HelveticaNarrow;
font-weight: bold;
font-size: 12pt;
text-transform: uppercase;
cursor: pointer;
position: relative;;
}
.btn-wide{
width: 728px;
height: 45px;
}
.btn-wide:before{
content: ' ';
display: block;
height: 100%;
width: 100%;
position: absolute;
background: url('images/white-arrow-down.png') no-repeat 50% 50%;
top: 0;
left: 0;
}