最近在修改项目的一个需求变更时,无意间发现了以前的一个问题,
这里拿出来讨论,可能在其他项目中没有碰到这样的需求或者无意中规避了这个问题
也或许已经有html&CSS高手把问题解决,都请来分享一下经验:
问题描述如下
因为客户不太懂技术,把上述td的宽度设置了百分比,然后为了好看又把里面的文本框也设置了width:100%,想让他自适应
更改之后变成这样
1 <html> 2 <head> 3 4 </head> 5 <body> 6 <table style="background-color:green;width:100%"> 7 <tr> 8 <th style="width:20%;background-color:red">th1</th> 9 <td style="width:30%;background-color:yellow">10 <input type="text" style="width:100%" maxlength="100" value="">11 </td>12 <th style="width:30%;background-color:red">th2</th>13 <td style="width:20%;background-color:yellow">14 <input type="text" maxlength="100" style="width:100%" value="">15 </td>16 </tr>17 </table>18 <table style="background-color:white;width:100%">19 <tr>20 <th style="width:20%;background-color:red">th1</th>21 <td style="background-color:yellow">22 <input type="text" maxlength="100" style="width:100%" value="">23 </td>24 25 </tr>26 <tr>27 <th style="width:20%;background-color:red">th1</th>28 <td style="background-color:yellow">29 <input type="text" maxlength="100" style="width:100%" value="">30 </td>31 32 </tr>33 <tr>34 <th style="width:20%;background-color:red">th1</th>35 <td style="background-color:yellow">36 <input type="text" maxlength="20" style="width:100%" value="">37 </td>38 39 </tr>40 <tr>41 <th style="width:20%;background-color:red">th1</th>42 <td style="background-color:yellow">43 <input type="text" maxlength="20" style="width:100%" value="">44 </td>45 46 </tr>47 <tr>48 <th style="width:20%;background-color:red">th1</th>49 <td style="background-color:yellow">50 <input type="text" maxlength="20" style="width:100%" value="">51 </td>52 53 </tr>54 </table>55 </body>56 </html>
因为是老代码,这个画面恶心的地方首先是第一行和下面的各行不在一个table里,
图中的这个文本框对应的数据库表对应的字段是一个100位英文内容,如果满位输出的话,画面变成了这样。。。
1 <html> 2 <head> 3 4 </head> 5 <body> 6 <table style="background-color:green;width:100%"> 7 <tr> 8 <th style="width:20%;background-color:red">th1</th> 9 <td style="width:30%;background-color:yellow">10 <input type="text" style="width:100%" maxlength="100" value="0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789">11 </td>12 <th style="width:30%;background-color:red">th2</th>13 <td style="width:20%;background-color:yellow">14 <input type="text" maxlength="100" style="width:100%" value="">15 </td>16 </tr>17 </table>18 <table style="background-color:white;width:100%">19 <tr>20 <th style="width:20%;background-color:red">th1</th>21 <td style="background-color:yellow">22 <input type="text" maxlength="100" style="width:100%" value="">23 </td>24 25 </tr>26 <tr>27 <th style="width:20%;background-color:red">th1</th>28 <td style="background-color:yellow">29 <input type="text" maxlength="100" style="width:100%" value="">30 </td>31 32 </tr>33 <tr>34 <th style="width:20%;background-color:red">th1</th>35 <td style="background-color:yellow">36 <input type="text" maxlength="20" style="width:100%" value="">37 </td>38 39 </tr>40 <tr>41 <th style="width:20%;background-color:red">th1</th>42 <td style="background-color:yellow">43 <input type="text" maxlength="20" style="width:100%" value="">44 </td>45 46 </tr>47 <tr>48 <th style="width:20%;background-color:red">th1</th>49 <td style="background-color:yellow">50 <input type="text" maxlength="20" style="width:100%" value="">51 </td>52 53 </tr>54 </table>55 </body>56 </html>
目测,这个文本框因为有一个maxlength=100,的设置,ie试图在允许的范围下,把内容全部显示,但是这样的话,画面就乱了,
测试环境是:IE 9,IE 8下也存在该问题,在chrome下完美解析,如下图:
所以据此推测是IE在解析INPUT上和chrome内核不太一致,但是现在开发是在IE8上进行,除了设置固定width和使用Js动态加载,有没有别的办法来兼容解决问题。。。
注:style=“table-layout:fixed”我用过了,但是这个办法有点狠,不太适合

이 기사는 HTML & lt; Progress & Gt에 대해 설명합니다. 요소, 그 목적, 스타일 및 & lt; meter & gt의 차이; 요소. 주요 초점은 & lt; progress & gt; 작업 완료 및 & lt; meter & gt; Stati의 경우

이 기사는 HTML & LT; Datalist & GT에 대해 논의합니다. 자동 완성 제안을 제공하고, 사용자 경험을 향상시키고, 오류를 줄임으로써 양식을 향상시키는 요소. 문자 수 : 159

이 기사는 HTML & lt; meter & gt에 대해 설명합니다. 범위 내에 스칼라 또는 분수 값을 표시하는 데 사용되는 요소 및 웹 개발의 일반적인 응용 프로그램. & lt; meter & gt; & lt; Progress & Gt; 그리고 Ex

이 기사는 모바일 장치의 반응 형 웹 디자인에 필수적인 Viewport Meta Tag에 대해 설명합니다. 적절한 사용이 최적의 컨텐츠 스케일링 및 사용자 상호 작용을 보장하는 방법을 설명하는 반면, 오용은 설계 및 접근성 문제로 이어질 수 있습니다.

기사는 HTML5 크로스 브라우저 호환성을 보장하기위한 모범 사례에 대해 논의하고 기능 감지, 점진적 향상 및 테스트 방법에 중점을 둡니다.

이 기사는 html5 & lt; time & gt; 시맨틱 날짜/시간 표현 요소. 인간이 읽을 수있는 텍스트와 함께 기계 가독성 (ISO 8601 형식)에 대한 DateTime 속성의 중요성을 강조하여 Accessibilit를 향상시킵니다.

이 기사에서는 브라우저에서 직접 사용자 입력을 검증하기 위해 필요한, Pattern, Min, Max 및 Length 한계와 같은 HTML5 양식 검증 속성을 사용하는 것에 대해 설명합니다.

이 기사는 & lt; iframe & gt; 외부 컨텐츠를 웹 페이지, 공통 용도, 보안 위험 및 객체 태그 및 API와 같은 대안을 포함시키는 태그의 목적.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

뜨거운 주제



