Arranging items in nav bar with Flexbox spacing

I'm looking for a way to adjust the spacing of items within a navigation bar that includes tags and a search bar. I experimented with using space-between, but I'm not sure how to properly resize the search bar to make it slightly larger. Would combining flex-end help achieve this?

Current Attempt

https://i.sstatic.net/ZYndo.png

Mock-Up Preview

https://i.sstatic.net/mR2Oy.png

The box on the right should be slightly enlarged.

Code Snippet

Container

const TagsContainer = styled.div`
    display: flex;
    width: 100%;
    margin-top: 15px;
`

export default function Tags() {
    return (
        <TagsContainer>
            <Tag>Algorithms</Tag>
            <Tag>Videos</Tag>
            <Tag>Books</Tag>
            <Tag>Tutorials</Tag>
            <Tag>Health</Tag>
            <Tag>Finance</Tag>
            <Tag>Rants</Tag>
            <Tag>Stream</Tag>
            <Tag>Music</Tag>
            <Search />
        </TagsContainer>
    )
}

Tag Style

const TagContainer = styled.div`
    height: 100%;
    max-height: 40px;
    opacity: .8;
    text-align: center;
`

const TagStyle = styled.span`
    font-family: 'Lora';
    min-width: 80px;
    color: white;
    padding: 10px;
    border: 1px solid white;
    font-size: 15px;
`

export default function Tag({ children }) {
    return (
        <>
            <TagContainer>
                <TagStyle>
                    { children }
                </TagStyle>
            </TagContainer>
        </>
    )
}

Search Component

const SearchContainer = styled.div`
    color: white;
    border: 1px solid black;
    flex-grow: 2;
    min-height: 40px;
    height: 100%;
    
`

export default function Search() {
    return (
        <>
            <SearchContainer>
                This is a search box
            </SearchContainer>
        </>
    )
}

Answer №1

To enable all flex items within TagContainer to expand, include the style rule flex-grow: 1;

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

Transferring data between two screens within an Ionic app by harnessing the power of angularJS

As a beginner in Ionic and Angular development, I am currently facing an issue with my Ionic application. I have two pages - one with drop-down selects and a submit button, and another page to process the user's choices and display the results. The pr ...

How can we detect line breaks within a selection using JavaScript?

Apologies for the lack of expertise in the content below, as it is being produced by a designer experimenting with coding :D The goal here is to determine the number of lines selected or highlighted by the cursor. When I mention "lines," I mean what is vi ...

The React modal refuses to disappear, stubbornly clinging to the original component it sprang from

Hey there, I'm a beginner in learning React and I'm encountering an issue with my popup modal component. Even after showing the modal, I can still interact with and click on the main UI elements. Can anyone assist me with this problem? https://i ...

The chosen option does not equal the value retrieved by using jQuery's

I am perplexed by the situation at hand. It seems that there is a discrepancy in the selected option of my select element. Despite appearing as the empty default option on top, the inspected element reveals it displaying a value of 13. https://i.sstatic.n ...

End <li> element in WebGL

Using Three.js, I have a model where clicking on objects creates a list of buttons. When I click an li element, the function is triggered but the result only shows after clicking in the model again. How can I refocus back to the WebGl model without needin ...

How can I create a fixed navigation menu in Wordpress that always stays at the top of the page?

I'm currently using the default Wordpress theme Twenty Twelve for my website located at: . My goal is to have the navigation menu always stay at the top of the page while scrolling, similar to a site called wpsites (I can't provide the link due ...

What is the anticipated durability of flex products?

UPDATE: JANUARY 2014 - The answer provided previously is no longer relevant. This question has been posted on flexcoders as well. Our team primarily works with flex technology. However, a potential client has expressed concerns about the longevity of fle ...

Setting up the bxslider plugin in HTML

I'm having trouble getting an image slider (bxslider) to work on my website, despite following the setup instructions provided on . Here is the html code I've used: <!doctype html> <html> <head> <!-- jQuery library (se ...

Certain code will not execute if a JavaScript div is inside a container div

Having trouble with executing specific commands on a div inside a container? I've got a function called doFunc() that doesn't seem to work when assigned to the div with id "x1" inside the container. Strangely enough, if I move the div outside of ...

Issue with Django not executing Bootstrap Mobile Toggle properly

In my Django project, I have successfully loaded Bootstrap4 with min.css/js files in my stylesheet references. However, the mobile toggle menu is not working when clicked. There are no errors in the browser source, so it seems like there might be a missi ...

Are there any tools available that can generate CSS code automatically

Our team offers a pre-set CSS file along with the HTML mock-up for partners to customize, such as changing colors and background images, to match their desired aesthetic. They then provide feedback on the modified CSS files back to us. However, we face a ...

Looking to display the ng-option in two lines within Angular 6?

How can I display data in a select dropdown with two lines for each option? I am currently using ng-select. <ng-select [(ngModel)]="selectedData" placeholder="Select Data"> <div *ngFor="let data of Data"> <ng-option [value]="da ...

Loading jQuery via JavaScript in the head section of the HTML document

I'm currently developing an application using jQuery and jQuery Mobile. I have a script in the head section that dynamically loads both libraries. However, my body contains a script that relies on jQuery ($) and is unable to access it because it loads ...

Using Python with Selenium to extract data from td elements inside tr tags using xpath

I am currently utilizing Selenium within my Python project to retrieve data from a Table using the following code snippet: xpath = "//div[@id='tab_highscore']//table[contains(@class, 'highscore')]//tr" users = driver.find_elem ...

How can we display an absolutely positioned div when hovering over a card with the help of Tailwind CSS?

I am currently working on a Next.js application with Tailwind CSS. I would like to implement a feature where additional information is displayed when hovering over a product card, similar to the functionality seen on wildberries.ru. I have tried using &apo ...

When hovering over a select element within a grid-area that has overflow set to scroll, Safari unexpectedly jumps to the

Encountering a strange issue that I can't seem to figure out. When testing the code in Safari, hovering over the select field causes the .page div to scroll to the top. This behavior only occurs when .page is within a grid layout and there's a s ...

Tips for restricting the size of inserted content in a contentEditable paragraph

I am in need of a one-line editable paragraph that can contain text without overflowing its size. Currently, I am using CSS to hide the overflow and prevent multiple lines by not displaying the children of the paragraph. However, what I really want is fo ...

When a new page loads, use Javascript to automatically reposition an anchor element below a top fixed element

I am in the process of learning how to use Javascript, and I have some JS code that moves page anchors 90 pixels below the top of the page. This is done to ensure that the contents of the anchor are not hidden by a fixed element at the top of the page. It ...

Conceal a div while revealing the other div

I am currently trying to achieve a unique visual effect. I have three divs named div1, div2, and div3. The objective is for div1 to slide up and disappear when clicked, while div2 simultaneously slides up and becomes visible. Similarly, when div2 is click ...

Retrieve a specific element using BeautifulSoup

Looking at this html structure found in a bs4.BeautifulSoup: <div class="bordered radius border-color-ui-2 bg-white h-100"> <a href="#" class="box-card-link-wishlist" role="button" aria-label="Adicion ...