Responsive Input Navigation Bar CSS

How can I create a top bar that resembles the design of Google Play?

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

I am struggling to make the input box flexible and fit the window size...
The minimum width of Div.search is set to 250px but it's not working. Can someone help?

*{
box-sizing: border-box;
}
.topbar{
position: fixed;
top: 0;
left: 0;
width: 100%;
min-width: 900px;
height: 60px;
background-color: #FFFFFF;
border-bottom: 1px solid #C7C7C7;
}
.menu{
position: absolute;
top: 15px;
left: 30px;
width: 30px;
heigth: 30px;
background-color: #777777;
}
.logo{
position: absolute;
top: 10px;
left: 70px;
width: 100px;
height: 40px;
background-color: #80DF5F;
}
.search{
flex: 0 2 auto;
position: relative;
margin: 15px 0px 0px 200px;
padding-right: 50px;
min-width: 250px;
width: 700px;
height: 30px;
background-color: #2A77FF;
}
.search input{
display: block;
width: 100%;
}
.btn{
position: absolute;
top: 0;
right: 0;
width: 50px;
height: 30px;
background-color: #FF3B3B;
}
.chat{
position: absolute;
top: 15px;
right: 20px;
width: 100px;
height: 30px;
background-color: #FFC536;
}
<div class="topbar">
<div class="menu">=</div>
    <div class="logo">Logo</div>
    <div class="search">
    <input type="text">
    <div class="btn">button</div>
    </div>
    <div class="chat">C</div>
</div>

Answer №1

Combine the widths of all other elements (including their horizontal positions) and utilize the calc function to specify the width of the .search div: width: calc(100% - 380px);

Optimal solution for updated web browsers (IE9 and above)

*{
box-sizing: border-box;
}
.topbar{
position: fixed;
top: 0;
left: 0;
width: 100%;
min-width: 900px;
height: 60px;
background-color: #FFFFFF;
border-bottom: 1px solid #C7C7C7;
}
.menu{
position: absolute;
top: 15px;
left: 30px;
width: 30px;
heigth: 30px;
background-color: #777777;
}
.logo{
position: absolute;
top: 10px;
left: 70px;
width: 100px;
height: 40px;
background-color: #80DF5F;
}
.search{
flex: 0 2 auto;
position: relative;
margin: 15px 0px 0px 200px;
padding-right: 50px;
min-width: 250px;
width: calc(100% - 380px);
height: 30px;
background-color: #2A77FF;
}
.search input{
display: block;
width: 100%;
}
.btn{
position: absolute;
top: 0;
right: 0;
width: 50px;
height: 30px;
background-color: #FF3B3B;
}
.chat{
position: absolute;
top: 15px;
right: 20px;
width: 100px;
height: 30px;
background-color: #FFC536;
}
<div class="topbar">
<div class="menu">=</div>
    <div class="logo">Logo</div>
    <div class="search">
    <input type="text">
    <div class="btn">button</div>
    </div>
    <div class="chat">C</div>
</div>

Solution compatible with legacy browsers (<=IE8):

*{
box-sizing: border-box;
}
.topbar{
position: fixed;
top: 0;
left: 0;
width: 100%;
min-width: 900px;
height: 60px;
background-color: #FFFFFF;
border-bottom: 1px solid #C7C7C7;
}
.menu{
position: absolute;
top: 15px;
left: 30px;
width: 30px;
heigth: 30px;
background-color: #777777;
}
.logo{
position: absolute;
top: 10px;
left: 70px;
width: 100px;
height: 40px;
background-color: #80DF5F;
}
.search-wrapper {
min-width: 250px;
padding-left: 200px;
padding-right: 170px;
width: 100%;
position: relative;
margin: 15px 0px 0px 0px;
}
.search{
position: relative;
width: 100%;
padding-right: 50px;
height: 30px;
background-color: #2A77FF;
}
.search input{
display: block;
width: 100%;
}
.btn{
position: absolute;
top: 0;
right: 0;
width: 50px;
height: 30px;
background-color: #FF3B3B;
}
.chat{
position: absolute;
top: 15px;
right: 20px;
width: 100px;
height: 30px;
background-color: #FFC536;
}
<div class="topbar">
<div class="menu">=</div>
    <div class="logo">Logo</div>
    <div class="search-wrapper">
<div class="search">
<input type="text">
<div class="btn">button</div>
</div>
</div>
    <div class="chat">C</div>
</div>

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

When an item in the accordion is clicked, the modal's left side scroll bar automatically scrolls to the top. Is there a solution to prevent this behavior and

When I first load the page and click on the Sales accordion, then proceed to click on Total reported and forecasted sales, the scrollbar jumps back up to the top The marked ng-container is specifically for the UI of Total reported and forecasted sales He ...

Having trouble getting the jQuery toggle function to work properly with div elements

I'm struggling with some divs that are not behaving as expected. When I click the button, it opens and changes the text to "Collapse", but when I click it again, it doesn't change the text back to "Find Support". Additionally, if I click on a dif ...

Html elements overlapping due to incorrect positioning

I'm having an issue with my div elements on a web page. Despite them being set up separately, they all end up positioned underneath the first div created (SiteFullControl). Is there any solution to prevent this from happening? <div id="SiteFullCo ...

Tips for aligning elements of varying heights

Currently, I am tackling a responsive web design challenge involving floating multiple items in 4 columns side by side. The issue arises due to the varying heights of these items, causing the floating to behave improperly. Here is the current problem illu ...

The flashing of Bootstrap tabs can be seen on various pages

Currently, I am encountering an issue with bootstrap tabs on my website. There seems to be a blinking problem with the tabs on certain pages. Check out this video showcasing the blinking tab in the search result page: Watch Here Interestingly, the same ta ...

Creating a dynamic Bootstrap navigation bar using PHP

I created a website using bootstrap, but now I want to add more dynamic features. The tutorial I'm following for this does not involve the use of bootstrap. Am I missing something obvious here? Could you please review my code? (To avoid overloading t ...

Move the accordion slider to the top of the browser

I'm working with an accordion menu that has some long content. To make it more user-friendly, I want to add a slide effect when the accordion items are opened. Right now, if you open the first two menu items, the last item's content is cut off a ...

Rearrange the order of divs dynamically to prevent wrapping/overflow, no need for media queries

Can someone help me with this issue? I am trying to create a navigation bar with centered menus/links, a logo on the left, and call-to-action buttons and icons on the right. If the content overflows or wraps, I want the center column to move to the next l ...

Transition the object in smoothly after the slide has changed

How can I make the h4 tags fade in after the divs slide into view, while also adding the class "current" to each visible slide? Check out the example on JSFiddle here. <div class="slider"> <div class="slides"> <div class="slide ...

What strategies can I implement to ensure my modal dialog box remains responsive? Adjusting the window size causes the modal box to malfunction and lose its structure

Whenever I adjust the size of the browser window, the elements inside the modal box become misaligned. HTML <div class='modal'> <div class='modal-content'> </div> </div> Below is the CSS for the modal ...

Expanding the content of a single page by clicking on a separate tab

I have a link on Page A. Page B has two tabs, with the content of tabs 1 and tab 2 currently set to "display:none". I want clicking the hyperlink on page A to automatically open or activate the second tab on page B. I am seeking a solution using JavaScri ...

Layers of CSS images

Is there a way to create multiple layers for images on a webpage so they can move independently without affecting other elements? I attempted to use z-index, which did work, but it caused the page to increase in height. Additionally, when using jQuery.posi ...

Tips for adjusting the alignment of numbers in an ordered list to the right

Check out the code snippet below: The list items are correctly aligned to the right, but the numbers are not. How can we adjust the CSS so that the numbers align properly on the right as well? ol { width: 15vw; } <ol style="text-align:right;"> ...

Consistent CSS alignment across all browsers

I have designed a four-digit counter that needs to be displayed in the bottom right corner of the page. Each digit is represented by a block image as a background. It is functioning properly in Chrome, but there are compatibility issues with IE7+ and Firef ...

Is there a way to include a textarea or text input in a table row and have it expand upon clicking or dragging, without increasing the row height?

I am looking for a way to allow a textarea to expand or grow when clicked or dragged, without affecting the height of the table row it is in. You can see an example of the issue on this CodePen: https://codepen.io/kerastensorflow/pen/PobaRvK?editors=1010 ...

Understanding Aspect Ratios in CSS for Div Containers and their Components

I am crafting an HTML5 game without the use of canvas and aiming to maintain a 16:9 aspect ratio within my div. Thanks to javascript, achieving this is straightforward and it functions flawlessly. However, the elements inside the div occasionally appear to ...

Bootstrap navbar problem: struggling to adjust padding for image and navigation links

Can anyone help me understand why my navbar isn't displaying padding on the left and right as specified in my CSS? I've been trying to figure it out for a while now, but I'm not sure if I need to remove the div-container fluid or if I'm ...

Web server experiencing issues with loading scripts and CSS files

After successfully building my project using CodeIgniter on localhost, I encountered an issue when trying to run it on a webhost. The site was functional but the design elements such as scripts and stylesheets were not loading properly. Before uploading t ...

Applying CSS classes to a custom AngularJS directive: A step-by-step guide

Need to have a CSS class called tab for the nav HTML element, which will be used as a directive: <nav tab></nav> The expected interpretation is: <nav class="tab"> <a></a> <a></a> <a></a> ...

The function toggleClass() is malfunctioning

The .toggleClass() method seems to only be adding the "class" attribute to my selection, resulting in: <div id="toggle" class> ... rather than: <div id="toggle" class="on"> ... I've been trying to solve this issue for about 2 hours now ...