Ways to style the bottom border of an input with CSS

Currently, I am trying to change the color of an input border bottom when the input is not in focus. Below is my HTML code:

<input type="number" id="nc" name="days" class="numero" placeholder="" min="0"><br />

Here is the CSS code I have tried:

.numero {
    border-bottom-color: red;
}

Unfortunately, this approach does not seem to be working as intended. Any suggestions or assistance would be greatly appreciated!

Answer №1

Your example displays a red border:

.numero {
  border-bottom: 1px solid #F00;
}
<input type="number" id="nc" name="days" class="numero" placeholder="" min="0"><br />

By using shorthand, it's simple to add style, size, and color.

To remove the border when focused, do the following:

.numero:not(:focus) {
  border-bottom: 1px solid #F00;
}
<input type="number" id="nc" name="days" class="numero" placeholder="" min="0"><br />

The :not() function combined with :focus checks if the element is not focused.

Answer №3

Here is a CSS code snippet to add border style:

.numero{
  border: 1px solid;
  border-bottom-color: red;
}

Answer №4

To set the border thickness, it is recommended to define it in the CSS code. Here's an example of how you can do that:

.numero {
    border-bottom:1px solid red;
}

If you want to change the border color on focus, you can use the following code:

.numero:focus {
    border-bottom:1px solid transparent;
}

You have the flexibility to replace the value of transparent with any other color of your choice.

Answer №5

.number-indicator {
  border-bottom: 2px solid aquamarine;
}
<input type="number" id="num_id" name="quantity" class="number-indicator" placeholder="" min="0"><br />

Feel free to leave a comment for any questions or doubts. Best of luck!

Answer №6

.numero {
    border-bottom:1px solid blue;
}

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

Ways to efficiently display elements in a grid in real-time

Attempting to design a layout where each row consists of 3 cards using Bootstrap's Grid layout for responsiveness. The challenge lies in the fact that the card data is stored in JSON format, and the length of the JSON Object array may vary, leading t ...

Searching for li elements that contain text values - a guide

I have a list of letters and I want to filter out any values that contain the text entered by the user in a textbox. Here is the design: Search List: <input type="text" id="txtSearch" /> <ul> <li>Coffee1</li> <li>Coffe ...

display upcoming schedule and time

How can I display the future date and time in the respective field components? See below for a sample code snippet: require([ "dojo/_base/lang", "dijit/registry", "dojo/ready", "dijit/form/TimeTextBox", "dojo/parser" ], function(lang, registry, ready ...

Building a HTML table using PHP

My goal is to generate a dynamic table using data from mysql. I am trying to create the table layout as shown in 'demo1', but I am facing challenges with the formatting, similar to what is depicted in 'demo'. The query and values are co ...

There seems to be an issue with the location.href function in the server-side code of

I'm encountering an issue in the code below where I am attempting to redirect to the login page, but it seems to not be functioning as expected. app.get('/current-pass', (req, res) => { res.sendFile(path.join(staticPath, "currentPass ...

Issue with creating a new jstree node

I recently put together a basic jstree. When I click on a link, it triggers the createNode() function. This function utilizes the create feature from the API to generate a new node. It appears to be a common issue with jQuery that I am encountering. Any ...

Automatic updates are enabled for Google Chrome extensions

I noticed that all the extensions I analyzed had a specific code in their manifest.json, even though Google says you don't have to include it if you host your Chrome app on their servers. Should I also include this code in my Chrome extension manifest ...

Identifying mouseover event across numerous elements in JavaScript

I'm attempting to identify the mouseover event on multiple elements using their class as a reference. For instance: <div class="myElement">1</div> <div class="myElement">2</div> <div class="myElement">3</div> & ...

Extract the <img> element from the Angular model property

I'm currently leveraging Angular to display some HTML content: <p class="description" ng-model="listing.Description"></p> When the content is rendered, it includes images within the text, which is acceptable. However, now I aim to ident ...

What is the best way to pinpoint particular text within a paragraph that includes numerous line breaks?

So here is the puzzling situation I'm grappling with. Here's a peek at the HTML snippet: <p>This paragraph has <br><br> two unusual line breaks <br><br> and it happens TWICE!</p> The problem arises when tryi ...

Height of border not being displayed accurately

I have been searching for a solution to my unique issue with inserting borders in HTML and CSS. When I try to add a border to three images, the height does not display correctly. This is all part of my learning process to improve my skills in coding. Belo ...

Creating a specific type of table using Ruby on Rails

Is it feasible to create a table with two columns, where the left column incorporates multiple rows with a scroll bar, and the right column contains a large box housing buttons that alter based on the selection of blocks in the left column? ...

Building a tag cloud with only HTML5 and CSS3

I am looking to generate a word cloud similar to the one shown in this image : click here for reference Is there a way to create a tag cloud without relying on JavaScript? Using only HTML5 and CSS3. Appreciate any guidance. Does anyone have a solution fo ...

Exploring the width of Bootstrap 5 Tab Pane content

My issue lies with the content width of my tab panels - specifically, it doesn't work well with columns. I am unable to divide a tab-pane as col-md-7 and col-md-5 (refer to the screenshot below). I am unsure of how to resolve this issue. <div clas ...

The data type 'string' cannot be assigned to the data type 'Position'

Currently, I am in the process of converting React js to typescript. The component being used is a Class Component. I would like to obtain CSS settings through props and apply them to an element. How can I resolve this issue? render(){return( <span st ...

Can a collapse that was saved in a separate file be displayed on the requested page?

Imagine having a navigation bar on your website's index page with four buttons, each leading to a different page. What if you wanted to bring all those separate pages together into one by using collapsible elements? That's the challenge this user ...

Importing .js files from the static folder in Nuxt.js: a step-by-step guide

I'm in the process of transitioning my website, which is currently built using html/css/js, to Nuxt.js so that I can automatically update it from an API. To maintain the same website structure, I have broken down my code into components and imported ...

What are the guidelines for incorporating tag names in CSS selectors?

I created a button that when clicked, displays a table containing actors. I have named them as follows: <button class="actors">Show actors</button> <table class="actors">...</div> Next, I want to style and access them in my CSS (a ...

Show unique language text in the <noscript> element based on the user's browser language

I am just starting out with HTML, and I would like to show a message if JavaScript is disabled. To do this, I have placed the message within the <noscript> tag, which is working perfectly. <noscript> Need to enable Javascript. </noscript> ...

The event target within the input is undefined when using this.setState in React.js

Within my react component, I've incorporated a file input like so: <input type="file" onChange={this.onFileChange.bind(this)} /> The function onFileChange is defined as follows: onFileChange(e) { let file = e.target.files[0]; this.setSta ...