Is there a way to position my left tab to float to the left while also extending to fill the remaining space next to the tabs that are floating

I am working with bootstrap tabs that are aligned to the right within my container:

https://jsfiddle.net/yc2dxnev/

Here is the code snippet:

<div class=container>
    <ul id="tabs" class="tabs-right tabs">
            <li class="banana active"><a>Banana</a></li>
            <li class="monkey"><a>Monkey</a></li>
            <li class="woods"><a>Woods</a></li>
        </ul>
</div>

<style>
ul.tabs a {
  display: block;
  outline: none;
}

ul.tabs {
  list-style: none;
  padding: 0;
  margin: 0;
  display: block;

}

ul.tabs>li {
  display: inline-block;
  position: relative;
  margin-top: 5px;
  margin-bottom: -1px;
}

My goal is to keep the tabs aligned right and have only the left tab stick to the left, while filling the space up to the next tab. I've included an image for reference:

If you have any suggestions or tricks on how to achieve this, please let me know.

Answer №1

Make sure your right tabs are aligned properly by floating them to the right with float:right;. To ensure that the first list item occupies the entire space, it should be placed at the end of your ul and have overflow:hidden; added to it. Here's how your code will appear:

<div class="container">
    <ul id="tabs" class="tabs-right tabs" data-tabs="tabs" style="">
        <li class="monkey"><a>Monkey</a></li>
        <li class="woods"><a>Woods</a></li>
        <li class="banana active"><a>Banana</a></li> // move this li item to the end
    </ul>
</div>

ul.tabs>li.active {
    border-bottom-color: #FFF;
    background-color: #FFF;
    overflow:hidden;
}

.monkey, .woods{
    float:right;
}

Check out this fiddle for reference.

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

JavaScript / html Error: function body missing closing curly brace

I encountered an error that I'm struggling to resolve: "SyntaxError: missing } after function body". Despite not having a function named 'body', I have attempted changing every instance of 'body' in my script. However, ...

Rearranging HTML elements using jQuery

I have a collection of 5 HTML elements <a href="#"><img src="image1.jpg" /></a> <a href="#"><img src="image2.jpg" /></a> <a href="#"><img src="image3.jpg" /></a> <a href="#"><img src="image4.j ...

Activate the toggle menu

Hi there! I'm currently working on a menu and I want the clicked item to become active, switching the active state to another item when clicked. However, my current implementation is not working as expected. Any assistance would be greatly appreciated ...

Having trouble with PHP upload to server file function

This code seems to be error-free, but unfortunately it is not inserting the file into the database and destination folder upon clicking the upload button. HTML Form <html> <body> <form action="includes/parts-cat/zip ...

Using HTML5 canvas to design a customizable measuring tool

I am trying to figure out how to create a ruler on the top and left side of my document, just like the one shown in the image. I've searched everywhere but haven't found anything useful. Can anyone please help me with this? ...

Tips for avoiding repetitive animations when using jQuery animate toggle

Check out my Pen here. I'm having an issue with a share button that expands on hover. Everything works fine, except if you hover over it multiple times, the animation repeats as many times as you've hovered. Is there a way to prevent this from h ...

What steps can be taken to resolve image display issues in a Heroku application?

For the past two days, I've been struggling with a particular issue. I have a Heroku app with a small icon named "icon.png" located in the "assets" folder within the main directory. Here's the directory structure: assets icon.png index.html i ...

Updating the correct list item in an unordered list on a Bootstrap modal pop-up submission

I am dealing with an unordered list of messages where each message within a list item is clickable. <ul id="home-message-list" class="messages"> <li> <a href="#"> <span class="linkClick" name="message">< ...

Animating with React using the animationDelay style does not produce the desired effect

Is there a way to apply an animation to each letter in a word individually when hovering over the word? I want the animation to affect each letter with an increasing delay, rather than all at once. For example, if scaling each letter by 1.1 is the animatio ...

SVG images are not perfectly aligned with surrounding elements, causing a noticeable discrepancy, which becomes even more pronounced when they are being animated

I've been experimenting with creating animated 3-D bars in a bar graph. To ensure there are no issues with stretching or aspect ratio, I decided to split each bar into three parts: (1) an SVG for the top of the bar, (2) a div with adjustable height fo ...

What is the best way to enclose an h2 with a designated class, along with the following two elements, inside a wrapper class?

Looking to select a specific block of code to wrap with a class using the jQuery .wrapAll method. I need to target the <h2> element and the two elements that follow it. Unfortunately, the elements before and after this block are inconsistent, ruling ...

Discover the art of concurrently listening to both an event and a timer in JavaScript

Upon loading the page, a timer with an unpredictable duration initiates. I aim to activate certain actions when the countdown ends and the user presses a button. Note: The action will only commence if both conditions are met simultaneously. Note 2: To cl ...

When you click the button, the page refreshes with no content

Every time I click on a button, an empty page reloads after invoking the button's onClick event. The code snippet on the page is as follows: <html> <head></head> <body>2015</body> </html> I am ...

CSS Navigation Bar Fails to Function Properly on Mobile Devices

Check out the plunkr I have created by visiting: http://plnkr.co/edit/gqtFoQ4x2ONnn1BfRmI9?p=preview The menu on this plunkr functions correctly on a desktop or laptop, but it doesn't display properly on a mobile device. I suspect that the issue may ...

What is the best way to customize bootstrap styles?

Currently, I am attempting to modify basic CSS attributes within the default theme that is included with a new ASP.NET MVC 5 application in Visual Studio 2013. Specifically, my goal is to change the background color of the navigation menu. With the help o ...

What is the best way to format log lines in a GWT custom logging section?

In GWT, a personalized logging area can be created by implementing a HasWidgetsLogHandler. In my situation, I am using a VerticalPanel. However, the logging output is too wide and distorts the rest of the page. How can I wrap the lines? Each log entry add ...

Displaying Image URLs in a Web Form using AJAX

I have been researching how to accomplish this task. So far, my search has led me to uploading an image and then using AJAX to preview it. Is there a way to do the same for an image URL? For example, when a user submits an image URL, can AJAX provide a ...

The model is only loaded when I access the developer toolbar

Recently, I encountered an issue while working with a three.js mesh. Upon opening the webpage in Chrome or Firefox (I haven't tested it on IE), everything seemed fine but the canvas displaying the mesh did not appear. It was only after activating the ...

Issues with Tooltips and Popovers in Bootstrap 5

I recently built a small website using Bootstrap 5. On this site, I added 2 buttons at the bottom of the page with tooltips and popovers. However, they seem to be malfunctioning as nothing is being displayed. You can check out the site for yourself at th ...

Issue with form submission and POST request not functioning in PHP

I am facing an issue with my pay.php script, which is supposed to execute after entering an amount. However, the pay.php file is not loading. Below is the HTML code: <div class="sap_tabs"> <div id="horizontalTab" style="d ...