What is the method for changing the background color of a search container within a blue top bar?

I'm having trouble styling the search field in the topbar of my website. The topbar and icons have a blue background (#6495ed) with white icons, but the search container remains white. How can I make it blue?

I have tried setting the background to #6495ed for both the search input and button within the search container (a div). I've adjusted the margin and padding multiple times, but haven't found the right combination.

Interestingly, when I created a JsFiddle, I couldn't replicate the issue! Isn't that strange? https://jsfiddle.net/r5uqb8v0/1/

Please refer to this picture for a visual explanation.
https://drive.google.com/file/d/1idQKbtKHaOT-QXByAMw1tXR9l9owMUlc/view?usp=sharing

The issue persists on both Chrome and Firefox.
I am working on Windows 10, using MySQL 5.7.22, PHP 7.2.4, and Apache 2.4.33 (WampServer).

Here is the HTML code for the search field:

<div class="item3 search-container">
  <form action="/action_page.php">
   <input type="text" placeholder="Search..." name="search">
   <button type="submit"><i class="fa fa-search"></i></button>
  </form>
</div>

And here is the CSS code:

.topnav .search-container {
  border: none;
  outline: none;
  color: inherit;
  padding: 0;
  float: right;
  background: #6495ed;
  margin: 0;
  text-decoration: none;
  cursor: pointer;
}
.topnav .search-container input {
  padding: 0px;
  margin: 0;
  border: none;
  font-size: 1em;
  display: none;
  width: 100%; /* Full width */
  cursor: pointer;
}
.topnav .search-container button {
  font-size: 1.875em;
  border: none;
  outline: none;
  color: white;
  padding: 6px 10px;
  background: #6495ed;
  margin: 0;
  display: inline;
  cursor: pointer;
  width: 100%; /* Full width */
}

While the topbar and icons have the correct blue background (#6495ed) and white icons, the search container remains white. Any suggestions or solutions would be greatly appreciated. Thank you for taking the time to read this!

Best regards,
Samuel

Answer №1

Samuel, I have tested your code locally and it appears to be functioning correctly. I utilized your JsFiddle code and did not encounter the reported issue. Please see the screenshot attached for confirmation. Rest assured, your code is working as intended.Click here to view the image

[Sometimes our browsers can cause unexpected issues on our systems. It's recommended to ensure they are up-to-date and consider reinstalling the browser if needed.]

Answer №2

One way to customize your design is by incorporating style attributes directly into the HTML element

Here's an example:

<i class="fa fa-car" style="font-size:60px;color:red;"></i>
fa fa -car - represents a font awesome icon class that I utilized in the above snippet.

Simply include your desired style properties within the <i> tag

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 code is not executing properly in the javascript function

Hello there! I've created a basic login form with JavaScript validation, but for some reason, the code below isn't functioning properly. Here is my HTML and JS code: <head> <script type="text/javascript"> function ha ...

What's the best way to dynamically show Bootstrap collapse panels in a loop with AngularJS ng-repeat?

Currently, I am utilizing angularJS and attempting to include a bootstrap collapsible-panel within a loop. The code that I have written is causing all the panel bodies to be displayed beneath the first panel header. I need each body to be shown below i ...

Adapting the position of a table row in AngularJS based on the

I need assistance with creating a dynamic table-row that moves to indicate the current time in a table filled with timestamps. <table> <tr ng-repeat="timestamp in timestampArray"> <td>{{timestamp}}</td> </tr> ...

Styling problem arises on IOS devices due to rounded corners affecting select box

The dropdown menu I am using to "sort products" on our WordPress website is causing some styling issues specifically on IOS devices. I would like the dropdown menu to have rounded corners. It seems to display rounded corners on IOS, but it still shows the ...

trouble seeing images with an array input and ngFor in Angular

I am encountering issues while attempting to exhibit an array of images by their source link using ngFor. It seems like there are errors hindering the functionality! Below is the image HTML code located within my card component: <div class="Session-Pa ...

"Exploring the world of CSS3: Arrow shapes and animated effects

Looking at the image provided, my task is to create and animate it. I was considering using CSS3 border-radius instead of an actual image. Below are the HTML and CSS code that I have so far. The animation I envision involves the arrow gradually appearing ...

The Angular integration with Semantic UI dropdown does not display the selected value clearly

I have put together a small example to demonstrate the issue. http://plnkr.co/edit/py9T0g2aGhTXFnjvlCLF Essentially, the HTML structure is as follows: <div data-ng-app="app" data-ng-controller="main"> <select class="ui dropdown" id="ddlStat ...

Utilizing Bootstrap to Showcase a Form

I am facing some confusion. In my MVC5 project, I am trying to display a form with 4 input fields. The display looks perfect without using the @using (HTML.BeginForm(...) statement. @using(Html.BeginForm("Create", "HR", FormMethod.Post)) { When the @ ...

Tips for creating a hover effect on a rounded outline button with a gradient border

What I am looking for: I want the buttons to have rounded corners; The buttons should use linear-gradient, with button A as the border and button B as the background color; When hovering over the buttons, the opacity should change to 0.5. This works fine ...

What is the best way to adjust the size of an image on Internet Explorer 8

I am struggling with resizing an image from 90px x 90px to 60px x 60px specifically in Internet Explorer. I have tried using the CSS style recommended on some websites: .img { -ms-interpolation-mode: bicubic; } Unfortunately, this did not work for me. Cu ...

The Jquery test isn't functioning as expected - the green square fails to display

So, the concept is that the green square should appear when your mouse hovers over the red square, but it's not working as expected. Here's the code snippet: <html> <head> <script type="text/javascript" src="jquery-1. ...

How to vertically align elements using CSS in Firefox

In my project, I have created an unordered list with various bullet images and I am attempting to align the text for each list item vertically centered. Although this works perfectly in Chrome and Safari, I am encountering issues with Firefox where the ver ...

Is it possible to refresh the chat-box using PHP?

I recently created a chat box application using PHP, but I'm facing an issue with its automatic reload functionality. Is there a way to implement auto-reload in PHP itself, or would it be better to restructure the system to utilize AJAX? Additionally, ...

Designing the Mailchimp signup form with React styling techniques

I downloaded the NPM React module for Mailchimp from this link: https://www.npmjs.com/package/react-mailchimp-form. It works well and provides all the necessary forms, but I'm having trouble customizing its style. The documentation suggests adding a ...

Delivering HTML Email

I want to send an HTML email with images using Google's SMTP servers. Here is the HTML code with inline CSS that I have generated: <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type& ...

Creating a spinning Cube with separate fields for x, y, and z rotation speeds: a step-by-step guide

After dabbling in Java, Visual Basic, HTML, and CSS, I'm now looking to create an interface featuring a central spinning cube with 3 fields to control its x, y, and z rotation speeds. Can you suggest which language would be the best fit for this proje ...

How to place a button in SwiperJs using React

Can anyone provide guidance on how to position the navigation buttons in a manner similar to the image below? The desired layout is for the buttons to appear on the outer edges of the swiper component. You can refer to this demo for more information. htt ...

Is there a way to verify the identity of two fields using an external script such as "signup.js"?

My current project involves working with Electron, and it consists of three essential files. The first file is index.html: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel="styles ...

Generate HTML content based on the permissions from a REST API

I have a frontend that renders based on user permissions from a REST API. These permissions could include deleting users, creating users, adding users to workflows, and more. Most of these permissions are managed by an administrator. So my question is: H ...

Running intricate javascript/jquery/json code using an html checkbox

Hey there, I'm hoping this issue is simpler than I'm making it out to be... So, I've got this pretty complex JSON/jQuery function (3000 lines long) that builds a DOM tree in a separate JS file. This JS file also contains a bunch of other on ...