Not every menu item will have radius corners applied to its end

Here is my customized menu -

<div ><ul id="menu">
        <li class="one"><a href="http://www.domain.com">Home</a></li>
        <li class="two"><a href="<?php echo bp_loggedin_user_domain() ?>">Profile</a></li>
        <li class="three"><a href="<?php echo bp_loggedin_user_domain() ?>messages">Inbox</a></li>
        <li class="four"><a href="<?php echo bp_loggedin_user_domain() ?>friends">Friends</a></li>
        <li><?php bp_adminbar_notifications_menu() ?>
        <ul>
        <li> </li>
        </ul>
        </li>
    </ul>

Custom CSS for the menu items -

ul#menu li {
    list-style: none;
    float: left;
    margin: 0 0px 0 0;
    background-color: #F8FCFE;
    position: relative;
    z-index: 1;
    border-top-left-radius: 10px 10px;
    border-bottom-left-radius: 10px 10px;

}

ul#menu li a:link, ul#menu li a:visited {
    display: block;
    text-align: center;
    width: 88px;
    height: 53px;
    line-height: 53px;
    font-family: 'Montserrat', sans-serif;
    text-decoration: none;
    font-size: 13px;
    color: black;
    letter-spacing: 1px;
    outline: none;
    float: left;
    background: #F8FCFE;
    border-top-left-radius: 10px 10px;
    border-bottom-left-radius: 10px 10px;
}

My goal is to have the first item with top left and bottom left radius, and the last item with top right and bottom right radius. This will create a vertical rectangle shape with rounded corners.

Answer №1

Designate the first li with a class of first, and the last one with a class of last. The first should have rounded borders on the top-left and bottom-left corners, while the last should have rounded borders on the top-right and bottom-right corners.

li.first {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px; }

li.last {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px; }

Here is an example menu:

<ul id="menu">
<li class="one first"><a href="http://www.domain.com">Dashboard</a></li>
<li class="two"><a href="<?php echo bp_loggedin_user_domain() ?>">Profile</a></li>
<li class="three"><a href="<?php echo bp_loggedin_user_domain() ?>messages">Messages</a></li>
<li class="four"><a href="<?php echo bp_loggedin_user_domain() ?>friends">Friends</a></li>
<li class="last"><?php bp_adminbar_notifications_menu() ?></li>
</ul>

Answer №2

How about trying this example on jsFiddle?

I kept your HTML as is but made some changes to the CSS:

ul#menu li {
    list-style: none;
    float: left;
    margin: 0 0px 0 0;
}

li.one a{
    border:2px solid #999;
    border-top-left-radius: 10px 10px;
    border-bottom-left-radius: 10px 10px;
    border-right:none;
}
li.two a, li.three a {
    border-top:2px solid #999;
    border-bottom:2px solid #999;
}
li.four a{
    border:2px solid #999;
    border-top-right-radius: 10px 10px;
    border-bottom-right-radius: 10px 10px;
    border-left:none;
}

ul#menu li a:link, ul#menu li a:visited {
    display: block;
    text-align: center;
    width: 88px;
    height: 53px;
    line-height: 53px;
    font-family: 'Montserrat', sans-serif;
    text-decoration: none;
    font-size: 13px;
    color: black;
    letter-spacing: 1px;
    outline: none;
    float: left;
    background: #ccc;

}​

Answer №3

html:

<ul id="menu">
    <li class="one"><a href="http://www.domain.com">Dashboard</a></li>
    <li class="two"><a href="<?php echo bp_loggedin_user_domain() ?>">Profile</a></li>
    <li class="three"><a href="<?php echo bp_loggedin_user_domain() ?>messages">Messages</a></li>
    <li class="four"><a href="<?php echo bp_loggedin_user_domain() ?>friends">Friends</a></li>
    <li class="five"><?php bp_adminbar_notifications_menu() ?>
    <ul>
    <li> </li>
    </ul>
    </li>
</ul>

css:

ul#menu li {
list-style: none;
float: left;
margin: 0 0px 0 0;
background-color: #F8FCFE;
position: relative;
z-index: 1;
border-top-left-radius: 10px 10px;
border-bottom-left-radius: 10px 10px;
overflow:hidden;}

ul#menu li.one {border-radius: 10px 0px 0px 10px;}

ul#menu li.five {border-radius: 0px 10px 10px 0px;}  

you can designate the corners for each item in a clockwise manner like this : top left, top right, bottom right, bottom left.

adjusted for easy copying and pasting directly into css file.

Answer №4

Cascading Style Sheets, known as CSS3, provides the ability to customize the style of individual child elements within a parent container. For example:

#gallery img:last-child {
 // define some specific styling here
}

#gallery img:first-child {
 // set a different style for this element
}

I trust that this information proves useful.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Manipulating div position interactively with vanilla javascript during scroll

I'm trying to create an effect where an image inside a div moves vertically downwards as the user scrolls, stopping only at the end of the page. I've attempted a solution using a script from another post, but it doesn't seem to be working. ...

CSS - sticky header causing issues when resizing the browser window

I'm currently facing an issue with the layout of my navbar. While I've managed to create a fixed navbar that stays at the top, the content on the page seems to be hidden underneath it. To address this problem, I attempted to add a 5% margin from ...

The issue arises when radio buttons allow for multiple selections and labels cannot be displayed in a single row

I am facing an issue with the radio buttons displayed in the Bootstrap format. The labels for the radio buttons are not aligning on the same line as the buttons. Below is the code I am using: <div class="row"> <div class="col-lg-4&q ...

How can I create a grid layout in Bootstrap using columns of sizes 1.5, 8.5, and 2?

Currently working with the bootstrap grid system and facing a dilemma - col-sm-1 is too small, while col-sm-2 is too big for my needs. Is there a way to create something in between like col-sm-1.5 without causing the entire bootstrap grid to collapse? ...

Reiterating the text and determining the length of the string

Currently, the script is capable of calculating the width of the script based on user input and can also determine the width of a string. However, I am facing an issue when attempting to repeat a string entered by the user. For example, if the user input ...

What is the best way to show a check mark when selecting a checkbox?

I have customized my checkbox to appear as a circle, and now I want to display a check mark when the user selects the checkbox. When I remove -webkit-appearance: none;, the check mark appears but my CSS stops working. Is there a way to achieve this witho ...

Unable to create a universal <header> and <footer> to be displayed across all pages

After trying to separate the <header> and <footer> into external files, everything seemed to work fine in the console. However, when running the code, it ended up returning undefined. This is the HTML for the Footer: <footer id="footer ...

When positioning 2 divs on top of each other, rotating one by 180 degrees causes it to be considered secondary in the visibility hierarchy. What is the reason behind this?

While delving into the realm of HTML, I stumbled upon a concept that has left me perplexed. Upon stacking two divs on top of each other, I observed an interesting phenomenon where rotating the second div by 180deg (i.e transform:rotateY(180deg)), causes t ...

Adding Bootstrap to a button is a simple process that can enhance the

I am new to using Bootstrap and have a question. I am currently working with CodeIgniter for my website, and I have added the Bootstrap files to the asset folder along with my CodeIgniter file. I want to incorporate Bootstrap CSS into the following code: ...

Diagonal-left ending div in cascading style sheets

Looking to achieve a div with a diagonal side similar to the image in the link below: https://i.sstatic.net/u9grW.png I'm trying to figure out the best way to do this. One idea is to position 2 divs closely together and rotate one of them. Alternativ ...

Division of two "div" sections

I have designed my webpage using three separate div elements for [logo, brand name], [product details], and [hamburger icon]. However, when applying display=flex and flex=1 in the CSS, I noticed that the last two elements are getting stuck together. Can so ...

Ways to retrieve attribute value in Selenium python without the use of .get_attribute() method

I am new to posting questions, so please let me know if I need to provide more clarification. I am also a beginner in Python, so I hope that I am using the right terms to phrase my question. Essentially, I have developed a customizable web scraper that re ...

Items vanish when hovering over them

Creating nested links in the sidebar navigation bar with CSS has been a challenge for me. While hovering over main links, I can see the sub-links being displayed. However, when I try to hover/click on the children of the sub-links, they disappear. Note: M ...

How can I utilize Material-UI's Grid component to make a single cell occupy the entire remaining horizontal space?

I am currently utilizing the Grid component from material-ui in my React 16.13.0 application. My objective is to create a row with three items. The first two items are supposed to occupy only the required space without specifying pixel values. I want the t ...

Idea: Develop a bookmarklet that generates a header form and deletes it upon submission

After much contemplation and experimentation, I have been grappling with the idea of creating a bookmarklet that displays a header when clicked on any webpage. This header will contain a small form that submits its contents to a server before disappearing. ...

iOS devices experiencing issues with fixed positioning

Currently, I am in the process of implementing a few instances of , but I am encountering some issues with the CSS. When viewing the website on an iPad or iPhone, the calendar is positioned correctly as the container covers the window like a fixed position ...

Gradient background overlaid with a blended SVG shape

Creating a full gradient background with a clipping mask can be tricky. I used an SVG to achieve the desired shape by cutting part of the background color, but now I'm facing a challenge with blending the colors seamlessly. I tried setting the SVG co ...

What can I do to prevent Masonry from floating all of my grid items to the left?

Is there a way to center justify the masonry grid items? I have noticed that my Masonry layout is aligning all the grid items to the left or justifying them to the left side: <div class="wrap"> <div class="parent grid"> <div class=" ...

Curved edges achieved without the need for relative positioning

Can anyone help me with a specific code snippet to achieve rounded corners for this page ? Currently, I am using the PIE.htc file which only works when I declare position:relative; throughout the layout, causing disruptions. Is there a code workaround that ...

Enhancing User Experience with Interactive React Hover Effects

Hello, I have tried various combinations but still cannot get the desired background color to display when hovering over my <p> element. I am looking for a CSS-only solution and not interested in using JavaScript hover events. I would appreciate it ...