Accessibility

CSS Advisor

Scrolling Backgrounds in Input & Textarea Fields

by Oli_K12 on March 30, 2007 Avg Rating 3.4 (11)   |   Log in to rate post.

Tagged with Explorer 6.0 , Explorer 7.0 , textarea , input , Background

Problem

IE6-7 incorectly scrolls an applied element background with background-attachment: scroll; when the user scrolls a textarea field or overflows an input field. This is incorrect behavior as the element background should only scroll with regards to the viewport.

Solution

No known solution or workaround, however this is only visible when the input element background consists of a pattern or an image.

Detailed description

A background image can be applied to an input or text element as shown:

/*CSS*/

input[type=text], input[type=password], textarea {
   background-image: url('pattern_or_image.gif');
   background-attachment: scroll; /* Note that this is the default value, and that using 'fixed' will not work as this ironically fixes the background to the viewport. */
   overflow: scroll;
}
IE7 incorrectly scrolls the background of a text input or a textarea when overflow is entered or when the attached scrollbar component is used.

The CSS2.1 specification states (from http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment):

"If an element has a scrolling mechanism (see 'overflow'), a 'fixed' background doesn't move with the element, and a 'scroll' background doesn't move with the scrolling mechanism."

See the attached image for a demonstration.

scrollbuggif.gif




Text ID: SCROLLING_INPUT_BACKGROUNDS_IE7



Comments (1)

To add a comment, please Log in.




Input Field Background Image Scrolling in IE 7 only

I am having trouble getting it to work in IE 7.

/* Input Styles */
.skinField {
padding: 2px 0 0 0;
margin: 5px 0 0 0;
width: 172px;
height: 22px;
float: left;
text-indent: 11px;
color: #333;
border: 0;
background: transparent url('../images/bg/home_form_field.gif') no-repeat top right;
_background-attachment: fixed;
*background-position: top left; /* For IE 7 scrolling */
}

Tyler Lange
www.epochwebdesign.com
www.needforspeed.com
www.ea.com





CSS Advisor home
Submit a post

rss

CSS ADVISOR RSS FEEDS
Recent: POSTS | COMMENTS | EDITS


Browsers
Internet Explorer (45)
Mozilla/Firefox (16)
Opera (7)
Safari (13)
CSS Properties
Background (6)
Border (3)
Color (1)
Float (15)
Font (1)
Margin (6)
Padding (4)
Position (15)
Text (13)
Width/Height (9)