Issue with the size of HTML elements in Chrome version 32

Since the recent chrome 32 update, there seems to be an issue with the width of html elements like input and select when defined by a css with properties such as:

position:absolute;
left:10px;
right:20px;

This problem is unique to chrome 32 as it worked perfectly fine in chrome 31 and other browsers.

To see this issue firsthand, check out the following link using chrome 32:

http://jsfiddle.net/EAkLb/7/

Answer №1

According to W3C, the recommended way to render input elements is by creating a container div with absolute positioning and setting the width of the input element to 100%.

<div class="container">
    <input type="text"/>
</div>

<style type="text/css">
    .container {
        position:absolute;
        left:10px;
        right:20px;
    }
    .container input {
        width: 100%;
    }
</style>

You can view an example at http://jsfiddle.net/pjK8s/1/

To add padding to the input field, style the container to mimic the appearance of the input and make the input itself transparent.

<div class="container">
    <input type="text"/>
</div>

<style type="text/css">
    .container {
        position:absolute;
        left:10px;
        right:20px;
        padding: 1px 8px;
        margin: 2px 0px;
        -webkit-appearance: textfield;
    }
    .container input {
        width: 100%;
        border: 0px;
        margin: 0px;
        padding: 0px;
        background: transparent;
        outline: none;
    }
</style>

Check out an example at http://jsfiddle.net/Vyj22/1/

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

Email confirmation section

I'm in the process of setting up a subscription newsletter page, and everything seems to be working correctly except for the part where I need users to enter their email address twice. The second email field is meant for confirmation purposes, but I&a ...

Stop HTML Select/Option from resetting following jQuery AJAX request

Something strange is happening. Here's the problem I'm facing. In my online application, there are three tabs where users can input and view data - List, Time Preference, and Search Results. In the Time Preference tab, users can choose from a se ...

Using the Requests library in Python to transmit POST data

I am encountering difficulties sending POST data to access my account using the requests library in Python. The resulting soup remains unchanged as if no POST request was made. Here is the code I have been utilizing, which previously worked on a different ...

Is it possible to use CSS to create a fading effect on the edges of a div

I am looking to implement a mobile modal popup that will show a success message. Currently, I am working to add a semi-transparent overlay to the entire screen using this CSS: .overlay { position:fixed; top:0px; left:0px; width:100%; h ...

overlay the div or image with a translucent color

I have a div containing an image with the results from my database, carefully designed and positioned within each div. However, I would like to highlight certain results by overlaying them with a color. I am seeking a method to achieve this effect withou ...

Adjust the size and color of text in Chart.js using Angular 5

Why does the font color in chartjs appear as light gray and not print when you want to do so from the page? I tried changing the font color of chartjs in the options attribute, but it didn't work. How can I change the font color in chartjs angular? ...

Issues have arisen with the @keydown.ctrl and @keyup.ctrl event modifiers in Vue.js, as they are not properly responding

I have a project in VueJS where I need to implement a custom context menu that will pop up when the user hovers over specific elements on the page. This context menu is dynamic, meaning it changes as the user moves between different items. If the user hold ...

Empty the fields upon closing the div tag

I used this code to toggle the opening and closing of a div: $('#addvisit').on('click', function(e) { e.stopImmediatePropagation(); $('#fechvisit').slideToggle('slow'); }); <script src="https://cdnjs.c ...

Stretching the height of a table without altering the position of its contents

While working on a project using Angular and Angular Material, I have realized that the solution might actually lie in pure CSS. The issue I'm facing is with a table that currently has only 2 or 3 rows. I want this table to have a fixed height of 700 ...

What is the best way to have my sliding panel automatically close when I click outside of it?

I have created a sleek sliding navigation panel for my website that appears when the screen width is reduced. Although I am satisfied with how it functions currently, I would like the panel to close when the user clicks/taps outside of it. What adjustments ...

Build a JavaScript image carousel featuring custom text for each image

I recently completed a tutorial on creating JavaScript image sliders. I have successfully added a text box to display on each image, but now I need the text to be specific for each individual image. The images are sourced from an img folder and are labeled ...

Fragment with HTML embedding for full screen video display in web view

Hello everyone, I have a question about enabling full-screen support for HTML embedded videos in my webview. I have set hardware acceleration to true in the manifest and the video plays fine, but when I try to go fullscreen, the video stops. Here is my co ...

When writing HTML tags H1-H6, they will automatically adopt the default styles specified in the _type

I am facing issues with my HTML-CSS code as some CSS properties are being overridden unexpectedly. Despite defining custom properties for the h1 tag, I noticed that they are getting overridden by settings from _type.scss file. https://i.sstatic.net/EJ3OE. ...

Troubleshooting: Issue with removeClass function when using CSS transitions

Is there an issue with my code where the removeClass is not working properly on the second click when trying to create a blink effect? Can you identify the mistake? JavaScript: $('div').click(function() { $(this).css({transition: '0s&a ...

Styling your tables with custom CSS in Bootstrap 4

Looking to design a unique CSS for a Bootstrap 4 table without impacting other standard tables. Can anyone provide the specific CSS code for customizing this table and setting it for all elements? <table class="table table-responsive table-bordered t ...

Ways to include ".com" content statically in HTML on a website with a .org domain

I need to modify the content of a webpage in HTML. Example 1: Whenever I change the domain name to end with .com, the URL within my content automatically updates to www.example.com. Here is an example: dotCOM Example 2: Similarly, if the domain name en ...

Restricting the caption width to match the image width

Is there a way to automatically wrap text in a figcaption when it reaches the right side of an image? .flex-container { padding: 0; margin: 0; list-style: none; display: flex; flex-flow: row wrap; justify-content: flex-start; } .flex-figure- ...

What causes larger breakpoints to collapse earlier than smaller breakpoints?

Compare the following two code snippets that use bootstrap: a) <div class="row"> <div class="col-lg-4" style="background-color:blue;">First</div> <div class="col-lg-8" style="background-color:red;">Second</div> </di ...

Arrange elements prior to the treeview within the unordered list/ list items

Below is a snippet of code that I am working with: <ul> <li>group 1 <ul> <li>group 1.1</li> <li> group 1.2</li> <li>group 1.3 <ul> <li>group 1.3.1</li> <l ...

Utilize a React component within a JavaScript file by incorporating ReactDOM in a script found in an HTML file

Can someone explain the process of importing a component into a script in an HTML file? What specific modifications need to be made to ensure everything runs smoothly? Do the Babel libraries need to be included in the HTML file, especially when Webpack ...