开发者

Is there a css hack for Chrome to make <textarea> a certain height? [closed]

开发者 https://www.devze.com 2023-01-21 19:01 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 开发者_运维百科years ago.

I have a <textarea> that appears at different heights with all the browsers.

Is there a css hack for Chrome?


Chrome uses the webkit rendering engine, which is among the better rendering engines. It is about as compliant with HTML5 and CSS standards as you'll see in the wild today.

Your best bet is to write code focused on the standards-compliant browsers (Chrome, Safari, Opera, and Firefox) If you're not doing any super-crazy HTML5, you'll find all these browsers act pretty much the same. As a bonus, mobile browsers are generally based on webkit or opera, so you'll also have the mobile market covered.

Even Internet Explorer (by the time you get to version 8) plays along pretty well with most of the standards (again, assuming you're not doing HTML5 form elements or the video tag or something.) The problem is the older versions of IE, particularly IE6.

Write your CSS for standards-compliant browsers first. Then use a conditional comment to add a special exceptions stylesheet read only by IE6 and earlier. Put the CSS adjustments you need there to take care of IE6.

Best of luck to you....


Yes, but it's not "a hack" it's just CSS. Put a CSS selector on your textarea.

<textarea id="myTextBox" >Here is your text </textarea>

Then, add a css rule like so:

#myTextBox{
height: 150px;  //adjust this to desired height.
}

I haven't studied this, but I would guess that there just isn't an HTML standard default for the height of a TextArea. You can specify a row property as well, but I think you might still end up with a few pixels difference between the browsers. Using CSS height property WILL make them all the same...

0

精彩评论

暂无评论...
验证码 换一张
取 消