Flexbox search bar positioned above a set of flexbox buttons

In an attempt to replicate Google's search bar, the following code has been developed:

<head>
    <title>Search</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="positions.css">
</head>
<body>    
    <div id="input_field">
        <input type="text" name="q">
    </div>
    <form action="https://google.com/search">
        <div class="flexbox-container">                
            <div class="button_search_pos"><input type="submit" value="Google Search"></div>
            <div class="lucky_pos"><input type="submit" value="I’m Feeling Lucky"></div>     
        </div>            

Here is the associated CSS:

Various suggestions provided on Stackoverflow were tested to no avail. Although there are pre-made solutions available on platforms like YouTube, I prefer to create my own. The challenge is to align the input field above both buttons using Flexbox, while ensuring that it remains responsive when the page size changes.

Any assistance would be greatly appreciated!

#input_field{
    position: absolute;
    top: 310px;
    left: 41%;
}
.flexbox-container{
    display: flex;
    align-items: center;
    justify-content: center;    
    min-height: 100vh;
}
.lucky_pos, .button_search_pos{    
    text-align: center;
    padding:1px;
    margin: 0;
    flex-direction: row;
}

Answer №1

I have a suggestion for your CSS code that I modified:

body {
  text-align: center;
}
#search_field{
  
    width: 60%;
    margin: auto;
    margin-top: 15%;
}
.flexbox-container{
    display: flex;
    align-items: center;
    justify-content: center;    
    margin-top: 7%;
}
.lucky_position, .search_button_position{    
    text-align: center;
    padding: 2px;
    margin: 0;
    flex-direction: row;
}

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

Customize the appearance of every other column in an asp gridview

Looking for help with formatting rows and columns in an ASP GridView. The rows are automatically colored alternating, and I want to make the content in every first column bold and every second column normal. I have heard about using CSS nth-child() to achi ...

Conceal User Interface Angular Tabulation

I'm working on setting up UI Bootstrap tabs, and for reference you can find the plunker here. My goal is to hide the tabs since I will be utilizing a button to switch between them. Despite adding the following CSS class to my file, the styling is not ...

Boost Page Text Size Using CSS

Possible Duplicate: Allowing users to adjust font size on a webpage My goal is to create webpages where users can click an image to increase the font size of all content. Is this achievable? If so, how would I go about implementing it? I am aware that ...

Selenium error: element has become detached from the page and is no longer accessible

Currently, I am encountering an error while trying to display items extracted from websites, and I am seeking to understand the root cause of it. My preferred browser for this task is Google Chrome. chromeDriver.Navigate().GoToUrl("somewebsites"); chrome ...

Encountering an error in a Javascript function: Property 'style' is unreadable because it is undefined

When attempting to run this Javascript function, an error message appears stating, 'Cannot read property 'style' of undefined at showSlides' var slideIndex = 1; showSlides(slideIndex); // Next/previous controls function plusSlides(n) ...

Conceal tooltip containing message using the required field validator in AngularJS

I'm looking to control the visibility of a tooltip for an input field that requires validation with the message: "This is a required field". Currently, I am implementing this using an ng-required input tag. <form novalidate name="CustAddressDe ...

Employing the for() loop for generating distinct PHP variables

Managing a dynamic input form for adding new quizzes to a database can be a challenge. The form layout typically includes a title followed by multiple questions, each with four answer choices. The number of questions may vary for each quiz, which adds comp ...

Adjust the font color in code function for Woocommerce

I am looking to customize the appearance of a specific part of this code: '% discount' This section displays the percentage amount followed by the word "Discount," and I would like to apply a unique color to this "% discount" * Modify the disp ...

The fixed navigation bar is obscured by the address bar in Chrome mobile

After starting a new project, I encountered an issue with my fixed navbar while testing it on Chrome on mobile iOS. Initially, I believed it to be a browser bug, but after reviewing previous projects, I realized that they functioned properly with the fixed ...

Steps for updating the <option> selection in the third <select> menu when the second <select> menu changes, with the second menu being populated by altering the value of the first dropdown through jQuery AJAX

I'm facing a unique situation in my school management project and have been unable to find a solution online. Here's the issue: I have three <select> elements - the first one is for selecting a class, the second one is for selecting a secti ...

What is the best way to superimpose two images with the same width but varying heights, where one remains static and the other scrolls seamlessly

I'm in the process of creating a webpage that will feature a .png image of a computer with a transparent screen. Upon this image, I plan to overlay a screenshot of a website and allow users to scroll through it as if they were navigating a real webpag ...

Tips for aligning the text of a button and placeholder vertically

I am facing an issue with centering placeholder/input text and button text vertically on my website. I used Bootstrap to create the site and utilized its input and button classes, but I couldn't figure out how to achieve vertical alignment. I tried ad ...

Is there a way to modify the color of the horizontal line within react-native-otp-inputs in the React Native platform?

Is there a way to customize the color of the horizontal line in react-native-otp-inputs for react native? I used react-native-otp-inputs to capture user OTP input, but now I want to change the color of the default black horizontal line to white. You can re ...

Missing information in input field using JQUERY

I've been attempting to extract a value from an input tag, but all I keep getting is an empty string. Upon inspecting the frame source, it appears as follows: <input type="hidden" name="" class="code_item" value="00-00000159" /> In order to re ...

Overflow: Truncating text with an ellipsis in the center

Seeking a CSS-only solution for adding an ellipsis in the middle of a string when it exceeds its container. I have tried splitting the container in half, trimming the first half with a wrapper on a whole letter and adding an ellipsis to the front of the s ...

Optimizing web layouts to fit on a single page is the most effective

Struggling to create a print layout for my web page that seamlessly transitions from the digital realm to the physical world. Utilizing HTML and CSS has presented challenges in aligning the "digital" design with a "real printable" page due to uncertainties ...

Improve the loading speed of large datasets into HTML tables

I have a problem where I generate an HTML table from code behind to display data like a grid (Note: I am not using GridView). When the data is large, around 2000 rows, it causes the application to display a white page as if it has hung. What is the best w ...

What are the steps to create a unique popup div effect with jQuery?

Upon clicking the icon on this page, a mysterious div appears with information. I'm completely baffled by how they achieved this cool effect using css/jQuery tools. Can anyone shed some light on the mechanism behind this? ...

Is there a way to automatically submit an upload form once a file has been selected?

Need help with automatically submitting a file upload form when a file is selected. Is there a way to bypass the need for the user to click the Submit button? ...

I am facing issues with my Bootstrap and CSS conflicting with each other in React JS

My styles are mysteriously changing when I add the bootstrap link between the <head></head> tags. Here is the header without the bootstrap link: https://i.sstatic.net/ly2nf.png And here is the header with the bootstrap link: https://i.sstatic ...