What is the best way to give <li> elements a border-top with rounded bottom corners?

I'm working on a menu design and need some help with styling. Currently, the menu items have a border but I would like to add a 6px border-top with rounded bottom corners specifically to the selected item. The challenge is to achieve this without moving the position of the menu item itself. I've included a small sketch for reference: [link](https://i.sstatic.net/f8VQ9.jpg) Your assistance in solving this problem would be greatly appreciated. Thank you!)

Answer №1

Try using a pseudo element:

ul{
  list-style-type:none;
}
li{  
  float:left;
  padding:5px;
  border:1px solid black;
  position:relative;
}
.active:before{
  content:"";
  position:absolute;
  top:0;
  height:6px;
  right:0;
  left:0;
  border-radius: 0 0 10px 10px;
  background:blue;
}
<ul>
     <li class="active">Home</li>
     <li>Gallery</li>
     <li>About</li>
<ul/>

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

The theme for Wordpress in 2015, also known as

Is there a way to automatically resize and fit the cover picture in the twenty fifteen theme to make it a square cover instead of the default rectangular one? I've been trying to change the dimensions of the cover image container but can't seem t ...

Material UI categorizing iPads with a width of 768px and a height of 1024px as belonging to the small

I am facing a challenge with the layout of my app on different screen sizes. To address this issue, I am utilizing Material UI's breakpoints to control the layout based on the screen size. According to the documentation, screens categorized as small ...

The Media Queries in the Wordpress html5blank theme are failing to function properly

While using the html5blank theme to develop a WordPress site, I noticed that my media queries are functioning properly locally. However, when I add them to the WordPress style.css file, they seem to stop working. Even after stripping away all other media q ...

Ways to locate a webtable element through XPath when it is nested within a td tag

Having trouble accessing the webtable elements within table2? Take a look at the page source provided below: <table id="table1"> <tr class="head"> <td class="left" colspan="2"> <!--PAGE LINKS--> < ...

Tips for creating a hover-activated dropdown menu

How can I create a drop-down menu in my horizontal navigation bar that appears when hovering over the Columns tab? The drop-down menu should include options such as Articles, Videos, Interview, and Fashion. To better illustrate what I am looking for, here ...

Display information retrieved from database query in HTML

As someone who is new to PHP, I am determined to learn and improve my programming skills through it. Currently, I have incorporated the following PHP code into my webpage to fetch data from my database: <?php //code missing to retrieve my ...

What causes manual input rendered in Django Template to be omitted from form submission?

When I use {{ form.ietf_tag|bootstrap }} in my Django template, it renders like this: Django rendering https://i.sstatic.net/jAOWE.png <div class="form-group"> <label class="control-label " for="id_ietf_tag">IETF tag</label> < ...

Trouble with updating scope values in the view within IONIC 1 and AngularJS

I recently implemented a feature to save the two most recent login details. The functionality works correctly, but I'm facing an issue where my view only updates upon refresh even though the scope values are being updated. I've tried using $scop ...

Identifying CSS on iPhone and iPad: A Guide

I need to adjust the CSS style based on different devices. This is how I currently have it set up: <link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/Destop.css")" media="only screen and (min-width: 1224px)"/> <link rel="s ...

A guide to extracting text from HTML elements with puppeteer

This particular query has most likely been asked numerous times, but despite my extensive search, none of the solutions have proven effective in my case. Here is the Div snippet I am currently dealing with: <div class="dataTables_info" id=&qu ...

Can a YouTube video be triggered to play when a specific CSS style is selected?

I am searching for a method to display and play different YouTube videos based on a selected CSS style from a drop-down menu. I believe JavaScript can be utilized to detect the chosen CSS. Include the following in the html header of the page. <script ...

Unique fluid layout with varied behavior

I am on the hunt for a layout that caught my eye some time ago, but unfortunately I forgot to save it. It featured 3 main columns that cleverly transformed into 2 when resized, causing the 3rd column to shift to the row below. It wasn't your typical l ...

Using jQuery to animate a div when clicked by the mouse

Here's the scenario: I have 3 block elements arranged in a specific order: Image Hidden Text Block (.hidden) Footer Block (.blockimage) When the page loads, the image is displayed over the hidden text block (which contains further infor ...

Function exhibiting varying behavior based on the form from which it is called

Currently, I'm utilizing AJAX to execute a server call, and I've noticed that the behavior of my function varies depending on its origin. Below is an excerpt of the code that's causing confusion: <html> <body> <script> ...

Enhance the efficiency of your website by ensuring that js/css files are loaded before the completion of the HTML

Currently, my website uses a template system involving XML/XSLT which outputs the generated HTML in one piece after completing all its tasks. As a result, browsers tend to start downloading all the content only after the entire HTML is generated, causing d ...

Ways to update the text alongside a slider form with JavaScript

I am currently working on a project using html and js function slide(){ let v= document.getElementById("slide_inner"); document.getElementById("slider").textContent=v.value; } <form id="slider"> <label for="slide_inner"&g ...

What is causing the colored SVG to appear lighter than the intended color after using a mask to recolor it?

I have a project using VueJS where I am trying to change the color of SVGs by looping through them and using mask and rect tags. However, I am noticing that as the icon index increases, the color of the icon becomes lighter. What could be causing this issu ...

Tips for integrating Less and Bootstrap in an Angular 6 project

After making changes to angular.json to use less as the styleext, I tested it by creating a component. However, now I want to incorporate Bootstrap classes into my component's css/less. I specifically want all buttons in my component to have the .mx-1 ...

Unfinished card or cut-off content within a bootstrap accordion

Greetings to the StackOverflow community! I am facing an issue with my accordion and card setup, where the card is not fully displayed within the button at the bottom. The following image illustrates the problem: https://i.sstatic.net/aSFsc.png Here is ...

One particular Django template is failing to load the CSS, while the rest of the templates are

In my folder, I have two Django templates. One template is for the URL localhost:8000/people and it correctly fetches CSS from /m/css/style.css. The problem arises with the second template meant for the URL localhost:8000/people/some-name. This template f ...