I'm trying to build a generic hover class that uses box-shadow amd that will work with multiple colors of buttons. For this reason, I want the "shadow" to be different for every color of button. I'm trying to figure out if there is a way to use or set only the color attribute of a shadow element?
Here is what I mean:
/*Notice that .button shadows does not have a color value*/
.button {
-webkit-box-shadow:
0px 8px 16px 0px;
box-shadow:
0px 8px 16px 0px;
}
.button:hover{
-webkit-box-shadow:
0px 16px 16px 0px;
box-shadow:
0px 16px 16px 0px;
}
/*And color elements does not have other values for the shadow*/
.red{
-webkit-box-shadow:
rgba(255, 0, 0, 0.1);
box-shadow:
rgba(255, 0, 0, 0.1);
}
.green{
-webkit-box-shadow:
rgba(0, 255, 0, 0.1);
box-shadow:
rgba(0, 255, 0, 0.1);
}
...to be used as follows:
<div class="button red>Red Button</div>
<div class="button green>Green Button</div>
I hope that explains the situation. Brainstorm time!
You need to add color: red
.red{
color:red
}
.green{
color:green
}
Since color: property applies to the text also, you need to wrap the text with span tag and give color:black to span.
DEMO
Unfortunately there is no way to specify ONLY the color for a box shadow as specified here: http://dev.w3.org/csswg/css3-background/#the-box-shadow
You will need to give a separate box shadow rule for each color class.
In CSS3 there in no box-shadow-color rule, so for different buttons you need to specify all shadow parameters (size, position, color).
try this css styles in this style using color for individual menu, u can try shadow to set instead of color...
HTMl Code
<div class="menu">
<ul>
<li class="active1">Home</li>
<li>About Us</li>
<li>Portfolio</li>
<li>Product</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
CSS Style
.menu{
font-family:Arial, Helvetica, sans-serif;
color:white;
float:left;
position:absolute;
top:95px;
width:855px;
background-image:url(../images/bottom-menu-line.png);
background-position:center bottom;
background-repeat:no-repeat;
}
.menu ul{padding:0; margin-left:65px; border-radius:10px;}
.menu ul li {
float:left;
border-radius:10px;
width:110px;
height:47px;
list-style:none;
padding:0;
margin-left:5px;
margin-right:5px;
/*overflow:hidden*/
}
.menu ul li a {
font-size:12px;
color:#fffcc7;
background-image:url(../images/button.png);
background-position:center;
height:47px;
overflow:hidden;
line-height:47px;
text-decoration:none;
width:110px;
text-align:center;
float:left;
border-radius:10px;
}
.menu li {float:left; padding:0;}
.menu ul li a:hover {
margin: -3px;
}
.menu ul li:nth-of-type(6) a:hover {
border:3px solid #c10202 !important;
border-radius:10px !important;
}
.menu ul li:nth-of-type(5) a:hover {
border:#c1d65f solid 3px;
border-radius:10px;
}
.menu ul li:nth-of-type(4) a:hover {
border:#01d290 solid 3px;
border-radius:10px;
}
.menu ul li:nth-of-type(3) a:hover {
border:#904ca1 solid 3px;
border-radius:10px;
}
.menu ul li:nth-of-type(2) a:hover {
border:#00caf3 solid 3px;
border-radius:10px;
}
.menu ul li:nth-of-type(1) a:hover {
border:3px #d44c1f solid;
border-radius:10px;
}
.active1{
border:3px #d44c1f solid;
width:110px !important;
border-radius:10px;
height:47px !important;
margin-bottom:7px !important;
margin-right:5px !important;
}
.active2{
border:#00caf3 solid 3px;
width:110px !important;
border-radius:10px;
height:47px !important;
margin-bottom:7px !important;
margin-right:5px !important;
}
.active3{
border:#904ca1 solid 3px;
width:110px !important;
border-radius:10px;
height:47px !important;
margin-bottom:7px !important;
margin-right:5px !important;
}
.active4{
border:#01d290 solid 3px;
width:110px !important;
border-radius:10px;
height:47px !important;
margin-bottom:7px !important;
margin-right:5px !important;
}
.active5{
border:#c1d65f solid 3px;
width:110px !important;
border-radius:10px;
height:47px !important;
margin-bottom:7px !important;
margin-right:5px !important;
}
.active6{
border:3px solid #c10202;
width:110px !important;
border-radius:10px;
height:47px !important;
margin-bottom:7px !important;
margin-right:5px !important;
}
No you can't, you have to put the 2 cases normal and hover for each button
http://dev.w3.org/csswg/css3-background/#the-box-shadow
Related
I have a button with border on the right and the bottom, when I hover that, both border is hidden, and show border on the top and the left with color same as background-color on parent that button, i want to make like a 3D button effect, but its not working.
Here's look like my button when i hover it
What i want is the border-color is red, and if the parent background-color is green the border-color is green
And here's my code
.cta {
display: inline-block;
padding: 10px 30px;
font-family: 'courier new' !important;
font-size: 19px !important;
background: #1d85bf;
color:#fff;
border:3px solid #0b527a;
border-top:0;
border-left: 0;
border-radius:3px;
text-transform:uppercase;
display: block;
overflow: hidden;
white-space: nowrap;
}
.cta:hover {
border:3px solid #dbdbdb;
border-color:inherit !important;
border-bottom: 0;
border-right: 0;
border-top-left-radius: 3px !important;
color:#fff;
}
Here's my fiddle https://jsfiddle.net/evpsthx3/
Problem is your parent has no border color set. So just set the border color to the parent. Something like this: https://jsfiddle.net/evpsthx3/9/
<div class="parent red">
<a class="cta">BUTTON</a>
</div>
<div class="parent green">
<a class="cta">BUTTON</a>
</div>
.parent.red {
background-color: red;
border-color: red;
}
.parent.green {
background-color: green;
border-color: green;
}
You can give that effect by adding the below css code, Hope it wrks.
.cta:hover {box-shadow: #000 5px 5px 5px;}
you can try this one:
.parent {
width:300px;
height:60px;
padding:30px;
}
.cta {
display: inline-block;
padding: 10px 30px;
font-family: 'courier new' !important;
font-size: 19px !important;
background: #1d85bf;
color:#fff;
border:3px solid #0b527a;
border-top:0;
border-left: 0;
border-radius:3px;
text-transform:uppercase;
display: block;
overflow: hidden;
white-space: nowrap;
}
.cta:hover {
border:3px solid #dbdbdb;
border-color:inherit !important;
border-bottom: 0;
border-right: 0;
border-top-left-radius: 3px !important;
color:#fff;
box-shadow: #242729 6px 6px 6px;
}
DEMO HERE
So I have an image inside a div that is centered in an outer-wrapper. I have a horizontal menu at the top of the wrapper that displays 5 sub divs inline. I have added css for a drop down menu that appears when you hover over the first of the 5 inline sub divs. When the drop down menu appears, it causes the image to shift to the right and I can't for the life of me figure out how to correct it. As you can see I have played around with z-index but i'm not sure if I understand what is happening or not happening with z-index and how it is used correctly.
HTML:
<div class="wrapper">
<div id="topmenu">
<div id="home">Home
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</div>
</div>
<div id="logo">
<img src="image.jpeg" />
</div>
</div>
CSS
.wrapper{
position:relative;
width:960px;
height:905px;
margin-top:5px;
margin-left:auto;
margin-right:auto;
/*text-align:left;
border:2px solid red;*/
background-color:#FFFFFF;
}
#topmenu{
position:relative;
border-bottom:2px solid #164207;
height:30px;
background-color:#ffffff;
z-index:3;
}
#logo{
position:relative;
border-bottom:2px solid #164207;
}
#logo img{
position:relative;
height:350px;
width:500px;
z-index:1;
}
#home{
display:inline-block;
float:left;
margin-top:5px;
margin-left:15px;
width:169px;
color:#164207;
font-family:serif;
font-weight:bold;
font-size:20px;
text-align:center;
border-right:2px solid #164207;
}
#home:hover .sub-menu {display:inline-block;}
.sub-menu {
overflow:hidden;
display: none;
width: 169px;
background-color: #164207;
color:#FFFFFF;
margin-top: 5px;
border: 1px solid #fff;
-webkit-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
-moz-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
}
.sub-menu li {
position:relative;
list-style-type: none;
display: block;
border-bottom: 1px solid #FFFFFF /*#eaeaea*/;
font-family:serif;
font-size: 12px;
height: 15px;
padding: 8px 0;
}
You need to add position: absolute; to .sub-menu to create a stacking context.
jsFiddle
#home{
display:block;
float:left;
margin-top:5px;
width:184px;
color:#164207;
font-family:serif;
font-weight:bold;
font-size:20px;
text-align:center;
border-right:2px solid #164207;
}
#home:hover .sub-menu {display:block;}
#course:hover .sub-menu{display:block;}
#leagues:hover .sub-menu{display:block;}
#events:hover .sub-menu{display:block;}
#about:hover .sub-menu{display:block;}
.sub-menu {
overflow:hidden;
display: none;
width: 182px;
background-color: #164207;
color:#FFFFFF;
/*padding: 10px 10px;
margin-left: 0px;*/
margin-top: 5px;
border: 1px solid #fff;
-webkit-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
-moz-box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
box-shadow: 0px 13px 25px rgba(0,0,0, 0.2);
position:absolute; /**************************** Important Bit*/
top:24px;
}
To re-adjust alignment- Remove margin-left:15px; from #home, #course, #leagues, #events, and #about and adjust widths on all of them. Then adjust the width of .sub-menu. See updated jsFiddle above for details and working model.
Example with navigation set up in <ul> unordered list </ul>. - Don't Need all the id's and resulting redundant CSS.
Would someone show me how to highligh parent and child navigation menu when active or current. Is it possible to highlight the parent menu item when a child page is selected. what i am trying to achieve is something like http://www.brotfabrik-berlin.de/ when you hover to a subpage the parent keeps being highlighted. Thank you.
#menu {
font-weight:700;
list-style:none;
width:990px;
margin:0px auto 0px auto;
height:29px;
padding:0px 0px 0px 0px;
/* Rounded Corners */
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
border-radius: 0px;
/* Background color and gradients */
background: #014464;
background: -moz-linear-gradient(top, #, #);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#), to(#));
/* Borders */
border: 1px solid #002232;
-moz-box-shadow:inset 0px 0px 1px #edf9ff;
-webkit-box-shadow:inset 0px 0px 1px #edf9ff;
box-shadow:inset 0px 0px 1px #edf9ff;
#menu li {
float:left;
display:block;
text-align:center;
position:relative;
padding: 4px 5px 4px 5px;
margin-right:0px;
margin-top:0px;
border:none;
z-index: 1;
#menu li:hover {
border: 1px solid #777777;
padding: 2px 4px 4px 4px;
/* Background color and gradients */
background: #F4F4F4;
background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));
/* Rounded corners */
-moz-border-radius: 0px 0px 0px 0px;
-webkit-border-radius: 0px 0px 0px 0px;
border-radius: 0px 0px 0px 0px;
#menu li a {
font-family:Arial Narrow;
font-size:15px;
color: #EEEEEE;
display:block;
outline:0;
text-decoration:none;
text-shadow: 0px 0px 0px #000;
#menu li:hover a {
color:#161616;
text-shadow: 0px 0px 0px #ffffff;
I would usually achieve this by adding a current class to the <li> of the navigation link. So if you are viewing home.html the navigation code would be like so:
<ul id="menu">
<li class="current">Home</li>
<li>About</li>
<li>Another page</li>
</ul>
Then I would style the current class by using the hover style of the link, or you could define a different style, for example:
#menu li.current a {
font-weight: bold;
}
If the <li> contains a sub menu (another <ul>), I would target the CSS like this:
#menu > li > a {
/* this would target the parent link */
}
And to target submenu links I would do:
#menu ul ul a {
/* this would target submenu links */
}
So I have this problem, which has never happened to me before.
I am trying to put a text field exactly next to an a button, which I already did and it looks great.
The problem is that it looks great on firefox, but on chrome the only issue is the button's height. I dont know why its not taking the specified height. Everything else on my site works great (height wise) its all the same specified hight on all cross-platforms
Here is the code:
HTML
<div> <!-- filter item start -->
<p>
<a href="#" id="add-friend-feed-link">
Add Friend
</a>
</p>
<form method="post" action="" name="searchFriendForm" id="add-friend-search">
<input type="text"/ name="searchFriendText">
<input type="button" class="small green button" id="add-friend-button"/>
</form>
<hr>
</div> <!-- filter item end -->
and CSS
/* Absolutes start */
#add-friend-search{
display: block;
position: absolute;
}
#add-friend-search input[type="text"]{
-moz-border-radius:4px 0px 0px 4px;
-moz-box-shadow:0 1px 0 #444444;
-webkit-border-radius:4px 0px 0px 4px;
-webkit-box-shadow:0 1px 0 #444444;
border-radius:4px 0px 0px 4px;
box-shadow:0 1px 0 #444444;
background:none repeat scroll 0 0 #D4D8DF;
border:1px solid black;
color:#444444;
font:13px Arial,sans-serif;
height:19px;
margin: 20px 4px 4px;
padding:5px 6px 4px;
width:250px;
text-align: center;
float: left;
display: inline-block;
}
#add-friend-search{
background:url("../images/small arrow.png") no-repeat scroll 88px 2px transparent;
display:block;
position:absolute;
width:332px;
}
#add-friend-search input[type="button"]{
background:url("../images/search icon.png");
background-position: center;
}
#add-friend-button{
border: 1px solid black;
border-radius: 0 4px 4px 0;
-moz-border-radius: 0 4px 4px 0;
-webkit-border-radius: 0 4px 4px 0;
display: inline-block;
height: 21px !important;
margin-right: 33px;
margin-top: 20px;
position: absolute;
right: 0;
max-height: 31px;
}
/*Absolutes end */
this is what it looks like in Firefox
and this is what it looks like in chrome
this is the button xcss that contains small, green but I am not supposed to modify this CSS AT ALL
/*--------------------------------------------------------------------------------------------
Button Styles Reset - Gets rid of Browser Specific Issues
-------------------------------------------------------------------------------------------- */
input[type="button"], button {
border:0 none;
font:inherit;
}
*:focus{outline:0 none;}
input[type="submit"] {border:1px solid rgba(0, 0, 0, 0.25);}
input[type="button"], button {-moz-box-sizing: content-box;}
input[type="button"]::-moz-focus-inner, button::-moz-focus-inner { padding:0;border:0 none; }/*fixes mozilla button padding */
.clearfix:after {
clear: both;
content: '.';
display: block;
font-size: 0;
line-height: 0;
visibility: hidden;
width: 0;
height: 0;
}
/*--------------------------------------------------------------------------------------------
General Button Styles, Cascades Down To Every Button
-------------------------------------------------------------------------------------------- */
.button {
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
-moz-box-shadow:0 1px 3px rgba(0, 0, 0, 0.50);
-webkit-box-shadow:0 1px 3px rgba(0, 0, 0, 0.50);
box-shadow:0 1px 3px rgba(0, 0, 0, 0.50);
background:#222222 url(button-images/button-overlay.png) repeat-x;
border:1px solid rgba(0, 0, 0, 0.25);
color:#FFFFFF !important;
cursor:pointer;
display:inline-block;
font-size:13px;
font-weight:bold;
line-height:1;
overflow:visible;
padding:5px 15px 6px;
position:relative;
text-decoration:none;
text-shadow:0 -1px 1px rgba(0, 0, 0, 0.25);
width:auto;
text-align:center;
}
.button:hover {
background:#111111;
color:#FFFFFF;
}
.button:active {
background:#242424;
}
.green.button {
background-color:#91BD09;
}
.green.button:hover {
background-color:#749A02;
}
.green.button:active {
background-color:#a4d50b;
}
.blue.button {
background-color:#0E59AE;
}
.blue.button:hover {
background-color:#063468;
}
.blue.button:active {
background-color:#1169cc;
}
.purple.button {
background-color:#660099;
}
.purple.button:hover {
background-color:#330066;
}
.purple.button:active {
background-color:#7f02bd;
}
.breen.button {
background-color:#2DAEBF;
}
.breen.button:hover {
background-color:#007D9A;
}
.breen.button:active {
background-color:#36cbdf;
}
.red.button {
background-color:#CC0000;
}
.red.button:hover {
background-color:#990000;
}
.red.button:active {
background-color:#ea0202;
}
.magenta.button {
background-color:#A9014B;
}
.magenta.button:hover {
background-color:#630030;
}
.magenta.button:active {
background-color:#ce025c;
}
.orange.button {
background-color:#FF5C00;
}
.orange.button:hover {
background-color:#D45500;
}
.orange.button:active {
background-color:#fd762a;
}
.yellow.button {
background-color:#FFE115;
}
.yellow.button:hover {
background-color:#E4C913;
}
.yellow.button:active {
background-color:#fee539;
}
.white.button {
background-color:#FFFFFF;
border:1px solid #CCCCCC;
color:#666666 !important;
font-weight:normal;
text-shadow:0 1px 1px #FFFFFF;
}
.white.button:hover {
background-color:#EEEEEE;
}
.white.button:active {
background-color:#ffffff;
}
.gray.button {
-moz-box-shadow:0 1px 3px rgba(0, 0, 0, 0.50);
background:#FFFFFF url(button-images/button-overlay-black.png) repeat-x;
border:1px solid #BBBBBB;
color:#555555 !important;
text-shadow:0 1px 1px rgba(255, 255, 255, 0.5);
}
.gray.button:hover {
background-color:#EEEEEE;
border-color:#999999;
color:#444444 !important;
}
.gray.button:active {
background-color:#ffffff;
}
/*--------------------------------------------------------------------------------------------
Small Buttons
-------------------------------------------------------------------------------------------- */
.small.button {
font-size:11px;
padding:5px 15px 6px;
background-image:url(button-images/small-button-overlay.png);
}
input[type="submit"].small.button, .small.button.input {
padding:3px 15px 4px;
}
input[type="button"].small.button, button.small.button {
padding:4px 15px;
}
/*--------------------------------------------------------------------------------------------
Tall Buttons
-------------------------------------------------------------------------------------------- */
.tall.button {
font-size:14px;
padding:8px 19px 9px;
background-image:url(button-images/tall-button-overlay.png);
}
.tall.gray.button {
background-color:#FFFFFF;
background-image: url(button-images/tall-black.png);
background-repeat:repeat-x;
}
.tall.gray.button:hover {
background-color:#EEEEEE!important;
border-color:#999999;
color:#444444 !important;
}
.tall.gray.button:active {
background-color:#FFFFFF!important;
}
.tall.button em {
font-size:11.5px;
font-style:normal;
display:block;
margin-top:5px;
}
/*--------------------------------------------------------------------------------------------
Round Buttons
-------------------------------------------------------------------------------------------- */
.round.button {
-moz-border-radius:15px;
-webkit-border-radius:15px;
border-radius:15px;
background-image:url(button-images/round-button-overlay.png);
border:1px solid rgba(0, 0, 0, 0.25);
font-size:13px;
padding:0;
}
.round.button span {
-moz-border-radius:14px;
-webkit-border-radius:14px;
border-radius:14px;
display:block;
line-height:1;
padding:4px 15px 6px;
}
.round.button.input {
padding:3px 13px 4px;
}
.small.round.button {
-moz-border-radius:12px;
-webkit-border-radius:12px;
border-radius:12px;
font-size:11px;
}
input[type="button"].round.small.button, button.round.small.button {
padding:0;
}
.small.round.button span {
-moz-border-radius:11px;
-webkit-border-radius:11px;
border-radius:11px;
padding:6px 15px 6px;
}
.large.round.button {
-moz-border-radius:18px;
-webkit-border-radius:18px;
border-radius:18px;
background-position:left bottom;
}
.large.round.button span {
-moz-border-radius:17px;
-webkit-border-radius:17px;
border-radius:17px;
font-size:14px;
padding:7px 20px 9px;
}
.large.tall.round.button small {
display:block;
margin-top:5px;
}
Chrome and Firefox seem to be in conflict with displaying the styles in your classes: small, green and input in conjuction with the style applied for the id add-friend-button.
There are a lot of styles being applied against that button. I would suggest you try to rebuild that form, adding a class at a time and check in each browser until you encounter the difference.
EDIT
The difference between the rendering of the submit button is due to
-moz-box-sizing: content-box;
located in your css class
input[type="button"], button {
-moz-box-sizing: content-box;
}
turn if off in firebug in firefox and you will see the button take on the same dimensions as in chrome.
There's a good article on this at quirksmode.org and you can find documentation on box-sizing on MDN. The solution is the same as what Nicholas suggests.
input[type=submit], input[type=button], button {
box-sizing: content-box;
-moz-box-sizing: content-box;
-ms-box-sizing: content-box;
-webkit-box-sizing: content-box;
}
Like with border-radius, I prefer to use a SASS mixin to handle the browser prefixes.
How can I create a "Contact Us" hyperlink as the one present on the top-right of this page?
I am particalarly interested on the balloon style.
They use simple html for the link and css to show rounded corners and an arrow.
Contact Us<span class="arrow"><span></span></span>
li.contactus a {
-moz-border-radius:5px 5px 5px 5px;
background:none repeat scroll 0 0 #EBE9D9;
border:1px solid #FFFFFF !important;
color:#4C4632 !important;
display:block;
float:left;
font-size:1.3em;
font-weight:bold;
line-height:1;
margin:0;
padding:0.4em 0.7em 0.6em 1.2em;
text-decoration:none;
text-shadow:1px 1px 0 #FFFFFF;
width:6em;
}
li.contactus a span.arrow {
border-left:0 none;
border-right:16px dashed transparent;
border-top:11px solid #FFFFFF;
bottom:-11px;
left:8px;
right:auto;
}
li.contactus a span span {
border-left:0 none;
border-right:14px dashed transparent;
border-top:10px solid #EBE9D9;
bottom:auto;
left:1px;
top:-12px;
}
li.contactus a span {
background:none repeat scroll 0 0 transparent;
border-bottom-width:0;
display:block;
height:0;
position:absolute;
width:0;
}
Since that is static, I would just use an <img> for this.
If you check the html and css in for that balloon you'll get your answer:
html:
<ul><li class="contactus">Contact Us<span class="arrow"><span></span></span></li></ul>
css:
li.contactus a span.arrow {
border-left:0 none;
border-right:16px dashed transparent;
border-top:11px solid #FFFFFF;
bottom:-11px;
left:8px;
right:auto;
}
li.contactus a span {
background:none repeat scroll 0 0 transparent;
border-bottom-width:0;
display:block;
height:0;
position:absolute;
width:0;
}
li.contactus, #home_nav li.contactus {
float:none;
font-size:1em !important;
margin:0;
overflow:visible !important;
padding:0;
position:absolute !important;
right:20px;
top:-0.5em;
width:10em;
z-index:99999;
}
li.contactus a {
-moz-border-radius:5px 5px 5px 5px;
background:none repeat scroll 0 0 #EBE9D9;
border:1px solid #FFFFFF !important;
color:#4C4632 !important;
display:block;
float:left;
font-size:1.3em;
font-weight:bold;
line-height:1;
margin:0;
padding:0.4em 0.7em 0.6em 1.2em;
text-decoration:none;
text-shadow:1px 1px 0 #FFFFFF;
width:6em;
}