Styling a Separator Nav with round edges stricly in CSS - css

My navbar looks like:
<div id="navbar">
<ul class="tabnavcenter">
<li class="active">Test</li>
<li class="aaron">Test</li>
<li>Test</li>
<li>Test</li>
<li>Test</li>
</ul>
</div>
And my CSS for the NavBar looks like:
ul.tabnavcenter {
background: #fff;
padding:0px 0px;
font-size:14px;
font-weight:bold;
color:#000;
overflow:hidden;
width:957px;
background-image: -moz-linear-gradient(top, #cacaca, #848484);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#cacaca), to(#848484));
}
ul.tabnavcenter li {
float:left;
border-right: #DDDDDD 1px solid;
list-style-type:none;
}
ul.tabnavcenter li.active {
background-image: -moz-linear-gradient(top, #cacaca, #4B4B4B);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#cacaca), to(#4B4B4B));
}
ul.tabnavcenter li:hover {
background: #7D7D7D;
cursor:pointer;
}
Is there a possible way I could add rounded edges to the first and last link just using CSS? :)

I put your code into a JS Fiddle but it's not apparent how you want to handle the last link (because of the gradient to the right, a rounded edge would look strange).
http://jsfiddle.net/Kk7vK/
Is there a possible way I could add rounded edges to the first and
last link just using CSS?
First/last can be selected using :first-child and :last-child. Browser support is good (IE7+) for first-child, not so good (IE9+) on last-child.
Example
ul.tabnavcenter > LI:first-child{ /* do something different */ }
CSS Selector Reference: http://www.w3.org/TR/selectors/
Rounded edges can be achieved using border-radius (with vendor-specific prefix(es) such as -moz-border-radius). Internet Explorer support for border-radius started with IE9 (though there are polyfills for < IE9).

Related

Combine CSS background-image and gradient on third h3 using nth-child

I'm having a heck of a time trying to combine a diagonal linear gradient and regular background-image together plus apply it only to the second h3 element; here is what I've got:
HTML
<div id="something">
<div><h3>...</h3></div>
<div><h3>...</h3></div>
<div><h3>...</h3></div>
<div><h3>...</h3></div>
</div>
CSS
#something h3:nth-child(2) {
background: linear-gradient(135deg, rgba(221,221,221,1) 0%,
rgba(221,221,221,1) 95%, rgba(0,0,0,1) 95%, rgba(0,0,0,1) 100%),
#ddd url(/assets/img/bullet.png) left 12px no-repeat;
}
I've had the nth-child selector working on other stuff previously before and this gradient is from an online generator, what am I missing here?
Looks like the selector should be:
#something > div:nth-child(3) > h3
https://jsfiddle.net/db2n5r63/1/
linear-gradient() takes the place of url(). In fact they are two delarations for the same background. One will be chosen. So define more precisely what you want and perhaps chose a span inside H3 to achieve the effect you want.
Your nth-childwont work beacuse the h3 tags are wrapped in a div so can you do something like this:
#something div:nth-child(2) h3
Now to make the background work we combine the background image url and the gradient. You can define the background url first then do a comma and define the gradient:
This stackoverflow question answers that in more depth.
#something div:nth-child(2) h3{
background: url("http://lorempixel.com/300/300/") no-repeat,linear-gradient(135deg, rgba(221,221,221,1) 0%,
rgba(221,221,221,1) 95%, rgba(0,0,0,1) 95%, rgba(0,0,0,1) 100%);
background-position-x: 12px;
}
I've made an Example for you to see this in action.

Bootstrap 3 submenu parent highlight

Submenus were removed in Bootstrap 3. I added them back using this example/code:
http://bootply.com/71520
The issue is the parent menu item does not stay highlighted as we hover over the submenu. How can this be accomplished? This used to work in bootstrap 2:
http://getbootstrap.com/2.3.2/components.html#dropdowns
I tried looking all over the CSS and couldn't find this.
You need to add a new style to .dropdown-submenu:hover > a. Note, I copied the CSS from the existing styles on the a:hover.
.dropdown-submenu:hover > a {
color: #fff;
text-decoration: none;
background-color: #357ebd;
background-image: -webkit-gradient(linear,left 0,left 100%,from(#428bca),to(#357ebd));
background-image: -webkit-linear-gradient(top,#428bca,0%,#357ebd,100%);
background-image: -moz-linear-gradient(top,#428bca 0,#357ebd 100%);
background-image: linear-gradient(to bottom,#428bca 0,#357ebd 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca',endColorstr='#ff357ebd',GradientType=0);
}
http://bootply.com/96695

Firefox li href CSS selector

I've styled some list items (li) using CSS. The style's applied to the a selector within the li. It works great in Chrome, IE and Safari but not Firefox:
<ul class="organisations">
<li class="community-care"><a href="http://adviceglos.org.uk/organisation-type/community-care/" title="View all posts in Community Care" >Community Care</a></li>
</ul>
Here's the CSS:
ul.organisations li.community-care a {
background-image: -webkit-gradient(linear,center top,center bottom,color-stop(0%,#5CBCC4),color-stop(100%,#38939B));
background-image: -webkit-linear-gradient(#5CBCC4 0,#38939B 100%);
background-image: -moz-linear-gradient(#5CBCC4 0,#38939B 100%);
background-image: -o-linear-gradient(#5CBCC4 0,#38939B 100%);
background-image: -ms-linear-gradient(#5CBCC4 0,#38939B 100%);
background-image: linear-gradient(#5CBCC4 0,#38939B 100%);
background-color: #5CBCC4;
border: 1px solid #318188;
border-bottom-color: #245E63;
}
You have a syntax error in your stylesheet. In particular, line 529 is:
background-image: -o-linear-gradient((#eeeeee 0,#ccc 100%) !important;
Note that you have one more open paren than close paren. In a spec-compliant CSS parser (which excludes WebKit), this causes the UA to treat everything up to the matching close paren as part of the background-image value. In this case, that's all the rest of the stylesheet, so all the rules after this point are ignored.
Further note that Firefox did report this problem in its error console, which is how I found it...
Apply -moz for firefox like this:
background: -moz-linear-gradient(#BF698C 0px, #93506D 100%) repeat scroll 0 0 transparent;

CSS Gradient in BODY but not full length with fallback

I know that you can set a gradient for a specific height in a body tag.
So I have my body background that has a blue gradient for 300px height and then continues with plain white.
But I want to have a fallback for that gradient for older browsers, how can I make sure that these 300px will have a plain blue color and then white in older browsers that don't support css3 gradients?
Laurens' answer works, but if you don't want to introduce extra elements with no semantic meaning, you can make the html background white and give the body a height of 300 pixels.
html {
background: white}
body {
margin:0;
padding:8px;
max-height:300px;
overflow:visible;
background:blue;
background:linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
}
set the style for older browsers first, then add it for css3-capable browsers:
#div{
background: blue;
background: linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
}
It will fall back to blue if gradients are not supported.
edit: Kinda misread your question.
I think the easiest solution is to add the white color to the body tag, and then add the blue plain/gradient to a div that is nested in that body tag.
Hope this helps
try this
.cssgradients
{
background: /* CSS Gradiant */
}
.no-cssgradients
{
background: /* link 1px by 300px blue background */ top left repeat-x;
/* more */
}
If you include modernizr on your page you'll be able to target css3 styles to browser that support them, your body tag would gain a class based on whether the browser supports css3-gradiants or not and you can style appropriately.
.cssgradients
{
background: /* CSS Gradiant */
}
.no-cssgradients
{
background: /* link to 1px by 300px blue background */ top left repeat-x;
}

How can I get IE Filter & CSS Transparent Background to display together?

I am trying to get a transparent PNG & Gradient to display at the same in IE. Right now, the filter dominates over the background image. If I take out the filter, the PNG does display. Ideally, I would like the PNG to be on top of the gradient.
CSS:
.defaultSelection {
border: 1px solid #bbb; color: #222222; outline: 0 none;
background: url('/img/dropdown-arrow.png') right center no-repeat;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#e9e9e9', endColorstr='#ffffff' )
}
HTML:
<li class="defaultSelection">Current Selection</li>
Good news: This is possible with IE (despite what others have said). But it does need a little hack called CSS3Pie.
CSS3Pie is a hack for IE which allows it to support a variety of CSS3 features using ordinary CSS, rather than those horrible filter styles.
See here for its supported features: http://css3pie.com/documentation/supported-css3-features/
You'll note that this includes the ability to specify a background with an image and a gradient:
As described on the page linked above, simply specify your CSS with -pie-background in addition to the normal background style, and also with the Pie behavior style to run the Pie script.
#myElement {
background: url(bg-image.png) no-repeat #CCC; /*non-CSS3 browsers will use this*/
background: url(bg-image.png) no-repeat, -moz-linear-gradient(#CCC, #EEE); /*gecko*/
background: url(bg-image.png) no-repeat, -webkit-gradient(linear, 0 0, 0 100%, from(#CCC) to(#EEE)); /*webkit*/
background: url(bg-image.png) no-repeat, linear-gradient(#CCC, #EEE); /*future CSS3 browsers*/
-pie-background: url(bg-image.png) no-repeat, linear-gradient(#CCC, #EEE); /*PIE*/
behavior: url(PIE.htc);
}
Behind the scenes, CSS3Pie creates a VML element, and layers it with the real element to achieve the desired effects (VML is a vector graphics language which is supported by IE6 and up). But you don't need to know any of this, as Pie goes to some lengths to make itself completely transparent to the developer and to the user. It does have some bugs and known issues, but overall it's a very very good tool for pulling older versions of IE up to some sort of parity with more modern browsers.
Have you tried using the gradient on the li and then applying the image on an element within the li?
<li class="defaultSelection">Current Selection<span class='bg'> </span></li>
.defaultSelection {
border: 1px solid #bbb; color: #222222; outline: 0 none;
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#e9e9e9', endColorstr='#ffffff' )
}
.defaultSelection .bg{
display:inline-block;
width: 10px;
height:10px;
background: transparent url('/img/dropdown-arrow.png') right center no-repeat;
}
This is not possible with IE as a filter gradient is essentially another background image (it takes its place.) Try reversing the order to have the filter first and the bg image last in the CSS selector, you'll most likely see the image.
Your best bet is to go with layering, or make on PNG that has both the image and transparency.

Resources