Text input not displaying CSS properties

I've been attempting to apply certain CSS properties to my forms, but for some reason, they're not taking effect when I move the properties to the parent HTML element. Although the CSS properties added directly to the .input class are working as expected, those applied to the parent .form-control class don't seem to have any impact on the input field. Additionally, none of the .form-control properties show up in Chrome dev tools when inspecting the text input element.

.form-control {
  display: inline-block;
  height: 34px;
  width: 100%;
  margin: 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
}


/*.form-control .input {*/
/*height: 34px;*/
/*width: 100%;*/
/*margin: 10px;*/
/*border-radius: 4px;*/
/*border: 1px solid #ccc;*/
/*}*/

.form-control .button {
  display: block;
  background-color: limegreen;
  font-size: 14px;
  font-weight: 400;
  color: white;
  margin: auto;
  vertical-align: middle;
  padding: 6px 12px;
  border: 1px solid transparent;
  height: 25px;
  border-radius: 4px;
}
<form className="form-control">
  <input className="input" type="text" />
  <button className="button">Get Weather</button>
</form>

Answer №1

Based on the snippet of code you shared, it seems like the issue arises from applying the rules to the form itself rather than its input fields. The input elements will not automatically inherit the styling properties set on the form. To address this, make sure to target the input specifically as shown in the commented-out section of your code.

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

What is the process of converting a Class Component to a functional component in React?

Struggling to grasp the concept of functional components in React, I attempted to convert a class component to a functional one. Unfortunately, my code is not functioning correctly and I am in need of assistance. I made changes based on the following proj ...

Stop Sublime Text from automatically calculating Less2Css

Within my workflow using Sublime Text and Less2Css for dealing with less files, I encountered an issue where specifying the max-height of a container as 100% - 20px resulted in minification reducing it to '80%'. Is there a way to work around this ...

Steps for eliminating a selection in the dropdown list:

I am dealing with a situation in which my select element gets new options added based on a specific input value. However, each time the value is changed, more options are appended to the select element instead of replacing the old ones. How can I remove th ...

Updating a marker's position every second in React-Leaflet by fetching coordinates from a hidden .env file

I have a simple React-Leaflet map running on a small HTTP server on an Arduino board. I want to update the marker's position (my position) based on the coordinates extracted by the Arduino from a connected GPS board. The process should function as fo ...

Having trouble with cy.clock and cy.tick functionality when using split code

In my React.js project, I have a countdown using setInterval from 15 to 0 seconds. However, in e2e tests, I need to speed up this process as 15 seconds may not be suitable for testing purposes. The following code achieves the desired result: describe(&apo ...

Is there a way to display all file errors in a React app using ESLint with just one line of code in the package.json scripts?

How can I display all errors from every file in a React/Next.js app using ESLint in the command line when running commands like "npm run errors" or "npm run lint"? I attempted to look for ESLint resources, but unfortunately came up empty-handed. ...

Tips for Expanding the Height of a Parent Div to Fill Its Containing Parent

I am experiencing some difficulty with a seemingly simple task. My goal is to have the lime-colored background expand and fill 100% of the current height of its parent container (in this case, the magenta-colored section). Here is a live example: https:/ ...

React Navigation: Updates the URL without rendering the associated component

Having recently started exploring React and Material-UI, I find myself struggling with a routing issue. Upon clicking the button, the URL changes, but the component does not render. Despite trying numerous solutions found on StackOverflow, nothing seems t ...

aligning vertically within inline elements

HTML <html> <head> <style type="text/css"> div { height: 300px; width: 300px; background-color: aqua; margin-bottom: 10px; } ...

"Discovering the active span tag in a webpage: A step-by-step guide

I have a main anchor tag with two span tags inside, each with a different class name as shown below. <a class="clickSlide" id="btnmain_login" href="/"> <span class="Icohide"></span> <span ...

Why is the React onClick method returning undefined upon the first selection, and why are the values being passed not consistent with

While attempting to create a list of users that, when clicked, should open up a corresponding user's message, I encountered an issue where clicking for the first time resulted in an 'undefined' value being passed. I've tried troublesho ...

experiencing challenges using react-testing-library in conjunction with material-ui

Trying out my first test using react-testing-library, but I'm having trouble selecting the correct material-ui element. https://codesandbox.io/s/lx5nl1839z An error message pops up stating that the event was never triggered. The mock function ...

Ways to merge two arrays into one in React JS

Here are two arrays presented below: const arrayA = { 0: { id: XXXXXXX, name: "test" }, 1: { id: YYYYYYY, name: "example" } } const arrayB = { 0: { id: XXXXXXX, category: "sea", } 1: { id: YYYYY ...

I am struggling to assign the height style attribute to a div element

I have created the code below where I am attempting to set a div to 'display: flex' and include two divisions, one with a width of 200px and the other with a width of 100%. <div style="clear:both;display:flex; height: 100%;"> <div ...

Creating a unique custom row labeled "ALL" at the top of an ag-grid, allowing it to be selected just like any other row

Looking for assistance regarding a customization in my ag-grid setup. The table consists of two columns - one for text and the other for numbers. I am trying to include a unique row at the very top of the ag-grid table that displays the total value of all ...

How to Align Video Alongside Image in HTML without Using CSS

Is there a way to place a video on the left and an image on the right of the same line in HTML without relying on CSS? ...

Tips for using Howler library in React to automatically play audio upon loading the page

I'm troubleshooting why the audio on my webpage won't start playing when the page loads, and instead only plays after a mouse click triggers an event. The audio works fine but I want it to automatically play as soon as the page is loaded. import ...

Tips for shutting down an open section within a jQuery Accordion?

I am having trouble closing the active panel using jQuery. The rest of my code is functioning perfectly, but for some reason, I can't get the active panel to close. Currently, the code is working correctly in that only one panel can be open at a time ...

Is it possible for CSS to bypass an HTML element?

Summary: Can CSS be instructed to ignore an HTML element without affecting its children? The ignored element should not impact the styling of its children, treating them as if they were direct descendants of the parent. In Depth Analysis: Imagine a caref ...

Developing the search feature using Sequelize

Before diving into the question, let's take a look at the structure of the post table in my current project. module.exports = class Post extends Model { static init(sequelize) { return super.init({ title: { type: DataTypes.TE ...