search
HomeWeb Front-endHTML Tutorial[Help] Help on the page. The text box is relatively fixed_html/css_WEB-ITnose

现在 有一个文本框和一个table 在同一个

 (这是个弹出窗口,点击后弹出该DIV)
由于table内很多行 所以导致弹出的窗口有垂直滚动条,当滚动条滚动时 文本框也会随之滚动
希望可以做到只有table数据随之滚动,文本框在最上面固定 需要怎么做呢?

回复讨论(解决方案)

position:fixed
?

position:fixed
? 不太对, 这个属性是对于整个页面固定的  而我要的是一个div里的另一个DIV 针对外层DIV固定

<div style="overflow:hidden;">     <div region="north">input放在这里</div>     <div region="center" style="overflow-y: auto;">table放在这里</div></div>

外面那层div加个split="true"

<div split="true" style="overflow:hidden;">            <div region="north">input放在这里</div>            <div region="center" style="overflow-y: auto;">table放在这里</div> </div>

外面那层div加个split="true"

<div split="true" style="overflow:hidden;">            <div region="north">input放在这里</div>            <div region="center" style="overflow-y: auto;">table放在这里</div> </div>

现在是这样一个结构    ^^^



div  table 相关都在JSP里面 很多页面都用到了搜索框  即 text文本框 所以 这个是写在JS里面的

现在想的是 只改 这里  让文本框 相对于DIV固定在最上面 就是看table中的行 翻滚  但是文本框一直在div最上面即可  可以实现么

外面那层div加个split="true"

<div split="true" style="overflow:hidden;">            <div region="north">input放在这里</div>            <div region="center" style="overflow-y: auto;">table放在这里</div> </div>
.
现在是这样 

 小>
 大>

只修改 div 小 和 input 可以实现我说的text 在div大最上面固定么

你不想改变现有结构   可以参考这个(不过真没有我那个方法方便):http://blog.sina.com.cn/s/blog_62f573ad01013ntd.html

你不想改变现有结构   可以参考这个(不过真没有我那个方法方便):http://blog.sina.com.cn/s/blog_62f573ad01013ntd.html
虽然没有解决我的问题 依然谢谢你~~~

还有人有高见么 坐等

外面那层div加个split="true"

<div split="true" style="overflow:hidden;">            <div region="north">input放在这里</div>            <div region="center" style="overflow-y: auto;">table放在这里</div> </div>
我试过了 不对~~~~~~~~~

我的是好的,效果图如下:

我的是好的,效果图如下:


嗯 你的图跟我需求差不多 方便共享下源码么

我的是好的,效果图如下:

我用你的 为什么 显示出来就没有下拉条了。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /></head><body>     <div region="west" split="true"  title="毒品列表" style=" width:180px; height:400px; overflow:hidden; border:true">        <div region="north" style="height:80px;border:true" >            <table width="100%" cellspacing="0" cellpadding="6">                <tr>                    <td>                        <input type="text" id="name" style="border: 1px solid #8DB2E3;width: 121px; height: 18px" />                    </td>                </tr>                <tr>                    <td style="text-align:right">                        <input type="radio" id="ch" name="language" value="1" />中文                         <input type="radio" id="en" name="language" value="0" />英文                    </td>                </tr>            </table>        </div>         <div region="center"style="width:100%; height:100%; overflow-y:auto;border:solid 1px black">            <select id="Chinese" multiple="multiple" style="width: 100%; height: 82%;">                                <option value="01000000" style="color:#08298A">农药中毒</option>                                 <option value="01010000" style="color:#08298A">有机磷</option>                                 <option value="01010100" style="color:#08298A"> 敌敌畏</option>                                 <option value="01010200" style="color:#08298A">敌百虫</option>                                 <option value="01010300" style="color:#08298A">甲基内吸磷</option>                                 <option value="01010400" style="color:#08298A">对硫磷</option>                                 <option value="01010500" style="color:#08298A">甲基对硫磷</option>                                 <option value="01010600" style="color:#08298A">甲胺磷</option>                                 <option value="01010700" style="color:#08298A">乙酰甲胺磷</option>                                 <option value="01010800" style="color:#08298A">乐果</option>                                 <option value="01010900" style="color:#08298A">氧乐果</option>                                 <option value="01011000" style="color:#08298A">*</option>                                 <option value="01011100" style="color:#08298A">硫*</option>                                 <option value="01011200" style="color:#08298A">甲拌磷</option>                                 <option value="01011300" style="color:#08298A">二嗪农</option>                                 <option value="01011400" style="color:#08298A">二溴磷</option>                                 <option value="01011500" style="color:#08298A"> 八甲磷</option>                                 <option value="01011600" style="color:#08298A">马拉硫磷</option>                                 <option value="01011700" style="color:#08298A">久效磷</option>                                 <option value="01011800" style="color:#08298A">水胺硫磷</option>                                 <option value="01011900" style="color:#08298A">亚胺硫磷</option>                                 <option value="01012000" style="color:#08298A">杀扑磷</option>                                 <option value="01012100" style="color:#08298A">杀螟松</option>                                 <option value="01012200" style="color:#08298A">谷硫磷</option>                                 <option value="01012300" style="color:#08298A">苯硫磷</option>                                 <option value="01012400" style="color:#08298A">速灭磷</option>                                 <option value="01012500" style="color:#08298A">倍硫磷</option>                                 <option value="01012600" style="color:#08298A">磷胺</option>                                 <option value="01012700" style="color:#08298A">内吸磷</option>                                 <option value="01020000" style="color:#08298A">氨基甲酸酯</option>                                 <option value="01020100" style="color:#08298A">克百威</option>                                 <option value="01020200" style="color:#08298A"> 灭多威</option>                                 <option value="01020300" style="color:#08298A">甲萘威</option>                                 <option value="01020400" style="color:#08298A">速灭威</option>                                 <option value="01020500" style="color:#08298A">仲丁威</option>                                 <option value="01020600" style="color:#08298A">害扑威</option>                                 <option value="01020700" style="color:#08298A">异丙威</option>                                 <option value="01020800" style="color:#08298A">涕灭威</option>                                 <option value="01020900" style="color:#08298A">抗蚜威</option>                                 <option value="01021000" style="color:#08298A">呋喃威</option>                                 <option value="01021100" style="color:#08298A">残杀威</option>                                 <option value="01021200" style="color:#08298A">混灭威</option>                                 <option value="01021300" style="color:#08298A">硫双威</option>                                 <option value="01030000" style="color:#08298A">拟除虫菊酯</option>                                 <option value="01030100" style="color:#08298A">丙烯菊酯</option>                                 <option value="01030200" style="color:#08298A">甲醚菊酯</option>                                 <option value="01030300" style="color:#08298A">戊菊酯</option>                                 <option value="01030400" style="color:#08298A">苄呋菊酯</option>                                 <option value="01030500" style="color:#08298A">胺菊酯</option>                                 <option value="01030600" style="color:#08298A">氯菊酯</option>                                 <option value="01030700" style="color:#08298A">氟氰菊酯</option>                                 <option value="01030800" style="color:#08298A">氟氯氰菊酯</option>                                 <option value="01030900" style="color:#08298A">氯氰菊酯</option>                                 <option value="01031000" style="color:#08298A">顺式氯氰菊酯</option>                                 <option value="01031100" style="color:#08298A">溴氰菊酯</option>                                 <option value="01031200" style="color:#08298A">氰戊菊酯</option>             </select>         </div>    </div></body></html>

我的是好的,效果图如下:

再麻烦看下我哪里是不是写错了还是理解错了

按4楼方法 为什么table的数值都跑到右面去了 滚动条也没了

直接一个position:absolute  不是就可以了么

直接一个position:absolute  不是就可以了么  是给小的DIV加么


直接一个position:absolute  不是就可以了么  是给小的DIV加么

对,然后用js获取外层div的滚动高度,当外层div滚动时更新就好了。

把table单独放到一个div中,给div设置overflow:auto;

还有人有高见么 坐等
简单的一个定位就好了,给你示例:

       <div style="position: relative;">           <div style="position: absolute;top:1px;left: 1px;width: 175px;padding: 5px 0 0 5px;background: #fff;">               <input type="text" />           </div>           <div style="height: 100px;width:200px;border: solid 1px red;overflow: auto;padding-top:30px;">               <table>                   <tr><td>1</td></tr>                   <tr><td>2</td></tr>                   <tr><td>3</td></tr>                   <tr><td>4</td></tr>                   <tr><td>5</td></tr>                   <tr><td>6</td></tr>               </table>           </div>       </div>

把table单独放到一个div中,给div设置overflow:auto;
你看我15楼的截图啊 是给table单独放到一个div里了 并且也设置aotu了 但是不对啊


还有人有高见么 坐等
简单的一个定位就好了,给你示例:

       <div style="position: relative;">           <div style="position: absolute;top:1px;left: 1px;width: 175px;padding: 5px 0 0 5px;background: #fff;">               <input type="text" />           </div>           <div style="height: 100px;width:200px;border: solid 1px red;overflow: auto;padding-top:30px;">               <table>                   <tr><td>1</td></tr>                   <tr><td>2</td></tr>                   <tr><td>3</td></tr>                   <tr><td>4</td></tr>                   <tr><td>5</td></tr>                   <tr><td>6</td></tr>               </table>           </div>       </div>


非常感谢  基本满足结果了 现在还有一个问题就是 下拉滚动时 input是透明的 如下图



还有人有高见么 坐等
简单的一个定位就好了,给你示例:

       <div style="position: relative;">           <div style="position: absolute;top:1px;left: 1px;width: 175px;padding: 5px 0 0 5px;background: #fff;">               <input type="text" />           </div>           <div style="height: 100px;width:200px;border: solid 1px red;overflow: auto;padding-top:30px;">               <table>                   <tr><td>1</td></tr>                   <tr><td>2</td></tr>                   <tr><td>3</td></tr>                   <tr><td>4</td></tr>                   <tr><td>5</td></tr>                   <tr><td>6</td></tr>               </table>           </div>       </div>


非常感谢  基本满足结果了 现在还有一个问题就是 下拉滚动时 input是透明的 如下图

我给的示例的div上的就特意已经加上了背景:background: #fff; 你设置成你自己的颜色就行了,div的大小也可以根据实际情况调整下。




还有人有高见么 坐等
简单的一个定位就好了,给你示例:

       <div style="position: relative;">           <div style="position: absolute;top:1px;left: 1px;width: 175px;padding: 5px 0 0 5px;background: #fff;">               <input type="text" />           </div>           <div style="height: 100px;width:200px;border: solid 1px red;overflow: auto;padding-top:30px;">               <table>                   <tr><td>1</td></tr>                   <tr><td>2</td></tr>                   <tr><td>3</td></tr>                   <tr><td>4</td></tr>                   <tr><td>5</td></tr>                   <tr><td>6</td></tr>               </table>           </div>       </div>


非常感谢  基本满足结果了 现在还有一个问题就是 下拉滚动时 input是透明的 如下图

我给的示例的div上的就特意已经加上了背景:background: #fff; 你设置成你自己的颜色就行了,div的大小也可以根据实际情况调整下。
非常感谢 学习到很多 谢谢~~

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML vs. CSS and JavaScript: Comparing Web TechnologiesHTML vs. CSS and JavaScript: Comparing Web TechnologiesApr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use