The red border highlighting Chrome's input

I want to apply the css style border-color: red;
to input elements.
But I notice that their dimensions change compared to the default chrome border.

You can view the example on jsfiddle:
http://jsfiddle.net/79QkJ/2/

In the example, you'll see that both input fields appear different even though the only expected difference is the red color.

How can I maintain the default input style but in a different color?

Answer №1

The default appearance may initially seem like border-width: 1px;, but in reality, it is (at least in chrome) border: 2px inset;. The inset style doesn't complement red very well.

To overcome this, you can try something like:

border-color: 1px solid red;
padding: 2px 1px;

The default padding is set as 1px 0; so it should be adjusted to 2px 1px.

http://jsfiddle.net/79QkJ/13/

Answer №2

Give this a shot

When any of these elements have focus - input, select, textarea, or button - the outline will be removed.

Answer №3

What if using the border property in this way is not correct?

"The border property actually combines several individual border properties, including: - border-width - border-style (which is necessary) - border-color "

Allowing the browser to handle spacing autonomously.

Answer №4

If you want to experiment, you could give this a shot:

#red-input {
    border-color: red;
    border-style: solid;
    border-width: 0.1em;
}

Alternatively, you can utilize the shorthand property for borders:

#red-input {
    border: 0.1em solid red;
}

I typically use "em" for sizing, but you have the option to use "px" as well.

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

Variables disappearing after hiding the flash application

In the div, I have a flash file embedded. This div is initially visible with display:block;. There are two other sister divs alongside this one. All three divs are controlled by jQuery tabs, which means when a different tab is clicked, the current visible ...

Manipulating CSS styles through Javascript with passed parameters

I need a feature that allows users to pick the color of the buttons displayed on the website. Currently, I am working with Angular 6 and JavaScript to achieve this functionality. I am focusing on setting the primary color, affecting buttons with the Bootst ...

Guide to Presenting HTML data stored in an SQL database on an ASP.NET webform

I need help figuring out how to dynamically display a blog page from my database. The content I'm pulling contains HTML tags, so right now it's showing the raw data with tags included. What I really want is for it to display like a proper page. ...

The class in my CSS is currently impacting all the menu bar items, but I specifically want it to only affect my photo gallery

<div class="gallery"> <a tabindex="1"><img src="images/smile.jpg"></a> <a tabindex="1"><img src="images/smile.jpg"></a> <a tabindex="1"><img src="images/smile.jpg"></a> ...

How do you toggle the visibility of a dependent <select> in an HTML form?

In my HTML jQuery form, I need to display a second select box based on the user's selection in the first select box. Should I use .show() to reveal a previously hidden div or should I use .append() to populate an empty select element? In other words, ...

interactive web elements powered by html and javascript

When utilizing ajax, I am able to dynamically generate html code in response to a button click. The html code is designed to link various figures together. Here is an example of the html code: <a class="show_figures" id="show_figures0" loop-id="0" hre ...

Jquery failing to trigger click() on a div with an id

Within my erb file, there exists a script that looks like the following: function checkJquery() { if(window.jQuery) { jQuery(document).ready(function() { alert('onready'); $('div#habla_topbar_div').click(function( ...

Evaluating the initial value from an array for radio buttons in Angular using Typescript

I am trying to retrieve the first value from an array that I receive through a get request via an api. Below is my HTML code: <div class="row" class="select-options" *ngFor="let options of paymentOptions;let idx = index"&g ...

Tips for making a table have the same width as its child td elements and enabling the table to exceed the width of the viewport

I am facing a challenge with a table that has dynamically changing rows and columns. <table> <tr> <td>column 1</td> <td>column 2</td> <td>column 3</td> </tr> <tr> <td> ...

Is there a way to resolve the warning message "The shadow-piercing descendant combinator (>>>) is deprecated" that appears when running ng build for production?

I keep receiving warnings when I run ng-build -c production for all my styles that contain the '>>>' notation. Warning: ▲ [WARNING] Unexpected ">" /Users/mike/project2022/client/src/app/bank/bank-new/bank-new.component.ts-angular- ...

The scrollbar fails to reach the bottom of my table, preventing me from viewing the entire content

I'm currently facing a challenge with a table on my webpage that displays data but isn't scrolling all the way to the bottom. This code was implemented by previous developers, and as someone who isn't well-versed in CSS, I'm struggling ...

Display or conceal headers depending on the corresponding homepage using Vue.js

I currently have a header-one that appears on all pages by default. Additionally, there are header-two and header-three which only appear when their respective home pages are visited. Is there a way to conditionally show header-v1 if the path is '/hom ...

Using AngularJS and ChartJS together for stellar data visualization

I need help displaying the canvas element within custom angular directives. Being new to AngularJS, I am in search of a demo or idea regarding Chart.js integration with AngularJS. Important: I specifically require a custom directive for chart display. T ...

Using inline SVG as a background in CSS

Recently, I've been on the hunt for a way to create a blur effect on a background specifically for IE10+. After experimenting with StackBlur, I found that it did work, but unfortunately, it was quite slow due to the size of my background image. I&apos ...

IE's inconsistent float alignment causing display issues

My challenge is getting my div elements to float correctly in Internet Explorer. They are displaying perfectly in Chrome and Firefox, but IE seems to be messing up the code. The jsfiddle link showcasing the issue can be found here: http://jsfiddle.net/vlya ...

What is the best way to retrieve the input value from post.ejs?

app.js var express = require('express'); var bodyParser = require('body-parser'); var app = express(); var passport = require('passport'); var localStrategy = require('passport-local'); var axios = require("axi ...

Enhance Your Website with a jQuery Plugin for Dynamic Updates to ElementsgetPost

Is there a way to update the content inside an element by passing a new value to the public method updateText? Currently, when I try to pass a new string to the updateText method and click the button, only the method name is received as an argument instea ...

Revamp the design of the Google image layout

I am trying to replicate the layout of a Google search results page. My goal is to have a full-width div appear on screen when an image is clicked, with a small triangle at the bottom of the clicked image. I attempted to place the img inside another div, ...

Creating a gap between two rows within a Bootstrap table

Is there a way to create space between two bootstrap table rows? I am looking for something like this: --------- | A B | --------- --------- | C D | --------- --------- | E F | --------- Here is the code snippet: <script src="https://cdnjs.c ...

Deleting a row from a table in Angular using a modal popup

Is there a way to remove a table row by pressing the confirm button in the modal popup? Open Delete Row Modal Popup I've attempted several methods without success thus far. I have coded separate components for adding, editing, and deleting users. H ...