CSS - nth-child conditions appearing on wrong elements - html

The goal is a rounded side nav with hover effects in CSS. I'm using nth-child to control border radius for the top and bottom. As you will see on the fiddle, when you hover over the elements in between the 1st and 4th child, you get the radius settings of nth-child(1). Why?
I'm using this markup:
http://jsfiddle.net/hKxt9/
HTML
<ul id="side-nav">
<li class="side-nav-item clients" id="link_clients">Clients</li>
<li class="side-nav-item rtemplates" id="link_routine_templates">Routines</li>
<li class="side-nav-item exlib" id="link_exercise_library">Exercise Library</li>
<li class="side-nav-item logout" id="link_log_out">Log Out</li>
</ul>
CSS
#side-nav{
border: 1px solid #D5D5D5;
border-radius: 10px;
padding: 0px !important;
list-style-type: none;
}
.side-nav-item{
padding: 10px;
border-bottom: 1px solid #D5D5D5;
border-radius: 0;
margin: 0px !important;
font-size: 16px;
font-weight: bold;
}
.side-nav-item a{
color: #808080;
}
.side-nav-item:hover{
background: #D5D5D5;
}
.side-nav-item.active{
background: #01bbea;
}
.side-nav-item.active {
color: #fff;;
}
.side-nav-item:nth-child(4){
border-bottom: 0px solid black;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.side-nav-item:nth-child(1){
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
border-bottom: 1px solid #D5D5D5;
}

First of all it is wrong to have anchors as child nodes of a list. You structure should look like ul>li>a.
On the other hand nth-child() works for elements, not for class selectors. And even not being so, your elements with .side-nav-item class are always the first element of its father, which are always the anchor. So if nth-child() would work for classes (which is not the case) then your code wouldn't work anyway.
So if you change your structure to this:
<ul>
<li></li>
<li></li>
<li></li>
</ul>
Which is valid HTML, then you can do what you are looking for in this way:
li:nth-child(1) a {
/* your stylings */
}

Related

How to remove border on active li tab

I have a list ul with items li. Under the list there is a box surrounded with border. The top border of the box is also the bottom border of the list items.
What I want to do know is to remove the bottom border of the active tab. That means removing the top border of the content box along the active tab. Is this possible or do I need to use a different approach?
li {
display: inline-block;
padding-top: 0;
padding: 15px;
border-right: 1px solid #e6e6e6;
cursor: pointer;
border-top: 1px solid #e6e6e6;
font-family: 'Cera';
font-size: 13px;
}
ul {
list-style-type: none;
margin: 0 auto;
border-left: 1px solid #e6e6e6;
padding-left: 0px;
}
.content-box {
display: block;
min-height: 100px;
margin: 0 auto;
border: 1px solid #e6e6e6;
overflow: hidden;
padding-bottom: 10px;
}
.active {
position: relative;
background-color: #f8f8f8;
top: -3px;
}
<ul id="menu">
<li class="active" data-nav="1">Prerender</li>
<li data-nav="2">Prefetch</li>
<li data-nav="3">Preconnect</li>
<li data-nav="4">DNS-prefetch</li>
</ul>
<div class="content-box box1 expanded">
<h3 id="isPrerender"> Prerendered page:</h3>
<ul class="results" id='pagetitle1'></ul>
</div>
Here's how I'd like it to look:
I suggest that you use negative margin to overlap elements.
Use a margin-top:-1px to overlap the top border of the lower box with the bottom edge of the top boxes. This allows the background-color of the active top box to cover the top border of the lower box.
Use margin-left:-1px on all top boxes except the first one to overlap the borders on their left and right sides. Otherwise, with a border on only one side, the active box will be missing a piece of border where it rises above the others.
I've removed the white space between <li> elements because, since they are display:inline-block, that space is rendered as gaps between the boxes.
I'm using additional padding to raise the active top box, instead of using negative top. This keeps the text inside the active box at the same height as the other boxes.
I've aligned the top boxes with vertical-align:bottom to keep them flush against the bottom box.
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
display: inline-block;
padding: 15px;
margin-left: -1px;
border-style: solid;
border-color: #e6e6e6;
border-width: 1px 1px 0 1px;
cursor: pointer;
font-family: 'Cera';
font-size: 13px;
vertical-align: bottom;
}
li:first-child {
margin-left: 0;
}
.content-box {
min-height: 100px;
border: 1px solid #e6e6e6;
margin-top: -1px;
padding: 10px;
}
.active {
background-color: #f8f8f8;
padding-top: 18px; /* 15 + 3 */
}
<ul id="menu">
<li data-nav="1">Prerender
</li><li class="active" data-nav="2">Prefetch
</li><li data-nav="3">Preconnect
</li><li data-nav="4">DNS-prefetch</li>
</ul>
<div class="content-box box1 expanded">
<h3 id="isPrerender">Prefetched page:</h3>
<ul class="results" id='pagetitle1'></ul>
</div>
If your idea is to slide down the tab to hide the border , then you should reset vetical-align on li (and eventually mind the white-space) , then increase the padding of 1px (for a one px border) and low it down of that extra pixel(s) like you tried.
li {
display: inline-block;
padding-top: 0;
padding: 15px;
border-right: 1px solid #e6e6e6;
cursor: pointer;
border-top: 1px solid #e6e6e6;
font-family: 'Cera';
font-size: 13px;
vertical-align: bottom;
}
ul {
list-style-type: none;
margin: 0 auto;
border-left: 1px solid #e6e6e6;
padding-left: 0px;
}
.content-box {
display: block;
min-height: 100px;
margin: 0 auto;
border: 1px solid #e6e6e6;
overflow: hidden;
padding-bottom: 10px;
}
.active {
position: relative;
background-color: #f8f8f8;
padding-bottom: 16px;/* increase height of 1 px here, can be any value you want */
top: 1px;/* low it done at least the border's thickness to hide */
}
body {
margin: 1em;
}
<ul id="menu">
<li class="active" data-nav="1">Prerender</li><!-- kill that white space via comments
--><li data-nav="2">Prefetch</li><!--
--><li data-nav="3">Preconnect</li><!--
--><li data-nav="4">DNS-prefetch</li>
</ul>
<div class="content-box box1 expanded">
<h3 id="isPrerender"> Prerendered page:</h3>
<ul class="results" id='pagetitle1'></ul>
</div>

include a pseudoelement inside a anchor hover state

I have pseudoelements next to my links in a navigation menu. There are small downward arrows indicating a dropdown and On hover, the background changes. However, the only area that is covered is the active link and not the downward pointing arrow.
A sample of that is below:
.item > a {
color: #000;
padding-top: 1.5rem;
padding-bottom: 1.1rem;
}
.item > a:hover {
background-color: blue;
color: #fff;
}
.arrow-nav-item:after {
content: '';
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #5a5a5a;
clear: both;
position: absolute;
top: 25px;
right: 625px;
}
<ul id="items">
<li class="item"><a class="arrow-nav-item" href="#">Main Item</a>
<ul class="subitem">
<li>Chapter 1</li>
</ul>
</li>
</ul>
Basically I have an ::after on my anchor tag which is positioned absolutely and is styled to look like a down arrow. On hover, a background appears, and I want the arrow included inside the colored hover area.
The reason it's not included I think is because of the absolute positioning - because when the arrow is relative, I can include it in the hover area. I don't think I can do that because giving the :after a relative positioning loses control of placement.
A couple of things I tried: add more right padding to the anchor, setting a fixed width on anchor and changing placement of pseudo-element (moving it to <li> tag) etc.
Should this be refactored to change? Is absolute positioning not the best way to handle these pseudoelements?
Using right in that way will cause problems as the screen resizes. Instead, you can remove absolute positioning and position the anchor with margin instead...
.item>a {
color: #000;
padding-top: 1.5rem;
padding-bottom: 1.1rem;
}
.item>a:hover {
background-color: blue;
color: #fff;
}
.arrow-nav-item:after {
content: '';
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #5a5a5a;
margin-left: 1em;
display: inline-block;
vertical-align: middle;
margin-right: 1em;
}
.arrow-nav-item:hover:after {
border-top-color: #FFF;
}
<ul id="items">
<li class="item"><a class="arrow-nav-item" href="#">Main Item</a>
<ul class="subitem">
<li>Chapter 1</li>
</ul>
</li>
</ul>
While absolute-positioning would be a good way to handle this, you certainly don't want to be using giant offsets relative to the right. What I would recommend is to make use of ::before, and simply set a small negative margin-left on the dropdown:
.item>a {
color: #000;
padding-top: 1.5rem;
padding-bottom: 1.1rem;
}
.item>a:hover {
background-color: blue;
color: #fff;
}
.arrow-nav-item:before {
content: '';
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #5a5a5a;
position: absolute;
margin-left: -35px;
margin-top: 5px;
}
<ul id="items">
<li class="item"><a class="arrow-nav-item" href="#">Main Item</a>
<ul class="subitem">
<li>Chapter 1</li>
</ul>
</li>
</ul>
Note that this makes the dropdown relative to the element's left-hand side, so it will always appear in the same place, regardless of the content of the <li>. However, it still has the dropdown arrow outside of the`. The problem is that in order to have the background cover both components, you need to move the arrow inside the bullet points.
This can then be offset with padding-left on the <a> tag itself, so that the dropdown remains within the blue background:
.item>a {
color: #000;
padding-top: 1.5rem;
padding-bottom: 1.1rem;
}
.item>a:hover {
background-color: blue;
color: #fff;
}
.arrow-nav-item:before {
content: '';
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #5a5a5a;
position: absolute;
margin-left: -15px;
margin-top: 5px;
}
.arrow-nav-item {
padding-left: 20px; /* Larger than margin-left */
}
<ul id="items">
<li class="item"><a class="arrow-nav-item" href="#">Main Item</a>
<ul class="subitem">
<li>Chapter 1</li>
</ul>
</li>
</ul>
I don't think it's possible to have the dropdown arrow outside the bullet point and still retain the background, but hopefully this will suffice :)

How to create chat bubbles like facebook Messenger

How would I create chat bubbles like this. More specifically how to group two ore more consecutive messages by one type of user into a bubble as a whole. For example FOR THE SENDER - the first message has right bottom border a 0, the messages in between have right top,bottom as 0 border radius and the last one has top right 0 border radius . Do I have to use javascript or can it be done using css.
HTML structure ca be
<ul>
<li class="him">By Other User</li>
<li class="me">By this User, first message</li>
<li class="me">By this User, secondmessage</li>
<li class="me">By this User, third message</li>
<li class="me">By this User, fourth message</li>
</ul>
What kind of css class/styles should i be using?
This is a rather basic example but it should explain all of the fundamentals you require.
Most of the solution lies within + adjacent sibling selector. In this case, it's used to apply a different border radius to multiple messages in a row from the same person.
ul{
list-style: none;
margin: 0;
padding: 0;
}
ul li{
display:inline-block;
clear: both;
padding: 20px;
border-radius: 30px;
margin-bottom: 2px;
font-family: Helvetica, Arial, sans-serif;
}
.him{
background: #eee;
float: left;
}
.me{
float: right;
background: #0084ff;
color: #fff;
}
.him + .me{
border-bottom-right-radius: 5px;
}
.me + .me{
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
.me:last-of-type {
border-bottom-right-radius: 30px;
}
<ul>
<li class="him">By Other User</li>
<li class="me">By this User, first message</li>
<li class="me">By this User, secondmessage</li>
<li class="me">By this User, third message</li>
<li class="me">By this User, fourth message</li>
</ul>
You will need a start and a end class, like this
li {
border: 1px solid black;
list-style-type: none;
margin: 2px 0;
padding: 2px 5px;
}
.him {
float: left;
border-radius: 0 10px 10px 0;
clear: both;
}
.me {
float: right;
border-radius: 10px 0 0 10px;
clear: both;
}
.him.start {
border-top-left-radius: 10px;
}
.him.end {
border-bottom-left-radius: 10px;
}
.me.start {
border-top-right-radius: 10px;
}
.me.end {
border-bottom-right-radius: 10px;
}
<ul>
<li class="him start">By Other User</li>
<li class="him">By Other User</li>
<li class="him end">By Other User</li>
<li class="me start">By this User, first message</li>
<li class="me">By this User, secondmessage</li>
<li class="me">By this User, third message</li>
<li class="me end">By this User, fourth message</li>
<li class="him start">By Other User</li>
<li class="him">By Other User</li>
<li class="him end">By Other User</li>
<li class="me start">By this User, first message</li>
<li class="me">By this User, secondmessage</li>
<li class="me">By this User, third message</li>
<li class="me end">By this User, fourth message</li>
</ul>
Here is a pure css solution, but it hinges on your ability to detect and apply the chat__bubble--stop class when the final message of a group is sent. Unfortunately the pseudo class :last-of-type can't be used; as others have pointed out, the last message in a group isn't necessarily the last of the conversation. It also makes use of the adjacent sibling selector (+).
.chat {
list-style-type: none;
width: 20em;
}
.chat__bubble {
margin-bottom: 3px;
padding: 5px 10px;
clear: both;
border-radius: 10px 10px 2px 2px ;
}
.chat__bubble--rcvd {
background: #f2f2f2;
color: black;
float: left;
border-bottom-right-radius: 10px;
}
.chat__bubble--sent {
background: #0066ff;
color: white;
float: right;
border-bottom-left-radius: 10px;
}
.chat__bubble--sent + .chat__bubble--sent {
border-top-right-radius: 2px;
}
.chat__bubble--rcvd + .chat__bubble--rcvd {
border-top-left-radius: 2px;
}
.chat__bubble--stop {
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
<ul class="chat">
<li class="chat__bubble chat__bubble--rcvd chat__bubble--stop">What are you up to?</li>
<li class="chat__bubble chat__bubble--sent">Not much.</li>
<li class="chat__bubble chat__bubble--sent">Just writing some CSS.</li>
<li class="chat__bubble chat__bubble--sent">I just LOVE writing CSS.</li>
<li class="chat__bubble chat__bubble--sent chat__bubble--stop">Do you?</li>
<li class="chat__bubble chat__bubble--rcvd">Yeah!</li>
<li class="chat__bubble chat__bubble--rcvd">It's super fun.</li>
<li class="chat__bubble chat__bubble--rcvd chat__bubble--stop">... SUPER fun.</li>
</ul>
I would suggest following this article for help when it comes to creating text bubbles:
https://www.templatemonster.com/blog/chat-bubbles-css-ui-tutorial/
As for the beginning and ending bubbles, use JQuery to identify and change their CSS properties based on their parent container.
if you want the sent images, you will need to wrap them inside of the li and do a float right, or absolute position inside of a relative object (the li).
<ul class="ulContainer">
<li>test1</li>
<li>test1</li>
<li>test1</li>
</ul>
Css:
.ulContainer li{
width:200px;
height:20px;
background-color:#9abff9;
list-style-type:none;
margin:10px 0 10px 0;
padding: 3px 3px 3px 5px;
border-radius: 10px 2px 2px 10px;
}
Use below script to change first and last li:
$('.ulContainer li:first').css('border-top-right-radius','10px');
$('.ulContainer li:last').css('border-bottom-right-radius','10px');
here's the JSFiddle: https://jsfiddle.net/s60dgfw2/
Update based upon your comment:
I believe this is the closest you can get to what you are trying to achieve without using JQuery. You need advanced selectors you can only get from grouping in .each() statements through JQuery. Or by adding multiple css classes to Lists.
Please see the response by LGSon's for how to do it with multiple CSS classes.
Or see below:
https://jsfiddle.net/5dcto0td/
.fancyContainer{
border: 1px solid #555;
position:relative;
width:300px;
padding:5px;
overflow:hidden;
}
.chatBox {
width: 300px;
list-style: none;
margin: 0 0 0 -40px;
position:0;
}
.chatBox li {
margin: 5px 0 5px 0;
padding: 3px 5px 3px 5px;
}
/*Set up initial chat element for .me*/
.chatBox .me {
min-height: 20px;
float:right;
clear: both;
background-color: #34a1ef;
border-radius: 10px 2px 2px 10px;
}
/*Set up initial chat element for .him*/
.chatBox .him {
min-height: 20px;
float:left;
clear: both;
background-color: #ddd;
border-radius: 2px 10px 10px 2px;
}
/*Set up grouped radius*/
.him + .me {
border-top-right-radius:10px;
}
.me + .him {
border-top-left-radius:10px;
}
.me + .me {
border-bottom-right-radius:2px;
}
.him + .him {
border-bottom-left-radius:2px;
}
/*Set up First and Last radius for .me*/
.chatBox > .me:first-child {
border-top-right-radius:10px;
}
.chatBox > .me:last-child{
border-bottom-right-radius:10px;
}
/*Set up First and Last radius for .him*/
.chatBox > .him:first-child{
border-top-left-radius:10px;
}
.chatBox > .him:last-child{
border-bottom-left-radius:10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="fancyContainer">
<ul class="chatBox">
<li class="him">Hello... This is a chatbox.</li>
<li class="me">Well well. I guess this is a chatbox.</li>
<li class="me">I'll have to talk about this some other time.</li>
<li class="me">No wait. I might change my mind</li>
<li class="him">Nonesense good sir! We'll have this talk right now and here.</li>
<li class="him">I Like...</li>
<li class="him">popsicles.</li>
<li class="me">I can't believe you've done this to me!</li>
</ul>
</div>

Bottom border with the same width from text value on css

I have an issue, I am trying to add 1 px to an underlined text, but researching a lot on the web I found that the only way was adding a border and a padding bottom
But the width is longer than the word and I want that the effect is the same form a underline effect, cropped with the word width.
Here is my fiddle
https://jsfiddle.net/0orb5h4s/1/
And my try to the selected underline class
/* Underline Issue */
.selected {
border-bottom: 1px solid #000;
/* text-decoration: underline; */
padding-bottom: 1px;
}
I think a span here is what you are looking for:
.horizontal-tabs li {
display: inline;
list-style-type: none;
padding-right: 10px;
padding-left: 10px;
}
.horizontal1,
.horizontal2 {
border-left: 1px solid #000;
}
/* Underline Issue */
.selected span {
text-decoration: underline;
}
<div class="tabs">
<ul class="horizontal-tabs">
<li class="horizontal0">Description</li>
<li class="horizontal1">Product Care</li>
<li class="horizontal2 selected"><span>Shipping Information</span>
</li>
</ul>
</div>
If you are actually looking to distance the underline from the text then you previous technique still works if you use the span as mentioned before.
.horizontal-tabs li {
display: inline;
list-style-type: none;
padding-right: 10px;
padding-left: 10px;
}
.horizontal1,
.horizontal2 {
border-left: 1px solid #000;
}
/* Underline Issue */
.selected span {
border-bottom: 1px solid #000;
padding-bottom: 1px;
}
<div class="tabs">
<ul class="horizontal-tabs">
<li class="horizontal0">Description</li>
<li class="horizontal1">Product Care</li>
<li class="horizontal2 selected"><span>Shipping Information</span>
</li>
</ul>
</div>
If you add a span inside your li elements you could use the border style on the span element instead. I edited your fiddle code and removed some unnecessary classes that you were using for setting the border-left style.
HTML
<div class="tabs">
<ul class="horizontal-tabs">
<li><span>Description</span></li>
<li><span>Product Care</span></li>
<li class="selected"><span>Shipping Information</span></li>
</ul>
</div>
CSS
.horizontal-tabs li {
display: inline-block;
list-style-type: none;
padding-right: 10px;
padding-left: 10px;
border-left: 1px solid #000;
}
/* This removes the first border */
.horizontal-tabs li:first-child {
border-left: none;
}
/* Underline Issue */
.horizontal-tabs li.selected span {
border-bottom: 1px solid #000;
padding-bottom: 1px;
display: inline-block;
}
JSFiddle
Here is an answer - https://jsfiddle.net/0orb5h4s/6/
Just added
.selected span {
border-bottom: 1px solid #000;
}
and
<li class="horizontal2 selected"><span>Shipping Information</span></li>
and removed the bottom border from the selected li.
The border applies to the padding as well and that's why adding a span moves the border to the content inside the padding.
Why don't you add a span?
HTML
<div class="tabs">
<ul class="horizontal-tabs">
<li class="horizontal0">Description</li>
<li class="horizontal1">Product Care</li>
<li class="horizontal2 selected">
<span>Shipping Information</span>
</li>
</ul>
</div>
CSS
.selected span {
border-bottom: 1px solid #000;
padding-bottom: 5px;
}
You can check my solution here: https://jsfiddle.net/lordfox/0orb5h4s/4/
Hope that helps! :)

help in Vertical CSS Menu

What I'm trying to do to design a vertical CSS menu like this one . on the right of this site
. I've two problems .
How can I add an image in the menu item .
How can I MAKE the BORDER RADIUS of all the item on the top and on the bottom NOT for each one .
That's my code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS3 Buttons</title>
<style>
.button {
width: 400px;
height: 100px;
line-height: 100px;
color: #C0C0C0;
text-decoration: none;
font-size: 50px;
font-family: helvetica, arial;
font-weight: bold;
display: block;
text-align: center;
position: relative;
padding-bottom:1px;
/* BACKGROUND GRADIENTS */
background: #F5F3F4;
/* BORDER RADIUS */
/* -moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px; */
/* TEXT SHADOW */
text-shadow: 1px 1px 1px black;
/* BOX SHADOW */
-moz-box-shadow: 0 1px 3px black;
-webkit-box-shadow: 0 1px 3px black;
box-shadow: 0 1px 3px black;
}
/* WHILE HOVERED */
.button:hover {
color: #A8A8A8;
-moz-box-shadow: 0 2px 6px black;
-webkit-box-shadow: 0 2px 6px black;
}
/* WHILE BEING CLICKED */
.button:active {
-moz-box-shadow: 0 2px 6px black;
-webkit-box-shadow: 0 2px 6px black;
}
</style>
</head>
<body>
Profile
Privacy
Services
Avatar
Language
</body>
</html>
First, you should adjust your html to include a list as follows (notice I also added id attributes):
<ul>
<li> Profile </li>
<li> Privacy </li>
<li> Services </li>
<li> Avatar </li>
<li> Language </li>
</ul>
Then, to add the image use the following css:
a#profile-btn {
background-image:url(/image_path/profile.png);
}
a#privacy-btn {
background-image:url(/image_path/privacy.png);
}
a#services-btn {
background-image:url(/image_path/services.png);
}
a#avatar-btn {
background-image:url(/image_path/avatar.png);
}
a#language-btn {
background-image:url(/image_path/language.png);
}
And finally the rounded borders:
ul {list-style:none;}
ul li:first-child a {
-moz-border-radius-topleft: 25px;
-moz-border-radius-topright: 25px;
-webkit-border-radius-topleft:25px;
-webkit-border-radius-topright:25px;
border-top-right-radius:25px;
border-top-left-radius:25px;
}
ul li:last-child a {
-moz-border-radius-bottomleft: 25px;
-moz-border-radius-bottomright: 25px;
-webkit-border-radius-bottomleft:25px;
-webkit-border-radius-bottomright:25px;
border-bottom-right-radius:25px;
border-bottom-left-radius:25px;
}
EDIT: This code is intended to work with all your other provided css, as long as you replace the HTML as shown.
Using pseudo classes like so:
(If your nav is a list and the button class is on the list element)
li.button:first-child {
-moz-border-radius: 4em 4em 0 0;
border-radius: 4em 4em 0 0;
}
li.button:last-child {
-moz-border-radius: 0 0 4em 4em;
border-radius: 0 0 4em 4em;
}
Use lists for that:
<ul id="main-menu">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
And the CSS:
ul li {
float: left;
display: inline;
text-decoration: none;
font-size: 20px;
font-family: helvetica, arial;
font-weight: bold;
display: block;
text-align: center;
position: relative;
margin: 0 0 0 30px;
background: #F5F3F4;
-moz-border-radius: 10px 10px 0 0; /* 10 top left, 10 top right. 0 for the rest */
-webkit-border-top-radius: 10px; /* This will select only the top part */
border-radius: 10px 10px 0 0;
text-shadow: 1px 1px 1px black;
-moz-box-shadow: 0 1px 3px black;
-webkit-box-shadow: 0 1px 3px black;
box-shadow: 0 1px 3px black;
padding: 15px 30px;
}
ul li a { color: #C0C0C0; text-decoration: none; }
Hope you get the point. You can have a preview here: http://www.jsfiddle.net/UtNA8/
You could use a containing element for the links, ideally one that can apply a semantic relationship to its contents, I've used a ul (since it's basically a non-ordered list) and style that, rather than trying to style specific instances of an otherwise non-grouped set of elements:
html
<ul>
<li> Profile </li>
<li> Privacy </li>
<li> Services </li>
<li> Avatar </li>
<li> Language </li>
</ul>
css
ul {
width: 12em;
border-radius: 1em;
overflow: hidden;
}
ul li {
padding: 0.5em;
background-color: #eee;
}
JS Fiddle demo.
If you're targeting browsers with reliable implementations of last-child you could also use the :first-child and :last-child pseudo elements:
css:
ul li {
width: 12em;
padding: 0.5em;
background-color: #eee;
}
ul li:first-child {
-webkit-border-top-radius: 1em;
-moz-border-radius: 1em 1em 0 0;
border-radius: 1em 1em 0 0;
}
ul li:last-child {
-webkit-border-bottom-radius: 1em;
-moz-border-radius: 0 0 1em 1em;
border-radius: 0 0 1em 1em;
}
JS Fiddle demo
I'd be wary of first-child, last-child pseudo selectors. Obviously they are great ideas, and you should use them because they're a part of the standard, but at the same time you'll need to make some allowances for browsers that don't properly adhere to standards - ahem MS. Same goes for the border-radius properties obviously. Oh and finally, you might want to include your icon graphics as tags inside of your links (that is, if you want them to show up on any browser that doesn't support css properly, and you feel their content is of particular note).